|
2 | 2 | // Use of this source code is governed by a BSD-style
|
3 | 3 | // license that can be found in the LICENSE file.
|
4 | 4 |
|
5 |
| -package exec |
| 5 | +// Use an external test to avoid os/exec -> internal/testenv -> os/exec |
| 6 | +// circular dependency. |
| 7 | + |
| 8 | +package exec_test |
6 | 9 |
|
7 | 10 | import (
|
8 | 11 | "fmt"
|
| 12 | + "internal/testenv" |
9 | 13 | "io"
|
10 | 14 | "io/ioutil"
|
11 | 15 | "os"
|
| 16 | + "os/exec" |
12 | 17 | "path/filepath"
|
13 | 18 | "strconv"
|
14 | 19 | "strings"
|
@@ -63,7 +68,7 @@ type lookPathTest struct {
|
63 | 68 | }
|
64 | 69 |
|
65 | 70 | 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:]...) |
67 | 72 | cmd.Env = env
|
68 | 73 | cmd.Dir = test.rootDir
|
69 | 74 | args[0] = filepath.Base(args[0])
|
@@ -346,7 +351,7 @@ func (test commandTest) isSuccess(rootDir, output string, err error) error {
|
346 | 351 | }
|
347 | 352 |
|
348 | 353 | 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) |
350 | 355 | cmd.Dir = rootDir
|
351 | 356 | cmd.Env = env
|
352 | 357 | output, err := cmd.CombinedOutput()
|
@@ -532,7 +537,7 @@ func buildPrintPathExe(t *testing.T, dir string) string {
|
532 | 537 | t.Fatalf("failed to execute template: %v", err)
|
533 | 538 | }
|
534 | 539 | outname := name + ".exe"
|
535 |
| - cmd := Command("go", "build", "-o", outname, srcname) |
| 540 | + cmd := exec.Command(testenv.GoToolPath(t), "build", "-o", outname, srcname) |
536 | 541 | cmd.Dir = dir
|
537 | 542 | out, err := cmd.CombinedOutput()
|
538 | 543 | if err != nil {
|
|
0 commit comments