Using Go1.7.4.
Consider the following test:
func Test(t *testing.T) {
var wg sync.WaitGroup
defer wg.Wait()
for i := 0; i < 100; i++ {
wg.Add(1)
go func(i int) {
defer wg.Done()
t.Run(fmt.Sprintf("LongLongLongLongName%d", i), func(t *testing.T) {})
}(i)
}
}
On some invocations, I see something like:
=== RUN Test/LongLongLongLongName48
=== RUN Test/LongLon=== RUN Test/LongLongLongLongName50
gLongLongName49
=== RUN Test/LongLongLongLongName51
In testing.go, we directly write "=== RUN %s\n" directly to the root's io.Writer (which is os.Stdout). Although it is safe to concurrently write to os.Stdout, the results can sometimes be non-sensical.
Instead, we should acquire the root's lock before writing.
Using Go1.7.4.
Consider the following test:
On some invocations, I see something like:
In testing.go, we directly write "=== RUN %s\n" directly to the root's io.Writer (which is os.Stdout). Although it is safe to concurrently write to os.Stdout, the results can sometimes be non-sensical.
Instead, we should acquire the root's lock before writing.