Commit c203696a authored by Daniel Martí's avatar Daniel Martí

go/importer,os/exec: use testenv.GoToolPath

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: default avatarIan Lance Taylor <iant@golang.org>
parent c5d744a4
...@@ -17,7 +17,7 @@ func TestFor(t *testing.T) { ...@@ -17,7 +17,7 @@ func TestFor(t *testing.T) {
testenv.MustHaveGoBuild(t) testenv.MustHaveGoBuild(t)
const thePackage = "math/big" 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 { if err != nil {
t.Fatalf("go list %s: %v\n%s", thePackage, err, out) t.Fatalf("go list %s: %v\n%s", thePackage, err, out)
} }
......
...@@ -2,13 +2,18 @@ ...@@ -2,13 +2,18 @@
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // 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 ( import (
"fmt" "fmt"
"internal/testenv"
"io" "io"
"io/ioutil" "io/ioutil"
"os" "os"
"os/exec"
"path/filepath" "path/filepath"
"strconv" "strconv"
"strings" "strings"
...@@ -63,7 +68,7 @@ type lookPathTest struct { ...@@ -63,7 +68,7 @@ type lookPathTest struct {
} }
func (test lookPathTest) runProg(t *testing.T, env []string, args ...string) (string, error) { 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.Env = env
cmd.Dir = test.rootDir cmd.Dir = test.rootDir
args[0] = filepath.Base(args[0]) args[0] = filepath.Base(args[0])
...@@ -346,7 +351,7 @@ func (test commandTest) isSuccess(rootDir, output string, err error) error { ...@@ -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 { 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.Dir = rootDir
cmd.Env = env cmd.Env = env
output, err := cmd.CombinedOutput() output, err := cmd.CombinedOutput()
...@@ -532,7 +537,7 @@ func buildPrintPathExe(t *testing.T, dir string) string { ...@@ -532,7 +537,7 @@ func buildPrintPathExe(t *testing.T, dir string) string {
t.Fatalf("failed to execute template: %v", err) t.Fatalf("failed to execute template: %v", err)
} }
outname := name + ".exe" outname := name + ".exe"
cmd := Command("go", "build", "-o", outname, srcname) cmd := exec.Command(testenv.GoToolPath(t), "build", "-o", outname, srcname)
cmd.Dir = dir cmd.Dir = dir
out, err := cmd.CombinedOutput() out, err := cmd.CombinedOutput()
if err != nil { if err != nil {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment