diff options
| author | Alberto Donizetti <alb.donizetti@gmail.com> | 2017-06-01 12:14:23 +0200 |
|---|---|---|
| committer | Brad Fitzpatrick <bradfitz@golang.org> | 2017-06-29 16:21:32 +0000 |
| commit | 68e1b3e361b84ed7a4d5564e37a12a2c3d473283 (patch) | |
| tree | b68f869d639e8b1f436dc3d3afc6da3d9568a460 /src | |
| parent | 6b8813ca4515cd558f12eb26582cdfd5909c9f3b (diff) | |
| download | go-68e1b3e361b84ed7a4d5564e37a12a2c3d473283.tar.xz | |
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>
Diffstat (limited to 'src')
| -rw-r--r-- | src/testing/benchmark.go | 2 | ||||
| -rw-r--r-- | src/testing/testing.go | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/src/testing/benchmark.go b/src/testing/benchmark.go index be9e96d50c..484a6d7e12 100644 --- a/src/testing/benchmark.go +++ b/src/testing/benchmark.go @@ -482,7 +482,7 @@ func (ctx *benchContext) processBench(b *B) { // least once will not be measured itself and will be called once with N=1. // // Run may be called simultaneously from multiple goroutines, but all such -// calls must happen before the outer benchmark function for b returns. +// calls must return before the outer benchmark function for b returns. func (b *B) Run(name string, f func(b *B)) bool { // Since b has subbenchmarks, we will no longer run it as a benchmark itself. // Release the lock and acquire it on exit to ensure locks stay paired. diff --git a/src/testing/testing.go b/src/testing/testing.go index 96c34a5aea..80031039b4 100644 --- a/src/testing/testing.go +++ b/src/testing/testing.go @@ -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) |
