diff --git a/src/sync/waitgroup_test.go b/src/sync/waitgroup_test.go index a581660940..8ec34fd343 100644 --- a/src/sync/waitgroup_test.go +++ b/src/sync/waitgroup_test.go @@ -128,13 +128,16 @@ func TestWaitGroupMisuse3(t *testing.T) { } }() defer runtime.GOMAXPROCS(runtime.GOMAXPROCS(4)) - done := make(chan interface{}, 1) + done := make(chan interface{}, 2) // The detection is opportunistically, so we want it to panic // at least in one run out of a million. for i := 0; i < 1e6; i++ { var wg WaitGroup wg.Add(1) go func() { + defer func() { + done <- recover() + }() wg.Done() }() go func() { @@ -150,8 +153,10 @@ func TestWaitGroupMisuse3(t *testing.T) { wg.Wait() }() wg.Wait() - if err := <-done; err != nil { - panic(err) + for j := 0; j < 2; j++ { + if err := <-done; err != nil { + panic(err) + } } } t.Fatal("Should panic")