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