diff options
| author | Dmitri Shuralyov <dmitshur@golang.org> | 2023-09-03 14:23:02 -0400 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2023-09-05 23:35:29 +0000 |
| commit | 0dfb22ed70749a2cd6d95ec6eee63bb213a940d4 (patch) | |
| tree | ba421b5cae00d9541f48ab2710a76e7fd722adda /src/runtime | |
| parent | cffdfe8d2cabbe874bceaeed1eba92cc567be6db (diff) | |
| download | go-0dfb22ed70749a2cd6d95ec6eee63bb213a940d4.tar.xz | |
all: use ^TestName$ regular pattern for invoking a single test
Use ^ and $ in the -run flag regular expression value when the intention
is to invoke a single named test. This removes the reliance on there not
being another similarly named test to achieve the intended result.
In particular, package syscall has tests named TestUnshareMountNameSpace
and TestUnshareMountNameSpaceChroot that both trigger themselves setting
GO_WANT_HELPER_PROCESS=1 to run alternate code in a helper process. As a
consequence of overlap in their test names, the former was inadvertently
triggering one too many helpers.
Spotted while reviewing CL 525196. Apply the same change in other places
to make it easier for code readers to see that said tests aren't running
extraneous tests. The unlikely cases of -run=TestSomething intentionally
being used to run all tests that have the TestSomething substring in the
name can be better written as -run=^.*TestSomething.*$ or with a comment
so it is clear it wasn't an oversight.
Change-Id: Iba208aba3998acdbf8c6708e5d23ab88938bfc1e
Reviewed-on: https://go-review.googlesource.com/c/go/+/524948
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Kirill Kolyshkin <kolyshkin@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Diffstat (limited to 'src/runtime')
| -rw-r--r-- | src/runtime/abi_test.go | 2 | ||||
| -rw-r--r-- | src/runtime/crash_test.go | 4 | ||||
| -rw-r--r-- | src/runtime/malloc_test.go | 2 | ||||
| -rw-r--r-- | src/runtime/vdso_test.go | 4 |
4 files changed, 6 insertions, 6 deletions
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() |
