diff options
author | Bryan C. Mills <bcmills@google.com> | 2021-03-19 11:48:22 -0400 |
---|---|---|
committer | Bryan C. Mills <bcmills@google.com> | 2021-03-19 17:34:25 +0000 |
commit | 1c590661e7d3b477662f76ead56f39567ea8345a (patch) | |
tree | e43a8ef5cf92eafbd44405924c5dfbf387adb194 /src/testing | |
parent | 482903150dff1a4e9791330aed24ae607005fc18 (diff) | |
download | go-1c590661e7d3b477662f76ead56f39567ea8345a.tar.gz go-1c590661e7d3b477662f76ead56f39567ea8345a.zip |
testing: allow parallel-subtest goroutines to exit when the subtest is complete
Fixes #45127
Updates #38768
Change-Id: I7f41901d5bcc07741ac9f5f2a24d2b07ef633cb1
Reviewed-on: https://go-review.googlesource.com/c/go/+/303330
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src/testing')
-rw-r--r-- | src/testing/testing.go | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/testing/testing.go b/src/testing/testing.go index 383e56a20e..0df6e45ec4 100644 --- a/src/testing/testing.go +++ b/src/testing/testing.go @@ -1258,7 +1258,7 @@ func (t *T) Run(name string, f func(t *T)) bool { t = &T{ common: common{ barrier: make(chan bool), - signal: make(chan bool), + signal: make(chan bool, 1), name: testName, parent: &t.common, level: t.level + 1, @@ -1539,7 +1539,7 @@ func runTests(matchString func(pat, str string) (bool, error), tests []InternalT ctx.deadline = deadline t := &T{ common: common{ - signal: make(chan bool), + signal: make(chan bool, 1), barrier: make(chan bool), w: os.Stdout, }, @@ -1552,11 +1552,12 @@ func runTests(matchString func(pat, str string) (bool, error), tests []InternalT for _, test := range tests { t.Run(test.Name, test.F) } - // Run catching the signal rather than the tRunner as a separate - // goroutine to avoid adding a goroutine during the sequential - // phase as this pollutes the stacktrace output when aborting. - go func() { <-t.signal }() }) + select { + case <-t.signal: + default: + panic("internal error: tRunner exited without sending on t.signal") + } ok = ok && !t.Failed() ran = ran || t.ran } |