mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
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>
This commit is contained in:
parent
2ee775fd9b
commit
dceee2e983
29 changed files with 49 additions and 75 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue