Skip to content

Commit c203696

Browse files
committed
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í <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]>
1 parent c5d744a commit c203696

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

src/go/importer/importer_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ func TestFor(t *testing.T) {
1717
testenv.MustHaveGoBuild(t)
1818

1919
const thePackage = "math/big"
20-
out, err := exec.Command("go", "list", "-f={{context.Compiler}}:{{.Target}}", thePackage).CombinedOutput()
20+
out, err := exec.Command(testenv.GoToolPath(t), "list", "-f={{context.Compiler}}:{{.Target}}", thePackage).CombinedOutput()
2121
if err != nil {
2222
t.Fatalf("go list %s: %v\n%s", thePackage, err, out)
2323
}

src/os/exec/lp_windows_test.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,18 @@
22
// Use of this source code is governed by a BSD-style
33
// license that can be found in the LICENSE file.
44

5-
package exec
5+
// Use an external test to avoid os/exec -> internal/testenv -> os/exec
6+
// circular dependency.
7+
8+
package exec_test
69

710
import (
811
"fmt"
12+
"internal/testenv"
913
"io"
1014
"io/ioutil"
1115
"os"
16+
"os/exec"
1217
"path/filepath"
1318
"strconv"
1419
"strings"
@@ -63,7 +68,7 @@ type lookPathTest struct {
6368
}
6469

6570
func (test lookPathTest) runProg(t *testing.T, env []string, args ...string) (string, error) {
66-
cmd := Command(args[0], args[1:]...)
71+
cmd := exec.Command(args[0], args[1:]...)
6772
cmd.Env = env
6873
cmd.Dir = test.rootDir
6974
args[0] = filepath.Base(args[0])
@@ -346,7 +351,7 @@ func (test commandTest) isSuccess(rootDir, output string, err error) error {
346351
}
347352

348353
func (test commandTest) runOne(rootDir string, env []string, dir, arg0 string) error {
349-
cmd := Command(os.Args[0], "-test.run=TestHelperProcess", "--", "exec", dir, arg0)
354+
cmd := exec.Command(os.Args[0], "-test.run=TestHelperProcess", "--", "exec", dir, arg0)
350355
cmd.Dir = rootDir
351356
cmd.Env = env
352357
output, err := cmd.CombinedOutput()
@@ -532,7 +537,7 @@ func buildPrintPathExe(t *testing.T, dir string) string {
532537
t.Fatalf("failed to execute template: %v", err)
533538
}
534539
outname := name + ".exe"
535-
cmd := Command("go", "build", "-o", outname, srcname)
540+
cmd := exec.Command(testenv.GoToolPath(t), "build", "-o", outname, srcname)
536541
cmd.Dir = dir
537542
out, err := cmd.CombinedOutput()
538543
if err != nil {

0 commit comments

Comments
 (0)