New upstream version 1.2.0
Sascha Steinbiss
5 years ago
70 | 70 | colorful bool |
71 | 71 | } |
72 | 72 | |
73 | var isColorful bool | |
73 | var noColorFlag bool | |
74 | 74 | |
75 | 75 | func init() { |
76 | noColor := flag.Bool("nocolor", false, "turns off colors") | |
77 | flag.Parse() | |
78 | isColorful = !*noColor | |
76 | flag.BoolVar(&noColorFlag, "nocolor", false, "turns off colors") | |
79 | 77 | } |
80 | 78 | |
81 | 79 | // New makes a new testing helper using the specified |
83 | 81 | // In strict mode, failures call T.FailNow causing the test |
84 | 82 | // to be aborted. See NewRelaxed for alternative behavior. |
85 | 83 | func New(t T) *I { |
86 | return &I{t, t.FailNow, os.Stdout, isColorful} | |
84 | return &I{t, t.FailNow, os.Stdout, !noColorFlag} | |
87 | 85 | } |
88 | 86 | |
89 | 87 | // NewRelaxed makes a new testing helper using the specified |
91 | 89 | // In relaxed mode, failures call T.Fail allowing |
92 | 90 | // multiple failures per test. |
93 | 91 | func NewRelaxed(t T) *I { |
94 | return &I{t, t.Fail, os.Stdout, isColorful} | |
92 | return &I{t, t.Fail, os.Stdout, !noColorFlag} | |
95 | 93 | } |
96 | 94 | |
97 | 95 | func (is *I) log(args ...interface{}) { |
188 | 186 | // pattern: |
189 | 187 | // |
190 | 188 | // func Test(t *testing.T) { |
191 | // is := is.New(t) | |
189 | // is := is.NewRelaxed(t) | |
192 | 190 | // t.Run("sub", func(t *testing.T) { |
193 | // is := is.New(t) | |
191 | // is := is.NewRelaxed(t) | |
194 | 192 | // // TODO: test |
195 | 193 | // }) |
196 | 194 | // } |