aboutsummaryrefslogtreecommitdiff
path: root/src/os/pipe_test.go
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/os/pipe_test.go
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/os/pipe_test.go')
-rw-r--r--src/os/pipe_test.go6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/os/pipe_test.go b/src/os/pipe_test.go
index a9e0c8bc8a..ccae6f61bf 100644
--- a/src/os/pipe_test.go
+++ b/src/os/pipe_test.go
@@ -118,7 +118,7 @@ func TestStdPipe(t *testing.T) {
// all writes should fail with EPIPE and then exit 0.
for _, sig := range []bool{false, true} {
for dest := 1; dest < 4; dest++ {
- cmd := testenv.Command(t, os.Args[0], "-test.run", "TestStdPipe")
+ cmd := testenv.Command(t, testenv.Executable(t), "-test.run", "TestStdPipe")
cmd.Stdout = w
cmd.Stderr = w
cmd.ExtraFiles = []*os.File{w}
@@ -145,7 +145,7 @@ func TestStdPipe(t *testing.T) {
}
// Test redirecting stdout but not stderr. Issue 40076.
- cmd := testenv.Command(t, os.Args[0], "-test.run", "TestStdPipe")
+ cmd := testenv.Command(t, testenv.Executable(t), "-test.run", "TestStdPipe")
cmd.Stdout = w
var stderr bytes.Buffer
cmd.Stderr = &stderr
@@ -263,7 +263,7 @@ func TestReadNonblockingFd(t *testing.T) {
}
defer r.Close()
defer w.Close()
- cmd := testenv.Command(t, os.Args[0], "-test.run=^"+t.Name()+"$")
+ cmd := testenv.Command(t, testenv.Executable(t), "-test.run=^"+t.Name()+"$")
cmd.Env = append(cmd.Environ(), "GO_WANT_READ_NONBLOCKING_FD=1")
cmd.Stdin = r
output, err := cmd.CombinedOutput()