Also tweak the failure message added in CL 352349.
Updates #18741.
Updates #48515.
Change-Id: I46ed84c6f498d7a68414cc3dab3c1cd55da69aa9
Reviewed-on: https://go-review.googlesource.com/c/go/+/451215
Reviewed-by: Austin Clements <austin@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Changkun Ou <mail@changkun.de>
Auto-Submit: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
{
desc: "Issue 48515: call t.Run in t.Cleanup should trigger panic",
flags: []string{"-test.run=TestCallRunInCleanupHelper"},
- want: `panic: testing: t.Run is called during t.Cleanup`,
+ want: `panic: testing: t.Run called during t.Cleanup`,
},
}
return len(b), nil
}
- var wg sync.WaitGroup
root := &T{
common: common{w: &funcWriter{raceDetector}},
context: newTestContext(1, allMatcher()),
}
root.chatty = newChattyPrinter(root.w)
root.Run("", func(t *T) {
+ var wg sync.WaitGroup
for i := 0; i < 100; i++ {
wg.Add(1)
go func(i int) {
})
}(i)
}
+ wg.Wait()
})
- wg.Wait()
if races > 0 {
t.Errorf("detected %d racy Writes", races)
// must return before the outer test function for t returns.
func (t *T) Run(name string, f func(t *T)) bool {
if t.cleanupStarted.Load() {
- panic("testing: t.Run is called during t.Cleanup")
+ panic("testing: t.Run called during t.Cleanup")
}
t.hasSub.Store(true)