Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5045bac92f |
@@ -94,7 +94,9 @@ func interruptOnFirstRequest(t *testing.T, requestArrived <-chan struct{}) {
|
||||
testEnded := make(chan struct{})
|
||||
senderDone := make(chan struct{})
|
||||
|
||||
// The sender must have stopped before the test stops catching SIGINT.
|
||||
// Stop catching SIGINT only after the sender has returned. The sender
|
||||
// waits for each SIGINT it sends to arrive on caught; one still on
|
||||
// its way after signal.Stop would kill the test binary.
|
||||
t.Cleanup(func() {
|
||||
close(testEnded)
|
||||
<-senderDone
|
||||
@@ -114,6 +116,13 @@ func interruptOnFirstRequest(t *testing.T, requestArrived <-chan struct{}) {
|
||||
defer ticker.Stop()
|
||||
|
||||
for {
|
||||
// Empty caught, so that the receive below waits for this
|
||||
// SIGINT rather than an earlier one.
|
||||
select {
|
||||
case <-caught:
|
||||
default:
|
||||
}
|
||||
|
||||
sendErr := self.Signal(os.Interrupt)
|
||||
if sendErr != nil {
|
||||
t.Errorf("sending SIGINT: %v", sendErr)
|
||||
@@ -121,6 +130,8 @@ func interruptOnFirstRequest(t *testing.T, requestArrived <-chan struct{}) {
|
||||
return
|
||||
}
|
||||
|
||||
<-caught
|
||||
|
||||
select {
|
||||
case <-testEnded:
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user