aboutsummaryrefslogtreecommitdiff
path: root/src/testing
diff options
context:
space:
mode:
authorqmuntal <quimmuntal@gmail.com>2025-02-24 09:43:41 +0100
committerQuim Muntal <quimmuntal@gmail.com>2025-02-24 11:03:10 -0800
commitdceee2e983f5dab65c3905ecf40e70e15cf41b7d (patch)
tree90d8aec778115127028196a5de6b321008252b92 /src/testing
parent2ee775fd9b58247618cf8bc06935f33875bdc872 (diff)
downloadgo-dceee2e983f5dab65c3905ecf40e70e15cf41b7d.tar.xz
all: use testenv.Executable instead of os.Executable and os.Args[0]
In test files, using testenv.Executable is more reliable than os.Executable or os.Args[0]. Change-Id: I88e577efeabc20d02ada27bf706ae4523129128e Reviewed-on: https://go-review.googlesource.com/c/go/+/651955 Reviewed-by: Cherry Mui <cherryyz@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
Diffstat (limited to 'src/testing')
-rw-r--r--src/testing/panic_test.go4
-rw-r--r--src/testing/testing_test.go4
2 files changed, 4 insertions, 4 deletions
diff --git a/src/testing/panic_test.go b/src/testing/panic_test.go
index 6307b84a7a..1c42f9f8dd 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(testenv.Executable(t), "-test.run=^TestPanicHelper$")
cmd.Args = append(cmd.Args, tc.flags...)
cmd.Env = append(os.Environ(), "GO_WANT_HELPER_PROCESS=1")
b, _ := cmd.CombinedOutput()
@@ -232,7 +232,7 @@ func TestMorePanic(t *testing.T) {
}
for _, tc := range testCases {
- cmd := exec.Command(os.Args[0], tc.flags...)
+ cmd := exec.Command(testenv.Executable(t), tc.flags...)
cmd.Env = append(os.Environ(), "GO_WANT_HELPER_PROCESS=1")
b, _ := cmd.CombinedOutput()
got := string(b)
diff --git a/src/testing/testing_test.go b/src/testing/testing_test.go
index addf6cad91..907d0701f0 100644
--- a/src/testing/testing_test.go
+++ b/src/testing/testing_test.go
@@ -801,7 +801,7 @@ func TestRunningTests(t *testing.T) {
timeout := 10 * time.Millisecond
for {
- cmd := testenv.Command(t, os.Args[0], "-test.run=^"+t.Name()+"$", "-test.timeout="+timeout.String(), "-test.parallel=4")
+ cmd := testenv.Command(t, testenv.Executable(t), "-test.run=^"+t.Name()+"$", "-test.timeout="+timeout.String(), "-test.parallel=4")
cmd.Env = append(cmd.Environ(), "GO_WANT_HELPER_PROCESS=1")
out, err := cmd.CombinedOutput()
t.Logf("%v:\n%s", cmd, out)
@@ -860,7 +860,7 @@ func TestRunningTestsInCleanup(t *testing.T) {
timeout := 10 * time.Millisecond
for {
- cmd := testenv.Command(t, os.Args[0], "-test.run=^"+t.Name()+"$", "-test.timeout="+timeout.String())
+ cmd := testenv.Command(t, testenv.Executable(t), "-test.run=^"+t.Name()+"$", "-test.timeout="+timeout.String())
cmd.Env = append(cmd.Environ(), "GO_WANT_HELPER_PROCESS=1")
out, err := cmd.CombinedOutput()
t.Logf("%v:\n%s", cmd, out)