aboutsummaryrefslogtreecommitdiff
path: root/src/internal/testenv/exec.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/internal/testenv/exec.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/internal/testenv/exec.go')
-rw-r--r--src/internal/testenv/exec.go12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/internal/testenv/exec.go b/src/internal/testenv/exec.go
index 9f21b323ab..7b251b6022 100644
--- a/src/internal/testenv/exec.go
+++ b/src/internal/testenv/exec.go
@@ -32,8 +32,12 @@ import (
// for the resulting error.
func MustHaveExec(t testing.TB) {
if err := tryExec(); err != nil {
+ msg := fmt.Sprintf("cannot exec subprocess on %s/%s: %v", runtime.GOOS, runtime.GOARCH, err)
+ if t == nil {
+ panic(msg)
+ }
t.Helper()
- t.Skipf("skipping test: cannot exec subprocess on %s/%s: %v", runtime.GOOS, runtime.GOARCH, err)
+ t.Skip("skipping test:", msg)
}
}
@@ -81,7 +85,11 @@ func Executable(t testing.TB) string {
exe, err := exePath()
if err != nil {
- t.Fatalf("os.Executable error: %v", err)
+ msg := fmt.Sprintf("os.Executable error: %v", err)
+ if t == nil {
+ panic(msg)
+ }
+ t.Fatal(msg)
}
return exe
}