import (
"bufio"
"fmt"
+ "internal/testenv"
"io"
"net"
"net/http"
func check(t *testing.T) {
if !cgiTested {
cgiTested = true
- cgiWorks = exec.Command("./testdata/test.cgi").Run() == nil
+ cgiWorks = testenv.Command(t, "./testdata/test.cgi").Run() == nil
}
if !cgiWorks {
// No Perl on Windows, needed by test.cgi
}
perl, _ = filepath.Abs(perl)
- cmd := exec.Command(perl, "-e", "print 123")
+ cmd := testenv.Command(t, perl, "-e", "print 123")
cmd.Env = []string{"PATH=/garbage"}
out, err := cmd.Output()
if err != nil || string(out) != "123" {
"bytes"
"errors"
"fmt"
+ "internal/testenv"
"io"
"io/fs"
"mime"
defer ln.Close()
// Attempt to run strace, and skip on failure - this test requires SYS_PTRACE.
- if err := exec.Command("strace", "-f", "-q", os.Args[0], "-test.run=^$").Run(); err != nil {
+ if err := testenv.Command(t, "strace", "-f", "-q", os.Args[0], "-test.run=^$").Run(); err != nil {
t.Skipf("skipping; failed to run strace: %v", err)
}
defer os.Remove(filepath)
var buf strings.Builder
- child := exec.Command("strace", "-f", "-q", os.Args[0], "-test.run=TestLinuxSendfileChild")
+ child := testenv.Command(t, "strace", "-f", "-q", os.Args[0], "-test.run=TestLinuxSendfileChild")
child.ExtraFiles = append(child.ExtraFiles, lnf)
child.Env = append([]string{"GO_WANT_HELPER_PROCESS=1"}, os.Environ()...)
child.Stdout = &buf
"io/fs"
"net/url"
"os"
- "os/exec"
"reflect"
"regexp"
"strings"
func TestCmdGoNoHTTPServer(t *testing.T) {
t.Parallel()
goBin := testenv.GoToolPath(t)
- out, err := exec.Command(goBin, "tool", "nm", goBin).CombinedOutput()
+ out, err := testenv.Command(t, goBin, "tool", "nm", goBin).CombinedOutput()
if err != nil {
t.Fatalf("go tool nm: %v: %s", err, out)
}
}
t.Parallel()
goTool := testenv.GoToolPath(t)
- out, err := exec.Command(goTool, "test", "-short", "-tags=nethttpomithttp2", "net/http").CombinedOutput()
+ out, err := testenv.Command(t, goTool, "test", "-short", "-tags=nethttpomithttp2", "net/http").CombinedOutput()
if err != nil {
t.Fatalf("go test -short failed: %v, %s", err, out)
}
func TestOmitHTTP2Vet(t *testing.T) {
t.Parallel()
goTool := testenv.GoToolPath(t)
- out, err := exec.Command(goTool, "vet", "-tags=nethttpomithttp2", "net/http").CombinedOutput()
+ out, err := testenv.Command(t, goTool, "vet", "-tags=nethttpomithttp2", "net/http").CombinedOutput()
if err != nil {
t.Fatalf("go vet failed: %v, %s", err, out)
}
"net/http/internal/testcert"
"net/url"
"os"
- "os/exec"
"path/filepath"
"reflect"
"regexp"
defer ts.Close()
b.StartTimer()
- cmd := exec.Command(os.Args[0], "-test.run=XXXX", "-test.bench=BenchmarkServer$")
+ cmd := testenv.Command(b, os.Args[0], "-test.run=XXXX", "-test.bench=BenchmarkServer$")
cmd.Env = append([]string{
fmt.Sprintf("TEST_BENCH_CLIENT_N=%d", b.N),
fmt.Sprintf("TEST_BENCH_SERVER_URL=%s", ts.URL),