Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
testing: are T.Run and B.Run safe for concurrent use? #18603
I do not see any documentation specifying if T.Run is safe for concurrent use. I see the following doc for testing.T, which does not mention T.Run:
There is a similar doc for testing.B.
I ask because I believe T.Run was safe for concurrent use in go 1.7. Then, this line was added in go 1.8, which made T.Run no longer safe for concurrent use. I don't particularly care whether T.Run is safe for concurrent use, but I think the semantics should be clarified.
Optimistically labeling this go1.8.
CL https://golang.org/cl/35354 added this comment to B.Run():
Which I don't think is true at all: calling B.Run() multiple times from multiple goroutines results in benchmarkLock.Unlock() being called multiple times before benchmarkLock.Lock(), which causes a crash.
(example code: https://play.golang.org/p/0u15AvArTK)
Is this a documentation issue or a implementation issue? cl/35354 does have a test for multiple goroutines using when using
Are you proposing we properly making