aboutsummaryrefslogtreecommitdiff
path: root/src/os/exec/lp_windows_test.go
diff options
context:
space:
mode:
authorKir Kolyshkin <kolyshkin@gmail.com>2024-08-29 19:51:22 -0700
committerGopher Robot <gobot@golang.org>2024-09-03 20:11:30 +0000
commitc3f346a485f2fa97a7bdee82d587419b3823a1ba (patch)
treec085a5dbe2fe5fb250b39d9ea56cc4608b6cee67 /src/os/exec/lp_windows_test.go
parent76a42d74356e3c5bee0851c99665b21bf29f0c27 (diff)
downloadgo-c3f346a485f2fa97a7bdee82d587419b3823a1ba.tar.xz
math,os,os/*: use testenv.Executable
As some callers don't have a testing context, modify testenv.Executable to accept nil (similar to how testenv.GOROOT works). Change-Id: I39112a7869933785a26b5cb6520055b3cc42b847 Reviewed-on: https://go-review.googlesource.com/c/go/+/609835 Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Diffstat (limited to 'src/os/exec/lp_windows_test.go')
-rw-r--r--src/os/exec/lp_windows_test.go11
1 files changed, 3 insertions, 8 deletions
diff --git a/src/os/exec/lp_windows_test.go b/src/os/exec/lp_windows_test.go
index a92a29799f..15b2a0032f 100644
--- a/src/os/exec/lp_windows_test.go
+++ b/src/os/exec/lp_windows_test.go
@@ -25,13 +25,8 @@ func init() {
registerHelperCommand("printpath", cmdPrintPath)
}
-func cmdPrintPath(args ...string) {
- exe, err := os.Executable()
- if err != nil {
- fmt.Fprintf(os.Stderr, "Executable: %v\n", err)
- os.Exit(1)
- }
- fmt.Println(exe)
+func cmdPrintPath(_ ...string) {
+ fmt.Println(testenv.Executable(nil))
}
// makePATH returns a PATH variable referring to the
@@ -82,7 +77,7 @@ func installProgs(t *testing.T, root string, files []string) {
// (We use a copy instead of just a symlink to ensure that os.Executable
// always reports an unambiguous path, regardless of how it is implemented.)
func installExe(t *testing.T, dstPath string) {
- src, err := os.Open(exePath(t))
+ src, err := os.Open(testenv.Executable(t))
if err != nil {
t.Fatal(err)
}