]> Cypherpunks repositories - gostls13.git/commitdiff
go: use testenv.Command instead of exec.Command in tests
authorBryan C. Mills <bcmills@google.com>
Tue, 15 Nov 2022 14:37:11 +0000 (09:37 -0500)
committerGopher Robot <gobot@golang.org>
Tue, 15 Nov 2022 20:17:57 +0000 (20:17 +0000)
This may help to diagnose whether the hang observed in
https://build.golang.org/log/d03db1d27515a4f7e91502e8b58bc83f6e2c04be
is related to #56180.

Updates #56180.
Updates #54773.

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

src/go/doc/comment/std_test.go
src/go/importer/importer_test.go
src/go/internal/gccgoimporter/importer_test.go
src/go/internal/gcimporter/gcimporter_test.go

index ae32dcd984aa0f6f0da5c8a5adab1689a655c211..89206e6bc85c2f716a9c3e7fe936838aa3ea4795 100644 (file)
@@ -7,14 +7,13 @@ package comment
 import (
        "internal/diff"
        "internal/testenv"
-       "os/exec"
        "sort"
        "strings"
        "testing"
 )
 
 func TestStd(t *testing.T) {
-       out, err := exec.Command(testenv.GoToolPath(t), "list", "std").CombinedOutput()
+       out, err := testenv.Command(t, testenv.GoToolPath(t), "list", "std").CombinedOutput()
        if err != nil {
                t.Fatalf("%v\n%s", err, out)
        }
index 3c391380383228599cb24ed80f5f9b44da116260..142efd30f46e67190f6b3626c4158f8dc53dee92 100644 (file)
@@ -11,7 +11,6 @@ import (
        "internal/testenv"
        "io"
        "os"
-       "os/exec"
        "strings"
        "testing"
 )
@@ -25,7 +24,7 @@ func TestForCompiler(t *testing.T) {
        testenv.MustHaveGoBuild(t)
 
        const thePackage = "math/big"
-       out, err := exec.Command(testenv.GoToolPath(t), "list", "-export", "-f={{context.Compiler}}:{{.Export}}", thePackage).CombinedOutput()
+       out, err := testenv.Command(t, testenv.GoToolPath(t), "list", "-export", "-f={{context.Compiler}}:{{.Export}}", thePackage).CombinedOutput()
        if err != nil {
                t.Fatalf("go list %s: %v\n%s", thePackage, err, out)
        }
index 55e2feb9fa6b7fcbb17ca8af34830234d4fc9b54..76b4500f3b53ffce2ef6f5968655a56a538573d1 100644 (file)
@@ -130,7 +130,7 @@ func TestObjImporter(t *testing.T) {
                t.Skip("This test needs gccgo")
        }
 
-       verout, err := exec.Command(gpath, "--version").CombinedOutput()
+       verout, err := testenv.Command(t, gpath, "--version").CombinedOutput()
        if err != nil {
                t.Logf("%s", verout)
                t.Fatal(err)
@@ -171,7 +171,7 @@ func TestObjImporter(t *testing.T) {
                ofile := filepath.Join(tmpdir, test.pkgpath+".o")
                afile := filepath.Join(artmpdir, "lib"+test.pkgpath+".a")
 
-               cmd := exec.Command(gpath, "-fgo-pkgpath="+test.pkgpath, "-c", "-o", ofile, gofile)
+               cmd := testenv.Command(t, gpath, "-fgo-pkgpath="+test.pkgpath, "-c", "-o", ofile, gofile)
                out, err := cmd.CombinedOutput()
                if err != nil {
                        t.Logf("%s", out)
@@ -180,7 +180,7 @@ func TestObjImporter(t *testing.T) {
 
                runImporterTest(t, imp, initmap, &test)
 
-               cmd = exec.Command("ar", "cr", afile, ofile)
+               cmd = testenv.Command(t, "ar", "cr", afile, ofile)
                out, err = cmd.CombinedOutput()
                if err != nil {
                        t.Logf("%s", out)
index bcbaa558d3b801cec835865ea08272d830afa9a0..af99e7a8522b265d1a24fbc1d59a55b38cd53826 100644 (file)
@@ -10,7 +10,6 @@ import (
        "internal/goexperiment"
        "internal/testenv"
        "os"
-       "os/exec"
        "path"
        "path/filepath"
        "runtime"
@@ -47,7 +46,7 @@ func compile(t *testing.T, dirname, filename, outdirname string, packagefiles ma
        importcfgfile := filepath.Join(outdirname, basename) + ".importcfg"
        testenv.WriteImportcfg(t, importcfgfile, packagefiles)
        pkgpath := path.Join("testdata", basename)
-       cmd := exec.Command(testenv.GoToolPath(t), "tool", "compile", "-p", pkgpath, "-D", "testdata", "-importcfg", importcfgfile, "-o", outname, filename)
+       cmd := testenv.Command(t, testenv.GoToolPath(t), "tool", "compile", "-p", pkgpath, "-D", "testdata", "-importcfg", importcfgfile, "-o", outname, filename)
        cmd.Dir = dirname
        out, err := cmd.CombinedOutput()
        if err != nil {