1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Merge pull request #40496 from thaJeztah/locally_scope_variable

TestCatchAll, TestStopCatch: remove unneeded goroutine
This commit is contained in:
Akihiro Suda 2020-04-07 09:54:25 +09:00 committed by GitHub
commit ff9fa7b43a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -6,7 +6,6 @@ import (
"os" "os"
"syscall" "syscall"
"testing" "testing"
"time"
"gotest.tools/v3/assert" "gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp" is "gotest.tools/v3/assert/cmp"
@ -27,17 +26,11 @@ func TestCatchAll(t *testing.T) {
} }
for sigStr := range listOfSignals { for sigStr := range listOfSignals {
signal, ok := SignalMap[sigStr] if signal, ok := SignalMap[sigStr]; ok {
if ok { syscall.Kill(syscall.Getpid(), signal)
go func() {
time.Sleep(1 * time.Millisecond)
syscall.Kill(syscall.Getpid(), signal)
}()
s := <-sigs s := <-sigs
assert.Check(t, is.Equal(s.String(), signal.String())) assert.Check(t, is.Equal(s.String(), signal.String()))
} }
} }
} }
@ -45,11 +38,7 @@ func TestStopCatch(t *testing.T) {
signal := SignalMap["HUP"] signal := SignalMap["HUP"]
channel := make(chan os.Signal, 1) channel := make(chan os.Signal, 1)
CatchAll(channel) CatchAll(channel)
go func() { syscall.Kill(syscall.Getpid(), signal)
time.Sleep(1 * time.Millisecond)
syscall.Kill(syscall.Getpid(), signal)
}()
signalString := <-channel signalString := <-channel
assert.Check(t, is.Equal(signalString.String(), signal.String())) assert.Check(t, is.Equal(signalString.String(), signal.String()))