]> Cypherpunks repositories - gostls13.git/commitdiff
go/importer,os/exec: use testenv.GoToolPath
authorDaniel Martí <mvdan@mvdan.cc>
Wed, 10 Jan 2018 17:01:31 +0000 (17:01 +0000)
committerDaniel Martí <mvdan@mvdan.cc>
Wed, 10 Jan 2018 20:24:15 +0000 (20:24 +0000)
These were the last two occurences of exec.Command("go", ...) in all of
std cmd. Checked with:

gogrep '$(f is(func))("go", $*_)' std cmd

Also changed lp_windows_test to use a test package name to avoid a
circular dependency, since internal/testenv imports os/exec.

Change-Id: I9a18948600dfecc8507ad76172e219e78b791ffd
Reviewed-on: https://go-review.googlesource.com/87200
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/go/importer/importer_test.go
src/os/exec/lp_windows_test.go

index 8fa90ef09771bd977fa893e6b94864716f6a6f80..56e83136fb1a0b09b4c6af27d69eeccf598d9252 100644 (file)
@@ -17,7 +17,7 @@ func TestFor(t *testing.T) {
        testenv.MustHaveGoBuild(t)
 
        const thePackage = "math/big"
-       out, err := exec.Command("go", "list", "-f={{context.Compiler}}:{{.Target}}", thePackage).CombinedOutput()
+       out, err := exec.Command(testenv.GoToolPath(t), "list", "-f={{context.Compiler}}:{{.Target}}", thePackage).CombinedOutput()
        if err != nil {
                t.Fatalf("go list %s: %v\n%s", thePackage, err, out)
        }
index 96a22d843f8544775555584895848f5f11f7596f..d1c904617477621cf04bf546aea262b68d9c3135 100644 (file)
@@ -2,13 +2,18 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-package exec
+// Use an external test to avoid os/exec -> internal/testenv -> os/exec
+// circular dependency.
+
+package exec_test
 
 import (
        "fmt"
+       "internal/testenv"
        "io"
        "io/ioutil"
        "os"
+       "os/exec"
        "path/filepath"
        "strconv"
        "strings"
@@ -63,7 +68,7 @@ type lookPathTest struct {
 }
 
 func (test lookPathTest) runProg(t *testing.T, env []string, args ...string) (string, error) {
-       cmd := Command(args[0], args[1:]...)
+       cmd := exec.Command(args[0], args[1:]...)
        cmd.Env = env
        cmd.Dir = test.rootDir
        args[0] = filepath.Base(args[0])
@@ -346,7 +351,7 @@ func (test commandTest) isSuccess(rootDir, output string, err error) error {
 }
 
 func (test commandTest) runOne(rootDir string, env []string, dir, arg0 string) error {
-       cmd := Command(os.Args[0], "-test.run=TestHelperProcess", "--", "exec", dir, arg0)
+       cmd := exec.Command(os.Args[0], "-test.run=TestHelperProcess", "--", "exec", dir, arg0)
        cmd.Dir = rootDir
        cmd.Env = env
        output, err := cmd.CombinedOutput()
@@ -532,7 +537,7 @@ func buildPrintPathExe(t *testing.T, dir string) string {
                t.Fatalf("failed to execute template: %v", err)
        }
        outname := name + ".exe"
-       cmd := Command("go", "build", "-o", outname, srcname)
+       cmd := exec.Command(testenv.GoToolPath(t), "build", "-o", outname, srcname)
        cmd.Dir = dir
        out, err := cmd.CombinedOutput()
        if err != nil {