testing: clarify rules for concurrent t.Run calls

Apparently, "all such calls must happen" means that the t.Run call
must *return* before the outer test function returns, or the calls
will cause a data race on t.ran.

Clarify the docs.

Fixes #20339

Change-Id: I191a9af2a9095be1e0aaf10b79c30e00a9c495cb
Reviewed-on: https://go-review.googlesource.com/47150
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
Alberto Donizetti 2017-06-01 12:14:23 +02:00 committed by Brad Fitzpatrick
parent 6b8813ca45
commit 68e1b3e361
2 changed files with 2 additions and 2 deletions

View file

@ -760,7 +760,7 @@ func tRunner(t *T, fn func(t *T)) {
// have completed.
//
// Run may be called simultaneously from multiple goroutines, but all such calls
// must happen before the outer test function for t returns.
// must return before the outer test function for t returns.
func (t *T) Run(name string, f func(t *T)) bool {
atomic.StoreInt32(&t.hasSub, 1)
testName, ok, _ := t.context.match.fullName(&t.common, name)