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/net/mockserver_test.go | 2 +- src/net/net_windows_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src/net') diff --git a/src/net/mockserver_test.go b/src/net/mockserver_test.go index 4d5e79a592..63802c575e 100644 --- a/src/net/mockserver_test.go +++ b/src/net/mockserver_test.go @@ -548,7 +548,7 @@ func startTestSocketPeer(t testing.TB, conn Conn, op string, chunkSize, totalSiz return nil, err } - cmd := testenv.Command(t, os.Args[0]) + cmd := testenv.Command(t, testenv.Executable(t)) cmd.Env = []string{ "GO_NET_TEST_TRANSFER=1", "GO_NET_TEST_TRANSFER_OP=" + op, diff --git a/src/net/net_windows_test.go b/src/net/net_windows_test.go index 480e89dfd7..bc3171b4ea 100644 --- a/src/net/net_windows_test.go +++ b/src/net/net_windows_test.go @@ -100,7 +100,7 @@ func TestAcceptIgnoreSomeErrors(t *testing.T) { defer ln.Close() // Start child process that connects to our listener. - cmd := exec.Command(os.Args[0], "-test.run=TestAcceptIgnoreSomeErrors") + cmd := exec.Command(testenv.Executable(t), "-test.run=TestAcceptIgnoreSomeErrors") cmd.Env = append(os.Environ(), "GOTEST_DIAL_ADDR="+ln.Addr().String()) stdout, err := cmd.StdoutPipe() if err != nil { -- cgit v1.3-5-g9baa