Skip to content

Commit 6cdf0b2

Browse files
committed
test(cli/clitest): Fix panic in Wait
1 parent e2a7448 commit 6cdf0b2

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

cli/clitest/clitest.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,11 +231,17 @@ func StartWithWaiter(t *testing.T, inv *clibase.Invocation) *ErrorWaiter {
231231
errCh <- err
232232
}()
233233

234+
ew := &ErrorWaiter{c: errCh, t: t}
235+
234236
// Don't exit test routine until server is done.
235237
t.Cleanup(func() {
236238
cancel()
237239
cleaningUp.Store(true)
240+
// We must allow Wait to deplete errCh because if we deplete it
241+
// here Wait will panic.
242+
_ = ew.Wait()
243+
// Safe to wait for errCh close after depletion.
238244
<-errCh
239245
})
240-
return &ErrorWaiter{c: errCh, t: t}
246+
return ew
241247
}

0 commit comments

Comments
 (0)