cmd/internal/obj: 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: Ica1a9985f9abb1935434367c9c8ba28fc50f331d
Reviewed-on: https://go-review.googlesource.com/c/go/+/450699
Auto-Submit: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
This commit is contained in:
Bryan C. Mills 2022-11-15 10:14:16 -05:00 committed by Gopher Robot
parent 6484e813b5
commit 5ccee1199e
6 changed files with 19 additions and 25 deletions

View file

@ -8,7 +8,6 @@ import (
"bytes"
"internal/testenv"
"os"
"os/exec"
"path/filepath"
"testing"
"unsafe"
@ -111,7 +110,7 @@ func TestSymbolTooLarge(t *testing.T) { // Issue 42054
t.Fatalf("failed to write source file: %v\n", err)
}
obj := filepath.Join(tmpdir, "p.o")
cmd := exec.Command(testenv.GoToolPath(t), "tool", "compile", "-p=p", "-o", obj, src)
cmd := testenv.Command(t, testenv.GoToolPath(t), "tool", "compile", "-p=p", "-o", obj, src)
out, err := cmd.CombinedOutput()
if err == nil {
t.Fatalf("did not fail\noutput: %s", out)
@ -137,7 +136,7 @@ func TestNoRefName(t *testing.T) {
// Build the fmt package with norefname. Not rebuilding all packages to save time.
// Also testing that norefname and non-norefname packages can link together.
cmd := exec.Command(testenv.GoToolPath(t), "build", "-gcflags=fmt=-d=norefname", "-o", exe, src)
cmd := testenv.Command(t, testenv.GoToolPath(t), "build", "-gcflags=fmt=-d=norefname", "-o", exe, src)
out, err := cmd.CombinedOutput()
if err != nil {
t.Fatalf("build failed: %v, output:\n%s", err, out)