mirror of
https://github.com/sourcegraph/sourcegraph.git
synced 2026-02-06 19:51:50 +00:00
lib/group: fix race condition in test (#39340)
This commit is contained in:
parent
6e25baf2f7
commit
124dc271a0
@ -98,6 +98,14 @@ func TestResultErrorGroup(t *testing.T) {
|
||||
synchronizer := make(chan struct{})
|
||||
g.Go(func() (int, error) {
|
||||
<-synchronizer
|
||||
// This test has an intrinsic race condition that can be reproduced
|
||||
// by adding a `defer time.Sleep(time.Second)` before the `defer
|
||||
// close(synchronizer)`. We cannot guarantee that the group processes
|
||||
// the return value of the second goroutine before the first goroutine
|
||||
// exits in response to synchronizer, so we add a sleep here to make
|
||||
// this race condition vanishingly unlikely. Note that this is a race
|
||||
// in the test, not in the library.
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
return 0, err1
|
||||
})
|
||||
g.Go(func() (int, error) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user