}
}()
- args := append(append([]string(nil), os.Args[1:]...), "-test.run=Test18146")
+ args := append(append([]string(nil), os.Args[1:]...), "-test.run=^Test18146$")
for n := attempts; n > 0; n-- {
cmd := exec.Command(os.Args[0], args...)
cmd.Env = append(os.Environ(), "test18146=exec")
continue
}
t.Run(fmt.Sprintf("%s%s", test.name[4:], flag), func(t *testing.T) {
- out, err := testenv.Command(t, filepath.Join(tmpdir, "code.test"), "-test.run="+test.name).CombinedOutput()
+ out, err := testenv.Command(t, filepath.Join(tmpdir, "code.test"), "-test.run=^"+test.name+"$").CombinedOutput()
if err != nil || string(out) != "PASS\n" {
t.Errorf("Failed:\n%s\n", out)
}
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// Code generated by 'go test cmd/go -v -run=TestDocsUpToDate -fixdocs'; DO NOT EDIT.
+// Code generated by 'go test cmd/go -v -run=^TestDocsUpToDate$ -fixdocs'; DO NOT EDIT.
// Edit the documentation in other files and then execute 'go generate cmd/go' to generate this one.
// Go is a tool for managing Go source code.
fmt.Fprintln(w, "// Use of this source code is governed by a BSD-style")
fmt.Fprintln(w, "// license that can be found in the LICENSE file.")
fmt.Fprintln(w)
- fmt.Fprintln(w, "// Code generated by 'go test cmd/go -v -run=TestDocsUpToDate -fixdocs'; DO NOT EDIT.")
+ fmt.Fprintln(w, "// Code generated by 'go test cmd/go -v -run=^TestDocsUpToDate$ -fixdocs'; DO NOT EDIT.")
fmt.Fprintln(w, "// Edit the documentation in other files and then execute 'go generate cmd/go' to generate this one.")
fmt.Fprintln(w)
buf := new(strings.Builder)
t.Fatal(err)
}
- cmd := testenv.Command(t, os.Args[0], "-test.run="+t.Name())
+ cmd := testenv.Command(t, os.Args[0], "-test.run=^"+t.Name()+"$")
cmd.Env = append(os.Environ(), fmt.Sprintf("%s=%s", dirVar, dir))
qDone := make(chan struct{})
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-//go:generate go test cmd/go -v -run=TestDocsUpToDate -fixdocs
+//go:generate go test cmd/go -v -run=^TestDocsUpToDate$ -fixdocs
package main
}
for _, test := range tests {
- cmd := exec.Command(os.Args[0], "-test.run=TestExitCode")
+ cmd := exec.Command(os.Args[0], "-test.run=^TestExitCode$")
cmd.Env = append(
os.Environ(),
"GO_CHILD_FLAG="+test.flag,
env := "GODEBUG=" + options
- cmd := exec.Command(os.Args[0], "-test.run="+test)
+ cmd := exec.Command(os.Args[0], "-test.run=^"+test+"$")
cmd.Env = append(cmd.Env, env)
output, err := cmd.CombinedOutput()
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=BisectTestCase").CombinedOutput()
+ 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()
if err != nil {
t.Fatalf("exec bisect: %v\n%s", err, out)
}
// This test does nothing by itself, but you can run
//
-// bisect 'GODEBUG=buggy=1#PATTERN' go test -run=BisectTestCase
+// bisect 'GODEBUG=buggy=1#PATTERN' go test -run='^TestBisectTestCase$'
//
// to see that the GODEBUG bisect support is working.
// TestCmdBisect above does exactly that.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-//go:generate go test . -run=TestGenerated -fix
+//go:generate go test . -run=^TestGenerated$ -fix
package platform
return
}
- cmd := exec.Command(os.Args[0], "-test.run=TestRunAtLowIntegrity", "--")
+ cmd := exec.Command(os.Args[0], "-test.run=^TestRunAtLowIntegrity$", "--")
cmd.Env = []string{"GO_WANT_HELPER_PROCESS=1"}
token, err := getIntegrityLevelToken(sidWilLow)
// Calculates lower and upper thresholds for when basicSqr
// is faster than standard multiplication.
-// Usage: go test -run=TestCalibrate -v -calibrate
+// Usage: go test -run='^TestCalibrate$' -v -calibrate
package big
h := &Handler{
Path: os.Args[0],
Root: "/test.go",
- Args: []string{"-test.run=TestBeChildCGIProcess"},
+ Args: []string{"-test.run=^TestBeChildCGIProcess$"},
}
expectedMap := map[string]string{
"test": "Hello CGI-in-CGI",
h := &Handler{
Path: os.Args[0],
Root: "/test.go",
- Args: []string{"-test.run=TestBeChildCGIProcess"},
+ Args: []string{"-test.run=^TestBeChildCGIProcess$"},
}
req, _ := http.NewRequest("GET", "http://example.com/test.cgi?write-forever=1", nil)
rec := httptest.NewRecorder()
h := &Handler{
Path: os.Args[0],
Root: "/test.go",
- Args: []string{"-test.run=TestBeChildCGIProcess"},
+ Args: []string{"-test.run=^TestBeChildCGIProcess$"},
}
expectedMap := map[string]string{
"_body": "",
h := &Handler{
Path: os.Args[0],
Root: "/test.go",
- Args: []string{"-test.run=TestBeChildCGIProcess"},
+ Args: []string{"-test.run=^TestBeChildCGIProcess$"},
}
expectedMap := map[string]string{
"nil-request-body": "false",
h := &Handler{
Path: os.Args[0],
Root: "/test.go",
- Args: []string{"-test.run=TestBeChildCGIProcess"},
+ Args: []string{"-test.run=^TestBeChildCGIProcess$"},
}
var tests = []struct {
name string
h := &Handler{
Path: os.Args[0],
Root: "/test.go",
- Args: []string{"-test.run=TestBeChildCGIProcess"},
+ Args: []string{"-test.run=^TestBeChildCGIProcess$"},
}
expectedMap := map[string]string{
"_body": "",
defer os.Remove(filepath)
var buf strings.Builder
- child := testenv.Command(t, "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
// When debugging a particular http server-based test,
// this flag lets you run
//
-// go test -run=BrokenTest -httptest.serve=127.0.0.1:8000
+// go test -run='^BrokenTest$' -httptest.serve=127.0.0.1:8000
//
// to start the broken server so you can interact with it manually.
// We only register this flag if it looks like the caller knows about it
// For use like:
//
// $ go test -c
-// $ ./http.test -test.run=XX -test.bench=BenchmarkServer -test.benchtime=15s -test.cpuprofile=http.prof
+// $ ./http.test -test.run=XX -test.bench='^BenchmarkServer$' -test.benchtime=15s -test.cpuprofile=http.prof
// $ go tool pprof http.test http.prof
// (pprof) web
func BenchmarkServer(b *testing.B) {
defer ts.Close()
b.StartTimer()
- cmd := testenv.Command(b, 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),
// Start server process.
ctx, cancel := context.WithCancel(context.Background())
- cmd := testenv.CommandContext(b, ctx, os.Args[0], "-test.run=XXXX", "-test.bench=BenchmarkClient$")
+ cmd := testenv.CommandContext(b, ctx, os.Args[0], "-test.run=XXXX", "-test.bench=^BenchmarkClient$")
cmd.Env = append(cmd.Environ(), "TEST_BENCH_SERVER=yes")
cmd.Stderr = os.Stderr
stdout, err := cmd.StdoutPipe()
testenv.MustHaveExec(t)
t.Parallel()
- cmd := testenv.Command(t, Args[0], "-test.run=TestGetppid")
+ cmd := testenv.Command(t, Args[0], "-test.run=^TestGetppid$")
cmd.Env = append(Environ(), "GO_WANT_HELPER_PROCESS=1")
// verify that Getppid() from the forked process reports our process id
t.Skip(err)
}
- cmd := testenv.Command(t, exe, "-test.run=TestRootDirAsTemp")
+ cmd := testenv.Command(t, exe, "-test.run=^TestRootDirAsTemp$")
cmd.Env = cmd.Environ()
cmd.Env = append(cmd.Env, "GO_WANT_HELPER_PROCESS=1")
cmd.Env = append(cmd.Env, "TMP="+newtmp)
}
defer r.Close()
defer w.Close()
- cmd := testenv.Command(t, os.Args[0], "-test.run="+t.Name())
+ cmd := testenv.Command(t, os.Args[0], "-test.run=^"+t.Name()+"$")
cmd.Env = append(cmd.Environ(), "GO_WANT_READ_NONBLOCKING_FD=1")
cmd.Stdin = r
output, err := cmd.CombinedOutput()
}
}
- cmd := testenv.Command(t, "/bin/strace", "-f", "-e", "fcntl", me, "-test.run=TestRemoveAllNoFcntl")
+ cmd := testenv.Command(t, "/bin/strace", "-f", "-e", "fcntl", me, "-test.run=^TestRemoveAllNoFcntl$")
cmd = testenv.CleanCmdEnv(cmd)
cmd.Env = append(cmd.Env, env+"="+subdir)
out, err := cmd.CombinedOutput()
var (
ctx = context.Background()
- cmdArgs = []string{"-test.run=TestTerminalSignal"}
+ cmdArgs = []string{"-test.run=^TestTerminalSignal$"}
)
if deadline, ok := t.Deadline(); ok {
d := time.Until(deadline)
var (
ctx = context.Background()
- cmdArgs = []string{"-test.run=TestTerminalSignal"}
+ cmdArgs = []string{"-test.run=^TestTerminalSignal$"}
)
if deadline, ok := t.Deadline(); ok {
d := time.Until(deadline)
// We have no intention of reading from c.
c := make(chan os.Signal, 1)
Notify(c, syscall.SIGHUP)
- if out, err := testenv.Command(t, os.Args[0], "-test.run=TestDetectNohup", "-check_sighup_ignored").CombinedOutput(); err == nil {
+ if out, err := testenv.Command(t, os.Args[0], "-test.run=^TestDetectNohup$", "-check_sighup_ignored").CombinedOutput(); err == nil {
t.Errorf("ran test with -check_sighup_ignored and it succeeded: expected failure.\nOutput:\n%s", out)
}
Stop(c)
}
Ignore(syscall.SIGHUP)
os.Remove("nohup.out")
- out, err := testenv.Command(t, "/usr/bin/nohup", os.Args[0], "-test.run=TestDetectNohup", "-check_sighup_ignored").CombinedOutput()
+ out, err := testenv.Command(t, "/usr/bin/nohup", os.Args[0], "-test.run=^TestDetectNohup$", "-check_sighup_ignored").CombinedOutput()
data, _ := os.ReadFile("nohup.out")
os.Remove("nohup.out")
args := []string{
"-test.v",
- "-test.run=TestStop",
+ "-test.run=^TestStop$",
"-send_uncaught_sighup=" + strconv.Itoa(i),
"-die_from_sighup",
}
args := []string{
os.Args[0],
"-test.v",
- "-test.run=TestStop",
+ "-test.run=^TestStop$",
"-send_uncaught_sighup=" + strconv.Itoa(i),
}
if subTimeout != 0 {
if deadline, ok := t.Deadline(); ok {
timeout = time.Until(deadline).String()
}
- cmd := testenv.Command(t, os.Args[0], "-test.run=TestAtomicStop", "-test.timeout="+timeout)
+ cmd := testenv.Command(t, os.Args[0], "-test.run=^TestAtomicStop$", "-test.timeout="+timeout)
cmd.Env = append(os.Environ(), "GO_TEST_ATOMIC_STOP=1")
out, err := cmd.CombinedOutput()
if err == nil {
args := []string{
"-test.v",
- "-test.run=TestNotifyContextNotifications$",
+ "-test.run=^TestNotifyContextNotifications$",
"-check_notify_ctx",
fmt.Sprintf("-ctx_notify_times=%d", tc.n),
}
// Actually run the test in a subprocess because we don't want
// finalizers from other tests interfering.
if os.Getenv("TEST_FINALIZER_REGABI") != "1" {
- cmd := testenv.CleanCmdEnv(exec.Command(os.Args[0], "-test.run=TestFinalizerRegisterABI", "-test.v"))
+ cmd := testenv.CleanCmdEnv(exec.Command(os.Args[0], "-test.run=^TestFinalizerRegisterABI$", "-test.v"))
cmd.Env = append(cmd.Env, "TEST_FINALIZER_REGABI=1")
out, err := cmd.CombinedOutput()
if !strings.Contains(string(out), "PASS\n") || err != nil {
func TestRuntimePanic(t *testing.T) {
testenv.MustHaveExec(t)
- cmd := testenv.CleanCmdEnv(exec.Command(os.Args[0], "-test.run=TestRuntimePanic"))
+ cmd := testenv.CleanCmdEnv(exec.Command(os.Args[0], "-test.run=^TestRuntimePanic$"))
cmd.Env = append(cmd.Env, "GO_TEST_RUNTIME_PANIC=1")
out, err := cmd.CombinedOutput()
t.Logf("%s", out)
}
if os.Getenv("TEST_G0_STACK_OVERFLOW") != "1" {
- cmd := testenv.CleanCmdEnv(exec.Command(os.Args[0], "-test.run=TestG0StackOverflow", "-test.v"))
+ cmd := testenv.CleanCmdEnv(exec.Command(os.Args[0], "-test.run=^TestG0StackOverflow$", "-test.v"))
cmd.Env = append(cmd.Env, "TEST_G0_STACK_OVERFLOW=1")
out, err := cmd.CombinedOutput()
// Don't check err since it's expected to crash.
// Test that mheap.sysAlloc handles collisions with other
// memory mappings.
if os.Getenv("TEST_ARENA_COLLISION") != "1" {
- cmd := testenv.CleanCmdEnv(exec.Command(os.Args[0], "-test.run=TestArenaCollision", "-test.v"))
+ cmd := testenv.CleanCmdEnv(exec.Command(os.Args[0], "-test.run=^TestArenaCollision$", "-test.v"))
cmd.Env = append(cmd.Env, "TEST_ARENA_COLLISION=1")
out, err := cmd.CombinedOutput()
if race.Enabled {
t.Skipf("skipping because Executable failed: %v", err)
}
- t.Logf("GO_WANT_HELPER_PROCESS=1 %s -f -e clock_gettime %s -test.run=TestUsingVDSO", strace, exe)
- cmd := testenv.Command(t, strace, "-f", "-e", "clock_gettime", exe, "-test.run=TestUsingVDSO")
+ t.Logf("GO_WANT_HELPER_PROCESS=1 %s -f -e clock_gettime %s -test.run=^TestUsingVDSO$", strace, exe)
+ cmd := testenv.Command(t, strace, "-f", "-e", "clock_gettime", exe, "-test.run=^TestUsingVDSO$")
cmd = testenv.CleanCmdEnv(cmd)
cmd.Env = append(cmd.Env, "GO_WANT_HELPER_PROCESS=1")
out, err := cmd.CombinedOutput()
syscall.Unmount(d, syscall.MNT_FORCE)
}
})
- cmd := testenv.Command(t, exe, "-test.run=TestUnshareMountNameSpace", d)
+ cmd := testenv.Command(t, exe, "-test.run=^TestUnshareMountNameSpace$", d)
cmd.Env = append(cmd.Environ(), "GO_WANT_HELPER_PROCESS=1")
cmd.SysProcAttr = &syscall.SysProcAttr{Unshareflags: syscall.CLONE_NEWNS}
t.Fatalf("%v: %v\n%s", cmd, err, o)
}
- cmd = testenv.Command(t, "/syscall.test", "-test.run=TestUnshareMountNameSpaceChroot", "/")
+ cmd = testenv.Command(t, "/syscall.test", "-test.run=^TestUnshareMountNameSpaceChroot$", "/")
cmd.Env = append(cmd.Environ(), "GO_WANT_HELPER_PROCESS=1")
cmd.SysProcAttr = &syscall.SysProcAttr{Chroot: d, Unshareflags: syscall.CLONE_NEWNS}
t.Fatal(err)
}
- cmd := testenv.Command(t, exe, "-test.run=TestUnshareUidGidMapping")
+ cmd := testenv.Command(t, exe, "-test.run=^TestUnshareUidGidMapping$")
cmd.Env = append(cmd.Environ(), "GO_WANT_HELPER_PROCESS=1")
cmd.SysProcAttr = &syscall.SysProcAttr{
Unshareflags: syscall.CLONE_NEWNS | syscall.CLONE_NEWUSER,
fd, suffix := prepareCgroupFD(t)
- cmd := testenv.Command(t, exe, "-test.run=TestUseCgroupFD")
+ cmd := testenv.Command(t, exe, "-test.run=^TestUseCgroupFD$")
cmd.Env = append(cmd.Environ(), "GO_WANT_HELPER_PROCESS=1")
cmd.SysProcAttr = &syscall.SysProcAttr{
UseCgroupFD: true,
t.Fatal(err)
}
- cmd := testenv.Command(t, exe, "-test.run=TestCloneTimeNamespace")
+ cmd := testenv.Command(t, exe, "-test.run=^TestCloneTimeNamespace$")
cmd.Env = append(cmd.Environ(), "GO_WANT_HELPER_PROCESS=1")
cmd.SysProcAttr = &syscall.SysProcAttr{
Cloneflags: syscall.CLONE_NEWTIME,
t.Fatal(err)
}
- cmd := testenv.Command(t, f.Name(), "-test.run="+t.Name())
+ cmd := testenv.Command(t, f.Name(), "-test.run=^"+t.Name()+"$")
cmd.Env = append(cmd.Environ(), "GO_WANT_HELPER_PROCESS=1")
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
// TestExec is for issue #41702.
func TestExec(t *testing.T) {
testenv.MustHaveExec(t)
- cmd := exec.Command(os.Args[0], "-test.run=TestExecHelper")
+ cmd := exec.Command(os.Args[0], "-test.run=^TestExecHelper$")
cmd.Env = append(os.Environ(), "GO_WANT_HELPER_PROCESS=2")
o, err := cmd.CombinedOutput()
if err != nil {
time.Sleep(10 * time.Millisecond)
- argv := []string{os.Args[0], "-test.run=TestExecHelper"}
+ argv := []string{os.Args[0], "-test.run=^TestExecHelper$"}
syscall.Exec(os.Args[0], argv, os.Environ())
t.Error("syscall.Exec returned")
executable = os.Args[0]
}
- cmd := testenv.Command(t, executable, "-test.run=TestRlimitRestored")
+ cmd := testenv.Command(t, executable, "-test.run=^TestRlimitRestored$")
cmd = testenv.CleanCmdEnv(cmd)
cmd.Env = append(cmd.Env, "GO_WANT_HELPER_PROCESS=1")
// run parent process
- parent := exec.Command(os.Args[0], "-test.run=TestChangingProcessParent")
+ parent := exec.Command(os.Args[0], "-test.run=^TestChangingProcessParent$")
parent.Env = append(os.Environ(), "GO_WANT_HELPER_PROCESS=parent")
err := parent.Start()
if err != nil {
}
defer syscall.CloseHandle(ph)
- child := exec.Command(os.Args[0], "-test.run=TestChangingProcessParent")
+ child := exec.Command(os.Args[0], "-test.run=^TestChangingProcessParent$")
child.Env = append(os.Environ(),
"GO_WANT_HELPER_PROCESS=child",
"GO_WANT_HELPER_PROCESS_FILE="+childDumpPath)
if err != nil {
exe = os.Args[0]
}
- cmd := exec.Command(exe, "-test.run=TestFlag", "-test_flag_arg="+flag)
+ cmd := exec.Command(exe, "-test.run=^TestFlag$", "-test_flag_arg="+flag)
if flag != "" {
cmd.Args = append(cmd.Args, flag)
}
}}
for _, tc := range testCases {
t.Run(tc.desc, func(t *testing.T) {
- cmd := exec.Command(os.Args[0], "-test.run=TestPanicHelper")
+ cmd := exec.Command(os.Args[0], "-test.run=^TestPanicHelper$")
cmd.Args = append(cmd.Args, tc.flags...)
cmd.Env = append(os.Environ(), "GO_WANT_HELPER_PROCESS=1")
b, _ := cmd.CombinedOutput()
}{
{
desc: "Issue 48502: call runtime.Goexit in t.Cleanup after panic",
- flags: []string{"-test.run=TestGoexitInCleanupAfterPanicHelper"},
+ flags: []string{"-test.run=^TestGoexitInCleanupAfterPanicHelper$"},
want: `panic: die
panic: test executed panic(nil) or runtime.Goexit`,
},
{
desc: "Issue 48515: call t.Run in t.Cleanup should trigger panic",
- flags: []string{"-test.run=TestCallRunInCleanupHelper"},
+ flags: []string{"-test.run=^TestCallRunInCleanupHelper$"},
want: `panic: testing: t.Run called during t.Cleanup`,
},
}