diff --git a/src/os/signal/signal_test.go b/src/os/signal/signal_test.go index 3182e83b4e..086ecdbcd5 100644 --- a/src/os/signal/signal_test.go +++ b/src/os/signal/signal_test.go @@ -713,7 +713,7 @@ func TestNotifyContextNotifications(t *testing.T) { } wg.Wait() <-ctx.Done() - fmt.Print("received SIGINT") + fmt.Println("received SIGINT") // Sleep to give time to simultaneous signals to reach the process. // These signals must be ignored given stop() is not called on this code. // We want to guarantee a SIGINT doesn't cause a premature termination of the program. @@ -730,11 +730,17 @@ func TestNotifyContextNotifications(t *testing.T) { {"multiple", 10}, } for _, tc := range testCases { + tc := tc t.Run(tc.name, func(t *testing.T) { + t.Parallel() + var subTimeout time.Duration if deadline, ok := t.Deadline(); ok { - subTimeout := time.Until(deadline) - subTimeout -= subTimeout / 10 // Leave 10% headroom for cleaning up subprocess. + timeout := time.Until(deadline) + if timeout < 2*settleTime { + t.Fatalf("starting test with less than %v remaining", 2*settleTime) + } + subTimeout = timeout - (timeout / 10) // Leave 10% headroom for cleaning up subprocess. } args := []string{ @@ -750,7 +756,7 @@ func TestNotifyContextNotifications(t *testing.T) { if err != nil { t.Errorf("ran test with -check_notify_ctx_notification and it failed with %v.\nOutput:\n%s", err, out) } - if want := []byte("received SIGINT"); !bytes.Contains(out, want) { + if want := []byte("received SIGINT\n"); !bytes.Contains(out, want) { t.Errorf("got %q, wanted %q", out, want) } })