From dceee2e983f5dab65c3905ecf40e70e15cf41b7d Mon Sep 17 00:00:00 2001 From: qmuntal Date: Mon, 24 Feb 2025 09:43:41 +0100 Subject: 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 LUCI-TryBot-Result: Go LUCI Reviewed-by: Ian Lance Taylor --- src/testing/testing_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/testing/testing_test.go') 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) -- cgit v1.3