diff options
31 files changed, 57 insertions, 57 deletions
diff --git a/src/cmd/cgo/internal/test/issue18146.go b/src/cmd/cgo/internal/test/issue18146.go index d302bd029f..b9255234eb 100644 --- a/src/cmd/cgo/internal/test/issue18146.go +++ b/src/cmd/cgo/internal/test/issue18146.go @@ -85,7 +85,7 @@ func test18146(t *testing.T) { } }() - 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") diff --git a/src/cmd/compile/internal/test/ssa_test.go b/src/cmd/compile/internal/test/ssa_test.go index 5f8acdc72d..7f2faa1140 100644 --- a/src/cmd/compile/internal/test/ssa_test.go +++ b/src/cmd/compile/internal/test/ssa_test.go @@ -169,7 +169,7 @@ func TestCode(t *testing.T) { 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) } diff --git a/src/cmd/go/alldocs.go b/src/cmd/go/alldocs.go index 2c8f59e682..3174c6af32 100644 --- a/src/cmd/go/alldocs.go +++ b/src/cmd/go/alldocs.go @@ -2,7 +2,7 @@ // 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. diff --git a/src/cmd/go/internal/help/help.go b/src/cmd/go/internal/help/help.go index c36dae822e..501f08eb2d 100644 --- a/src/cmd/go/internal/help/help.go +++ b/src/cmd/go/internal/help/help.go @@ -26,7 +26,7 @@ func Help(w io.Writer, args []string) { 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) diff --git a/src/cmd/go/internal/lockedfile/lockedfile_test.go b/src/cmd/go/internal/lockedfile/lockedfile_test.go index 8dea8f70c2..a9fa40b8df 100644 --- a/src/cmd/go/internal/lockedfile/lockedfile_test.go +++ b/src/cmd/go/internal/lockedfile/lockedfile_test.go @@ -238,7 +238,7 @@ func TestSpuriousEDEADLK(t *testing.T) { 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{}) diff --git a/src/cmd/go/main.go b/src/cmd/go/main.go index b85da97201..7d4dedc1bb 100644 --- a/src/cmd/go/main.go +++ b/src/cmd/go/main.go @@ -2,7 +2,7 @@ // 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 diff --git a/src/flag/flag_test.go b/src/flag/flag_test.go index 57c88f009f..8e9ae316fe 100644 --- a/src/flag/flag_test.go +++ b/src/flag/flag_test.go @@ -701,7 +701,7 @@ func TestExitCode(t *testing.T) { } 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, diff --git a/src/internal/cpu/cpu_test.go b/src/internal/cpu/cpu_test.go index b8c74f2e9c..a6fe7f77f3 100644 --- a/src/internal/cpu/cpu_test.go +++ b/src/internal/cpu/cpu_test.go @@ -30,7 +30,7 @@ func runDebugOptionsTest(t *testing.T, test string, options string) { 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() diff --git a/src/internal/godebug/godebug_test.go b/src/internal/godebug/godebug_test.go index 8e46283ada..ed8e93d453 100644 --- a/src/internal/godebug/godebug_test.go +++ b/src/internal/godebug/godebug_test.go @@ -72,7 +72,7 @@ func TestMetrics(t *testing.T) { 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) } @@ -101,7 +101,7 @@ func TestCmdBisect(t *testing.T) { // 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. diff --git a/src/internal/platform/supported.go b/src/internal/platform/supported.go index b1e550ef32..4589903550 100644 --- a/src/internal/platform/supported.go +++ b/src/internal/platform/supported.go @@ -2,7 +2,7 @@ // 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 diff --git a/src/internal/syscall/windows/exec_windows_test.go b/src/internal/syscall/windows/exec_windows_test.go index 3311da5474..72550b5a84 100644 --- a/src/internal/syscall/windows/exec_windows_test.go +++ b/src/internal/syscall/windows/exec_windows_test.go @@ -29,7 +29,7 @@ func TestRunAtLowIntegrity(t *testing.T) { 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) diff --git a/src/math/big/calibrate_test.go b/src/math/big/calibrate_test.go index 4fa663ff08..d85833aede 100644 --- a/src/math/big/calibrate_test.go +++ b/src/math/big/calibrate_test.go @@ -15,7 +15,7 @@ // 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 diff --git a/src/net/http/cgi/integration_test.go b/src/net/http/cgi/integration_test.go index ef2eaf748b..4890ae0707 100644 --- a/src/net/http/cgi/integration_test.go +++ b/src/net/http/cgi/integration_test.go @@ -31,7 +31,7 @@ func TestHostingOurselves(t *testing.T) { 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", @@ -98,7 +98,7 @@ func TestKillChildAfterCopyError(t *testing.T) { 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() @@ -120,7 +120,7 @@ func TestChildOnlyHeaders(t *testing.T) { h := &Handler{ Path: os.Args[0], Root: "/test.go", - Args: []string{"-test.run=TestBeChildCGIProcess"}, + Args: []string{"-test.run=^TestBeChildCGIProcess$"}, } expectedMap := map[string]string{ "_body": "", @@ -139,7 +139,7 @@ func TestNilRequestBody(t *testing.T) { 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", @@ -154,7 +154,7 @@ func TestChildContentType(t *testing.T) { h := &Handler{ Path: os.Args[0], Root: "/test.go", - Args: []string{"-test.run=TestBeChildCGIProcess"}, + Args: []string{"-test.run=^TestBeChildCGIProcess$"}, } var tests = []struct { name string @@ -202,7 +202,7 @@ func want500Test(t *testing.T, path 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": "", diff --git a/src/net/http/fs_test.go b/src/net/http/fs_test.go index 2e15773652..cfabaae353 100644 --- a/src/net/http/fs_test.go +++ b/src/net/http/fs_test.go @@ -1280,7 +1280,7 @@ func TestLinuxSendfile(t *testing.T) { 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 diff --git a/src/net/http/httptest/server.go b/src/net/http/httptest/server.go index f254a494d1..79749a0378 100644 --- a/src/net/http/httptest/server.go +++ b/src/net/http/httptest/server.go @@ -77,7 +77,7 @@ func newLocalListener() net.Listener { // 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 diff --git a/src/net/http/serve_test.go b/src/net/http/serve_test.go index e71c5365e1..2473a88056 100644 --- a/src/net/http/serve_test.go +++ b/src/net/http/serve_test.go @@ -4992,7 +4992,7 @@ func benchmarkClientServerParallel(b *testing.B, parallelism int, mode testMode) // 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) { @@ -5031,7 +5031,7 @@ 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), @@ -5086,7 +5086,7 @@ func BenchmarkClient(b *testing.B) { // 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() diff --git a/src/os/os_test.go b/src/os/os_test.go index c5776a9f29..25837dce9e 100644 --- a/src/os/os_test.go +++ b/src/os/os_test.go @@ -2609,7 +2609,7 @@ func TestGetppid(t *testing.T) { 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 diff --git a/src/os/os_windows_test.go b/src/os/os_windows_test.go index bfbe7ec815..90c1eabd96 100644 --- a/src/os/os_windows_test.go +++ b/src/os/os_windows_test.go @@ -1228,7 +1228,7 @@ func TestRootDirAsTemp(t *testing.T) { 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) diff --git a/src/os/pipe_test.go b/src/os/pipe_test.go index 6f01d30e24..a9e0c8bc8a 100644 --- a/src/os/pipe_test.go +++ b/src/os/pipe_test.go @@ -263,7 +263,7 @@ func TestReadNonblockingFd(t *testing.T) { } 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() diff --git a/src/os/removeall_test.go b/src/os/removeall_test.go index 2f7938bb5c..c0b2dd6505 100644 --- a/src/os/removeall_test.go +++ b/src/os/removeall_test.go @@ -489,7 +489,7 @@ func TestRemoveAllNoFcntl(t *testing.T) { } } - 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() diff --git a/src/os/signal/signal_cgo_test.go b/src/os/signal/signal_cgo_test.go index 5e85f45e70..9e9a9fe526 100644 --- a/src/os/signal/signal_cgo_test.go +++ b/src/os/signal/signal_cgo_test.go @@ -130,7 +130,7 @@ func TestTerminalSignal(t *testing.T) { var ( ctx = context.Background() - cmdArgs = []string{"-test.run=TestTerminalSignal"} + cmdArgs = []string{"-test.run=^TestTerminalSignal$"} ) if deadline, ok := t.Deadline(); ok { d := time.Until(deadline) @@ -250,7 +250,7 @@ func runSessionLeader(t *testing.T, pause time.Duration) { var ( ctx = context.Background() - cmdArgs = []string{"-test.run=TestTerminalSignal"} + cmdArgs = []string{"-test.run=^TestTerminalSignal$"} ) if deadline, ok := t.Deadline(); ok { d := time.Until(deadline) diff --git a/src/os/signal/signal_test.go b/src/os/signal/signal_test.go index e5af885511..e7575eb70e 100644 --- a/src/os/signal/signal_test.go +++ b/src/os/signal/signal_test.go @@ -304,7 +304,7 @@ func TestDetectNohup(t *testing.T) { // 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) @@ -315,7 +315,7 @@ func TestDetectNohup(t *testing.T) { } 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") @@ -440,7 +440,7 @@ func TestNohup(t *testing.T) { args := []string{ "-test.v", - "-test.run=TestStop", + "-test.run=^TestStop$", "-send_uncaught_sighup=" + strconv.Itoa(i), "-die_from_sighup", } @@ -491,7 +491,7 @@ func TestNohup(t *testing.T) { args := []string{ os.Args[0], "-test.v", - "-test.run=TestStop", + "-test.run=^TestStop$", "-send_uncaught_sighup=" + strconv.Itoa(i), } if subTimeout != 0 { @@ -546,7 +546,7 @@ func TestAtomicStop(t *testing.T) { 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 { @@ -742,7 +742,7 @@ func TestNotifyContextNotifications(t *testing.T) { args := []string{ "-test.v", - "-test.run=TestNotifyContextNotifications$", + "-test.run=^TestNotifyContextNotifications$", "-check_notify_ctx", fmt.Sprintf("-ctx_notify_times=%d", tc.n), } diff --git a/src/runtime/abi_test.go b/src/runtime/abi_test.go index 0c9488a5f4..d7039e758a 100644 --- a/src/runtime/abi_test.go +++ b/src/runtime/abi_test.go @@ -40,7 +40,7 @@ func TestFinalizerRegisterABI(t *testing.T) { // 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 { diff --git a/src/runtime/crash_test.go b/src/runtime/crash_test.go index df75658750..2c990c199c 100644 --- a/src/runtime/crash_test.go +++ b/src/runtime/crash_test.go @@ -777,7 +777,7 @@ func init() { 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) @@ -798,7 +798,7 @@ func TestG0StackOverflow(t *testing.T) { } 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. diff --git a/src/runtime/malloc_test.go b/src/runtime/malloc_test.go index 5b9ce9882e..8c162fbea4 100644 --- a/src/runtime/malloc_test.go +++ b/src/runtime/malloc_test.go @@ -268,7 +268,7 @@ func TestArenaCollision(t *testing.T) { // 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 { diff --git a/src/runtime/vdso_test.go b/src/runtime/vdso_test.go index 61f651614b..126fd8d199 100644 --- a/src/runtime/vdso_test.go +++ b/src/runtime/vdso_test.go @@ -47,8 +47,8 @@ func TestUsingVDSO(t *testing.T) { 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() diff --git a/src/syscall/exec_linux_test.go b/src/syscall/exec_linux_test.go index d192b904d2..ca92a153f8 100644 --- a/src/syscall/exec_linux_test.go +++ b/src/syscall/exec_linux_test.go @@ -242,7 +242,7 @@ func TestUnshareMountNameSpace(t *testing.T) { 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} @@ -305,7 +305,7 @@ func TestUnshareMountNameSpaceChroot(t *testing.T) { 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} @@ -356,7 +356,7 @@ func TestUnshareUidGidMapping(t *testing.T) { 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, @@ -453,7 +453,7 @@ func TestUseCgroupFD(t *testing.T) { 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, @@ -494,7 +494,7 @@ func TestCloneTimeNamespace(t *testing.T) { 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, @@ -632,7 +632,7 @@ func testAmbientCaps(t *testing.T, userns bool) { 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 diff --git a/src/syscall/exec_unix_test.go b/src/syscall/exec_unix_test.go index 9627317bb3..accf6cc5c5 100644 --- a/src/syscall/exec_unix_test.go +++ b/src/syscall/exec_unix_test.go @@ -310,7 +310,7 @@ func TestInvalidExec(t *testing.T) { // 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 { @@ -343,7 +343,7 @@ func TestExecHelper(t *testing.T) { 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") @@ -366,7 +366,7 @@ func TestRlimitRestored(t *testing.T) { 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") diff --git a/src/syscall/exec_windows_test.go b/src/syscall/exec_windows_test.go index 8b8f330e99..5cacf42b6b 100644 --- a/src/syscall/exec_windows_test.go +++ b/src/syscall/exec_windows_test.go @@ -73,7 +73,7 @@ func TestChangingProcessParent(t *testing.T) { // 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 { @@ -96,7 +96,7 @@ func TestChangingProcessParent(t *testing.T) { } 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) diff --git a/src/testing/flag_test.go b/src/testing/flag_test.go index 416d8c9862..6f76c237c4 100644 --- a/src/testing/flag_test.go +++ b/src/testing/flag_test.go @@ -32,7 +32,7 @@ func TestFlag(t *testing.T) { 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) } diff --git a/src/testing/panic_test.go b/src/testing/panic_test.go index 8733bc3f30..6307b84a7a 100644 --- a/src/testing/panic_test.go +++ b/src/testing/panic_test.go @@ -139,7 +139,7 @@ ran outer cleanup }} 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() @@ -220,13 +220,13 @@ func TestMorePanic(t *testing.T) { }{ { 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`, }, } |
