]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/internal/archive: use testenv.Command instead of exec.Command in tests
authorBryan C. Mills <bcmills@google.com>
Tue, 15 Nov 2022 15:14:28 +0000 (10:14 -0500)
committerGopher Robot <gobot@golang.org>
Tue, 15 Nov 2022 20:21:32 +0000 (20:21 +0000)
testenv.Command sets a default timeout based on the test's deadline
and sends SIGQUIT (where supported) in case of a hang.

Change-Id: I6f8391da50e74919ccc59cd43ccae99affab8798
Reviewed-on: https://go-review.googlesource.com/c/go/+/450700
Auto-Submit: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

src/cmd/internal/archive/archive_test.go

index f5315856c15f22c74552515d7bdebf9b2f3873f8..0e2c7bca75e0eecd013929dc8a7455a49ab09129 100644 (file)
@@ -14,7 +14,6 @@ import (
        "internal/xcoff"
        "io"
        "os"
-       "os/exec"
        "path/filepath"
        "runtime"
        "sync"
@@ -116,15 +115,15 @@ func buildGoobj(t *testing.T) goobjPaths {
                        importcfgfile := filepath.Join(buildDir, "importcfg")
                        testenv.WriteImportcfg(t, importcfgfile, nil)
 
-                       out, err := exec.Command(gotool, "tool", "compile", "-importcfg="+importcfgfile, "-p=p", "-o", go1obj, go1src).CombinedOutput()
+                       out, err := testenv.Command(t, gotool, "tool", "compile", "-importcfg="+importcfgfile, "-p=p", "-o", go1obj, go1src).CombinedOutput()
                        if err != nil {
                                return fmt.Errorf("go tool compile -o %s %s: %v\n%s", go1obj, go1src, err, out)
                        }
-                       out, err = exec.Command(gotool, "tool", "compile", "-importcfg="+importcfgfile, "-p=p", "-o", go2obj, go2src).CombinedOutput()
+                       out, err = testenv.Command(t, gotool, "tool", "compile", "-importcfg="+importcfgfile, "-p=p", "-o", go2obj, go2src).CombinedOutput()
                        if err != nil {
                                return fmt.Errorf("go tool compile -o %s %s: %v\n%s", go2obj, go2src, err, out)
                        }
-                       out, err = exec.Command(gotool, "tool", "pack", "c", goarchive, go1obj, go2obj).CombinedOutput()
+                       out, err = testenv.Command(t, gotool, "tool", "pack", "c", goarchive, go1obj, go2obj).CombinedOutput()
                        if err != nil {
                                return fmt.Errorf("go tool pack c %s %s %s: %v\n%s", goarchive, go1obj, go2obj, err, out)
                        }
@@ -139,7 +138,7 @@ func buildGoobj(t *testing.T) goobjPaths {
                                if err != nil {
                                        return err
                                }
-                               cmd := exec.Command(gotool, "build", "-buildmode=archive", "-o", cgoarchive, "-gcflags=all="+os.Getenv("GO_GCFLAGS"), "mycgo")
+                               cmd := testenv.Command(t, gotool, "build", "-buildmode=archive", "-o", cgoarchive, "-gcflags=all="+os.Getenv("GO_GCFLAGS"), "mycgo")
                                cmd.Dir = filepath.Join(gopath, "src", "mycgo")
                                cmd.Env = append(os.Environ(), "GOPATH="+gopath)
                                out, err = cmd.CombinedOutput()