diff options
| author | qmuntal <quimmuntal@gmail.com> | 2025-02-24 09:43:41 +0100 |
|---|---|---|
| committer | Quim Muntal <quimmuntal@gmail.com> | 2025-02-24 11:03:10 -0800 |
| commit | dceee2e983f5dab65c3905ecf40e70e15cf41b7d (patch) | |
| tree | 90d8aec778115127028196a5de6b321008252b92 /src/cmd/cgo | |
| parent | 2ee775fd9b58247618cf8bc06935f33875bdc872 (diff) | |
| download | go-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/cmd/cgo')
| -rw-r--r-- | src/cmd/cgo/internal/test/issue18146.go | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/cmd/cgo/internal/test/issue18146.go b/src/cmd/cgo/internal/test/issue18146.go index 112b7ee2e7..04e5b5ffb8 100644 --- a/src/cmd/cgo/internal/test/issue18146.go +++ b/src/cmd/cgo/internal/test/issue18146.go @@ -11,6 +11,7 @@ package cgotest import ( "bytes" "crypto/md5" + "internal/testenv" "os" "os/exec" "runtime" @@ -73,7 +74,7 @@ func test18146(t *testing.T) { } runtime.GOMAXPROCS(threads) argv := append(os.Args, "-test.run=^$") - if err := syscall.Exec(os.Args[0], argv, os.Environ()); err != nil { + if err := syscall.Exec(testenv.Executable(t), argv, os.Environ()); err != nil { t.Fatal(err) } } @@ -87,7 +88,7 @@ func test18146(t *testing.T) { 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 := exec.Command(testenv.Executable(t), args...) cmd.Env = append(os.Environ(), "test18146=exec") buf := bytes.NewBuffer(nil) cmd.Stdout = buf |
