"io"
"io/fs"
"os"
- "os/exec"
"path/filepath"
"strings"
"sync"
// Load all of the packages in the module to ensure that their
// dependencies are vendored. If any imported package is missing,
// 'go list -deps' will fail when attempting to load it.
- cmd := exec.Command(goBin, "list", "-mod=vendor", "-deps", "./...")
+ cmd := testenv.Command(t, goBin, "list", "-mod=vendor", "-deps", "./...")
cmd.Env = append(os.Environ(), "GO111MODULE=on", "GOWORK=off")
cmd.Dir = m.Dir
cmd.Stderr = new(strings.Builder)
// There is no vendor directory, so the module must have no dependencies.
// Check that the list of active modules contains only the main module.
- cmd := exec.Command(goBin, "list", "-mod=readonly", "-m", "all")
+ cmd := testenv.Command(t, goBin, "list", "-mod=readonly", "-m", "all")
cmd.Env = append(os.Environ(), "GO111MODULE=on", "GOWORK=off")
cmd.Dir = m.Dir
cmd.Stderr = new(strings.Builder)
testenv.MustHaveExternalNetwork(t)
if haveDiff := func() bool {
- diff, err := exec.Command("diff", "--recursive", "--unified", ".", ".").CombinedOutput()
+ diff, err := testenv.Command(t, "diff", "--recursive", "--unified", ".", ".").CombinedOutput()
if err != nil || len(diff) != 0 {
return false
}
- diff, err = exec.Command("diff", "--recursive", "--unified", ".", "..").CombinedOutput()
+ diff, err = testenv.Command(t, "diff", "--recursive", "--unified", ".", "..").CombinedOutput()
if err == nil || len(diff) == 0 {
return false
}
// GO_TEST_SHORT=0 causes it to run this portion of the test.)
var modcacheEnv []string
{
- out, err := exec.Command(goBin, "env", "GOMODCACHE").Output()
+ out, err := testenv.Command(t, goBin, "env", "GOMODCACHE").Output()
if err != nil {
t.Fatalf("%s env GOMODCACHE: %v", goBin, err)
}
}
// TODO(golang.org/issue/43440): Check anything else influenced by dependency versions.
- diff, err := exec.Command("diff", "--recursive", "--unified", r.Dir, m.Dir).CombinedOutput()
+ diff, err := testenv.Command(t, "diff", "--recursive", "--unified", r.Dir, m.Dir).CombinedOutput()
if err != nil || len(diff) != 0 {
t.Errorf(`Module %s in %s is not tidy (-want +got):
// run runs the command and requires that it succeeds.
func (r runner) run(t *testing.T, args ...string) {
t.Helper()
- cmd := exec.Command(args[0], args[1:]...)
+ cmd := testenv.Command(t, args[0], args[1:]...)
cmd.Dir = r.Dir
cmd.Env = r.Env
out, err := cmd.CombinedOutput()
// Use 'go list' to describe the module contained in this directory (but
// not its dependencies).
- cmd := exec.Command(goBin, "list", "-json", "-m")
+ cmd := testenv.Command(t, goBin, "list", "-json", "-m")
cmd.Env = append(os.Environ(), "GO111MODULE=on", "GOWORK=off")
cmd.Dir = dir
cmd.Stderr = new(strings.Builder)