Skip to content

Commit 54ffa75

Browse files
committed
Ensure test exits cleanly before being killed.
1 parent 07f61d0 commit 54ffa75

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/runtime/signal_windows_test.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ package runtime_test
55
import (
66
"bufio"
77
"bytes"
8+
"context"
89
"fmt"
910
"internal/testenv"
1011
"io/ioutil"
@@ -114,8 +115,11 @@ func TestCtrlHandler(t *testing.T) {
114115
defer conn.Close()
115116
conn.SetDeadline(time.Now().Add(5 * time.Second))
116117

118+
ctx, cancel := context.WithTimeout(context.TODO(), 5*time.Second)
119+
defer cancel()
120+
117121
// run test program
118-
cmd = exec.Command("cmd.exe", "/c", "start", exe, conn.LocalAddr().String())
122+
cmd = exec.CommandContext(ctx, "cmd.exe", "/c", "start", exe, conn.LocalAddr().String())
119123
if err := cmd.Start(); err != nil {
120124
t.Fatalf("Start failed: %v", err)
121125
}

0 commit comments

Comments
 (0)