From 5dda49037209290519f4881a0080caaef025bbd7 Mon Sep 17 00:00:00 2001 From: "Bryan C. Mills" Date: Tue, 22 Aug 2023 11:01:29 -0400 Subject: net/http: use testenv.Command instead of exec.Command in tests On Unix platforms, testenv.Command sends SIGQUIT to stuck commands before the test times out. For subprocesses that are written in Go, that causes the runtime to dump running goroutines, and in other languages it triggers similar behavior (such as a core dump). If the subprocess is stuck due to a bug (such as #57999), that may help to diagnose it. For #57999. Change-Id: Ia2e9d14718a26001e030e162c69892497a8ebb21 Reviewed-on: https://go-review.googlesource.com/c/go/+/521816 Reviewed-by: Damien Neil Run-TryBot: Bryan Mills TryBot-Result: Gopher Robot Auto-Submit: Bryan Mills --- src/net/http/cgi/host_test.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/net/http/cgi') diff --git a/src/net/http/cgi/host_test.go b/src/net/http/cgi/host_test.go index 860e9b3e8f..707af71dd7 100644 --- a/src/net/http/cgi/host_test.go +++ b/src/net/http/cgi/host_test.go @@ -9,6 +9,7 @@ package cgi import ( "bufio" "fmt" + "internal/testenv" "io" "net" "net/http" @@ -93,7 +94,7 @@ var cgiTested, cgiWorks bool func check(t *testing.T) { if !cgiTested { cgiTested = true - cgiWorks = exec.Command("./testdata/test.cgi").Run() == nil + cgiWorks = testenv.Command(t, "./testdata/test.cgi").Run() == nil } if !cgiWorks { // No Perl on Windows, needed by test.cgi @@ -462,7 +463,7 @@ func findPerl(t *testing.T) string { } perl, _ = filepath.Abs(perl) - cmd := exec.Command(perl, "-e", "print 123") + cmd := testenv.Command(t, perl, "-e", "print 123") cmd.Env = []string{"PATH=/garbage"} out, err := cmd.Output() if err != nil || string(out) != "123" { -- cgit v1.3-5-g9baa