}
func run(t *testing.T, dir string, lto bool, args ...string) {
+ testenv.MustHaveGoRun(t)
runArgs := append([]string{"run", "."}, args...)
- cmd := exec.Command("go", runArgs...)
+ cmd := exec.Command(testenv.GoToolPath(t), runArgs...)
cmd.Dir = dir
if lto {
// On the builders we're using the default /usr/bin/ld, but
func mustHaveCxx(t *testing.T) {
// Ask the go tool for the CXX it's configured to use.
- cxx, err := exec.Command("go", "env", "CXX").CombinedOutput()
+ cxx, err := exec.Command(testenv.GoToolPath(t), "env", "CXX").CombinedOutput()
if err != nil {
t.Fatalf("go env CXX failed: %s", err)
}
t.Fatal(err)
}
- cmd := exec.Command("go", "tool", "cgo",
+ cmd := exec.Command(testenv.GoToolPath(t), "tool", "cgo",
"-objdir", objDir,
"-exportheader", header)
cmd.Args = append(cmd.Args, files...)
}()
}
- cmd := exec.Command("go", "build", "-buildmode=c-archive", "-o", "libgo2.a", "./libgo2")
+ cmd := exec.Command(testenv.GoToolPath(t), "build", "-buildmode=c-archive", "-o", "libgo2.a", "./libgo2")
if out, err := cmd.CombinedOutput(); err != nil {
t.Logf("%s", out)
t.Fatal(err)
}
t.Log("go build -buildmode=c-archive -o libgo2.a ./libgo2")
- cmd := exec.Command("go", "build", "-buildmode=c-archive", "-o", "libgo2.a", "./libgo2")
+ cmd := exec.Command(testenv.GoToolPath(t), "build", "-buildmode=c-archive", "-o", "libgo2.a", "./libgo2")
out, err := cmd.CombinedOutput()
if len(out) > 0 {
t.Logf("%s", out)
}()
}
- cmd := exec.Command("go", "build", "-buildmode=c-archive", "-o", "libgo3.a", "./libgo3")
+ cmd := exec.Command(testenv.GoToolPath(t), "build", "-buildmode=c-archive", "-o", "libgo3.a", "./libgo3")
if out, err := cmd.CombinedOutput(); err != nil {
t.Logf("%s", out)
t.Fatal(err)
}()
}
- cmd := exec.Command("go", "build", "-buildmode=c-archive", "-o", "libgo4.a", "./libgo4")
+ cmd := exec.Command(testenv.GoToolPath(t), "build", "-buildmode=c-archive", "-o", "libgo4.a", "./libgo4")
if out, err := cmd.CombinedOutput(); err != nil {
t.Logf("%s", out)
t.Fatal(err)
t.Fatal(err)
}
- cmd := exec.Command("go", "build", "-buildmode=c-archive", "-ldflags=-extar="+filepath.Join(dir, "testar"), "-o", "libgo4.a", "./libgo4")
+ cmd := exec.Command(testenv.GoToolPath(t), "build", "-buildmode=c-archive", "-ldflags=-extar="+filepath.Join(dir, "testar"), "-o", "libgo4.a", "./libgo4")
if out, err := cmd.CombinedOutput(); err != nil {
t.Logf("%s", out)
t.Fatal(err)
// be running this test in a GOROOT owned by root.)
genHeader(t, "p.h", "./p")
- cmd := exec.Command("go", "build", "-buildmode=c-archive", "./libgo")
+ cmd := exec.Command(testenv.GoToolPath(t), "build", "-buildmode=c-archive", "./libgo")
if out, err := cmd.CombinedOutput(); err != nil {
t.Logf("%s", out)
t.Fatal(err)
}()
}
- cmd := exec.Command("go", "build", "-buildmode=c-archive", "-o", "libgo6.a", "./libgo6")
+ cmd := exec.Command(testenv.GoToolPath(t), "build", "-buildmode=c-archive", "-o", "libgo6.a", "./libgo6")
out, err := cmd.CombinedOutput()
t.Logf("%v\n%s", cmd.Args, out)
if err != nil {
}()
}
- cmd := exec.Command("go", "build", "-buildmode=c-archive", "-gcflags=-shared=false", "-o", "libgo2.a", "./libgo2")
+ cmd := exec.Command(testenv.GoToolPath(t), "build", "-buildmode=c-archive", "-gcflags=-shared=false", "-o", "libgo2.a", "./libgo2")
out, err := cmd.CombinedOutput()
t.Logf("%v\n%s", cmd.Args, out)
if err != nil {
}()
}
- cmd := exec.Command("go", "build", "-buildmode=c-archive", "-o", "libgo7.a", "./libgo7")
+ cmd := exec.Command(testenv.GoToolPath(t), "build", "-buildmode=c-archive", "-o", "libgo7.a", "./libgo7")
out, err := cmd.CombinedOutput()
t.Logf("%v\n%s", cmd.Args, out)
if err != nil {
}()
}
- cmd := exec.Command("go", "build", "-buildmode=c-archive", "-o", "libgo8.a", "./libgo8")
+ cmd := exec.Command(testenv.GoToolPath(t), "build", "-buildmode=c-archive", "-o", "libgo8.a", "./libgo8")
out, err := cmd.CombinedOutput()
t.Logf("%v\n%s", cmd.Args, out)
if err != nil {
}()
}
- cmd := exec.Command("go", "build", "-buildmode=c-archive", "-o", "libgo9.a", "./libgo9")
+ cmd := exec.Command(testenv.GoToolPath(t), "build", "-buildmode=c-archive", "-o", "libgo9.a", "./libgo9")
out, err := cmd.CombinedOutput()
t.Logf("%v\n%s", cmd.Args, out)
if err != nil {
}()
}
- cmd := exec.Command("go", "build", "-buildmode=c-archive", "-o", "libgo10.a", "./libgo10")
+ cmd := exec.Command(testenv.GoToolPath(b), "build", "-buildmode=c-archive", "-o", "libgo10.a", "./libgo10")
out, err := cmd.CombinedOutput()
b.Logf("%v\n%s", cmd.Args, out)
if err != nil {
}()
}
- cmd := exec.Command("go", "build", "-buildmode=c-archive", "-o", "libgo_s.a", "./libgo")
+ cmd := exec.Command(testenv.GoToolPath(t), "build", "-buildmode=c-archive", "-o", "libgo_s.a", "./libgo")
out, err := cmd.CombinedOutput()
t.Logf("%v\n%s", cmd.Args, out)
if err != nil {
argv = append(argv, "-ldflags", "-extldflags=-Wl,--export-all-symbols")
}
argv = append(argv, "-o", objfile, srcfile)
- out, err := exec.Command("go", argv...).CombinedOutput()
+ out, err := exec.Command(testenv.GoToolPath(t), argv...).CombinedOutput()
if err != nil {
t.Fatalf("build failure: %s\n%s\n", err, string(out))
}
t.Fatal(err)
}
- cmd := exec.Command("go", "tool", "cgo",
+ cmd := exec.Command(testenv.GoToolPath(t), "tool", "cgo",
"-srcdir", testdata,
"-objdir", dir,
"issue42580.go")
makeFile(godir, "go.mod", "module badsym")
// Try to build our little package.
- cmd := exec.Command("go", "build", "-ldflags=-v")
+ cmd := exec.Command(testenv.GoToolPath(t), "build", "-ldflags=-v")
cmd.Dir = godir
output, err := cmd.CombinedOutput()
for _, file := range files {
args = append(args, path(file))
}
- cmd := exec.Command("go", args...)
+ cmd := exec.Command(testenv.GoToolPath(t), args...)
out, err := cmd.CombinedOutput()
if err == nil {
t.Errorf("expected cgo to fail but it succeeded")
func sizeofLongDouble(t *testing.T) int {
testenv.MustHaveGoRun(t)
testenv.MustHaveCGO(t)
- cmd := exec.Command("go", "run", path("long_double_size.go"))
+ cmd := exec.Command(testenv.GoToolPath(t), "run", path("long_double_size.go"))
out, err := cmd.CombinedOutput()
if err != nil {
t.Fatalf("%#q: %v:\n%s", strings.Join(cmd.Args, " "), err, out)
testenv.MustHaveCGO(t)
t.Parallel()
- cmd := exec.Command("go", "build", path("issue14669.go"))
+ cmd := exec.Command(testenv.GoToolPath(t), "build", path("issue14669.go"))
cmd.Env = append(os.Environ(), "CGO_CFLAGS="+cflags)
out, err := cmd.CombinedOutput()
if err != nil {
testenv.MustHaveGoRun(t)
t.Parallel()
- cmd := exec.Command("go", "run", path("malloc.go"))
+ cmd := exec.Command(testenv.GoToolPath(t), "run", path("malloc.go"))
out, err := cmd.CombinedOutput()
if err == nil {
t.Logf("%#q:\n%s", strings.Join(cmd.Args, " "), out)
if cgocheck2 {
exeName = "ptrtest2.exe"
}
- cmd := exec.Command("go", "build", "-o", exeName)
+ cmd := exec.Command(testenv.GoToolPath(t), "build", "-o", exeName)
cmd.Dir = src
cmd.Env = append(os.Environ(), "GOPATH="+gopath)
// Finally, run the actual test.
t.Log("go", "run", "./testdata/testprog")
var stdout, stderr strings.Builder
- cmd := exec.Command("go", "run", "./testdata/testprog")
+ cmd := exec.Command(testenv.GoToolPath(t), "run", "./testdata/testprog")
cmd.Stdout = &stdout
cmd.Stderr = &stderr
err := cmd.Run()
}
for _, fp := range filePrefixes {
- cmd := exec.Command("go", "tool", "cgo",
+ cmd := exec.Command(testenv.GoToolPath(t), "tool", "cgo",
"-godefs",
"-srcdir", testdata,
"-objdir", dir,
// instead of invoking 'go build' and the resulting binary separately, so that
// this test can pass on mobile builders, which do not copy artifacts back
// from remote invocations.
- cmd := exec.Command("go", "run", ".")
+ cmd := exec.Command(testenv.GoToolPath(t), "run", ".")
cmd.Env = append(os.Environ(), "GOPATH="+gopath)
cmd.Dir = dir
if out, err := cmd.CombinedOutput(); err != nil {
testenv.MustHaveGoRun(t)
testenv.MustHaveCGO(t)
- cmd := exec.Command("go", "run", "main.go")
+ cmd := exec.Command(testenv.GoToolPath(t), "run", "main.go")
got, err := cmd.CombinedOutput()
if err != nil {
t.Fatalf("%v: %s\n%s", cmd, err, got)
}
}
- cmd = exec.Command("go", "build", "-o", "main.exe", "main.go")
+ cmd = exec.Command(testenv.GoToolPath(t), "build", "-o", "main.exe", "main.go")
cmd.Dir = modRoot
cmd.Env = append(os.Environ(), "GOPATH="+GOPATH)
out, err = cmd.CombinedOutput()
file := file
wantFile := strings.Replace(file, ".go", ".out", 1)
t.Run(file, func(t *testing.T) {
- cmd := exec.Command("go", "run", file)
+ cmd := exec.Command(testenv.GoToolPath(t), "run", file)
got, err := cmd.CombinedOutput()
if err != nil {
t.Fatalf("%v: %s\n%s", cmd, err, got)
// Get list of packages in stdlib. Filter out test-only packages with {{if .GoFiles}} check.
var stderr bytes.Buffer
- cmd := exec.Command("go", "list", "-f", "{{if .GoFiles}}{{.ImportPath}}{{end}}", "std")
+ cmd := exec.Command(testenv.GoToolPath(t), "list", "-f", "{{if .GoFiles}}{{.ImportPath}}{{end}}", "std")
cmd.Stderr = &stderr
out, err := cmd.Output()
if err != nil {
}
func TestCmdBisect(t *testing.T) {
- testenv.MustHaveGoBuild(t)
- out, err := exec.Command("go", "run", "cmd/vendor/golang.org/x/tools/cmd/bisect", "GODEBUG=buggy=1#PATTERN", os.Args[0], "-test.run=^TestBisectTestCase$").CombinedOutput()
+ testenv.MustHaveGoRun(t)
+ out, err := exec.Command(testenv.GoToolPath(t), "run", "cmd/vendor/golang.org/x/tools/cmd/bisect", "GODEBUG=buggy=1#PATTERN", os.Args[0], "-test.run=^TestBisectTestCase$").CombinedOutput()
if err != nil {
t.Fatalf("exec bisect: %v\n%s", err, out)
}
import (
"bufio"
"fmt"
+ "internal/testenv"
"io"
"math/rand"
"os"
t.Skip("wasmer does not support non-blocking I/O")
}
+ testenv.MustHaveGoRun(t)
+
for _, mode := range []string{"os.OpenFile", "os.NewFile"} {
t.Run(mode, func(t *testing.T) {
args := []string{"run", "./testdata/nonblock.go", mode}
fifos[len(fifos)-i-1] = &fifo{file, path}
}
- subProcess := exec.Command("go", args...)
+ subProcess := exec.Command(testenv.GoToolPath(t), args...)
subProcess.Env = append(os.Environ(), "GOOS=wasip1", "GOARCH=wasm")
import (
"bytes"
"fmt"
+ "internal/testenv"
"math/rand"
"net"
"os"
t.Skip()
}
+ testenv.MustHaveGoRun(t)
+
// We're unable to use port 0 here (let the OS choose a spare port).
// Although the WASM runtime accepts port 0, and the WASM module listens
// successfully, there's no way for this test to query the selected port
port++
}
- subProcess := exec.Command("go", "run", "./testdata/tcpecho.go")
+ subProcess := exec.Command(testenv.GoToolPath(t), "run", "./testdata/tcpecho.go")
subProcess.Env = append(os.Environ(), "GOOS=wasip1", "GOARCH=wasm")