mirror of https://github.com/golang/go.git
os: use testenv.Command instead of exec.Command in tests
testenv.Command sets a default timeout based on the test's deadline and sends SIGQUIT (where supported) in case of a hang. Change-Id: I32ea9ca11c30d8af3d5490f2db1674314962cc80 Reviewed-on: https://go-review.googlesource.com/c/go/+/451195 Reviewed-by: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Joedian Reid <joedian@golang.org> Auto-Submit: Bryan Mills <bcmills@google.com> Run-TryBot: Bryan Mills <bcmills@google.com>
This commit is contained in:
parent
86713ea311
commit
f3ae7ac9d9
|
|
@ -106,13 +106,13 @@ func TestExecutableDeleted(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
|
||||
out, err := osexec.Command(testenv.GoToolPath(t), "build", "-o", exe, src).CombinedOutput()
|
||||
out, err := testenv.Command(t, testenv.GoToolPath(t), "build", "-o", exe, src).CombinedOutput()
|
||||
t.Logf("build output:\n%s", out)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
out, err = osexec.Command(exe).CombinedOutput()
|
||||
out, err = testenv.Command(t, exe).CombinedOutput()
|
||||
t.Logf("exec output:\n%s", out)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
|
|
|
|||
|
|
@ -1735,7 +1735,7 @@ func runBinHostname(t *testing.T) string {
|
|||
}
|
||||
|
||||
func testWindowsHostname(t *testing.T, hostname string) {
|
||||
cmd := osexec.Command("hostname")
|
||||
cmd := testenv.Command(t, "hostname")
|
||||
out, err := cmd.Output()
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to execute hostname command: %v %s", err, out)
|
||||
|
|
@ -2130,9 +2130,9 @@ func TestStatStdin(t *testing.T) {
|
|||
|
||||
var cmd *osexec.Cmd
|
||||
if runtime.GOOS == "windows" {
|
||||
cmd = osexec.Command("cmd", "/c", "echo output | "+Args[0]+" -test.run=TestStatStdin")
|
||||
cmd = testenv.Command(t, "cmd", "/c", "echo output | "+Args[0]+" -test.run=TestStatStdin")
|
||||
} else {
|
||||
cmd = osexec.Command("/bin/sh", "-c", "echo output | "+Args[0]+" -test.run=TestStatStdin")
|
||||
cmd = testenv.Command(t, "/bin/sh", "-c", "echo output | "+Args[0]+" -test.run=TestStatStdin")
|
||||
}
|
||||
cmd.Env = append(Environ(), "GO_WANT_HELPER_PROCESS=1")
|
||||
|
||||
|
|
@ -2287,7 +2287,7 @@ func testKillProcess(t *testing.T, processKiller func(p *Process)) {
|
|||
t.Parallel()
|
||||
|
||||
// Re-exec the test binary to start a process that hangs until stdin is closed.
|
||||
cmd := osexec.Command(Args[0])
|
||||
cmd := testenv.Command(t, Args[0])
|
||||
cmd.Env = append(os.Environ(), "GO_OS_TEST_DRAIN_STDIN=1")
|
||||
stdout, err := cmd.StdoutPipe()
|
||||
if err != nil {
|
||||
|
|
@ -2338,7 +2338,7 @@ func TestGetppid(t *testing.T) {
|
|||
Exit(0)
|
||||
}
|
||||
|
||||
cmd := osexec.Command(Args[0], "-test.run=TestGetppid")
|
||||
cmd := testenv.Command(t, Args[0], "-test.run=TestGetppid")
|
||||
cmd.Env = append(Environ(), "GO_WANT_HELPER_PROCESS=1")
|
||||
|
||||
// verify that Getppid() from the forked process reports our process id
|
||||
|
|
|
|||
Loading…
Reference in New Issue