aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2025-12-27 19:08:26 -0500
committerGopher Robot <gobot@golang.org>2026-01-12 13:57:21 -0800
commitb7e6d8b923ad06538c800d635d3ede90d3d0b782 (patch)
tree5dae2631e01c55476115fd275cd9460969d2ef37
parentcbe153806e67a16e362a1cdbbf1741d4ce82e98a (diff)
downloadgo-b7e6d8b923ad06538c800d635d3ede90d3d0b782.tar.xz
os/exec_test: fix test on Plan 9
Error strings vary across OSes when trying to execute a file that does not exist. Since matching them is not the point of the test, ignore them. Fixes #76965 Change-Id: I6d220bc2d0289070f3441adb48983c13b2a3e597 Reviewed-on: https://go-review.googlesource.com/c/go/+/732940 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Richard Miller <millerresearch@gmail.com> Reviewed-by: Alan Donovan <adonovan@google.com> Auto-Submit: Alan Donovan <adonovan@google.com> Reviewed-by: Michael Pratt <mpratt@google.com>
-rw-r--r--src/os/exec/exec_test.go24
1 files changed, 7 insertions, 17 deletions
diff --git a/src/os/exec/exec_test.go b/src/os/exec/exec_test.go
index bf2f3da535..2746ad8783 100644
--- a/src/os/exec/exec_test.go
+++ b/src/os/exec/exec_test.go
@@ -1845,23 +1845,13 @@ func TestStart_twice(t *testing.T) {
testenv.MustHaveExec(t)
cmd := exec.Command("/bin/nonesuch")
- for i, want := range []string{
- cond(runtime.GOOS == "windows",
- `exec: "/bin/nonesuch": executable file not found in %PATH%`,
- "fork/exec /bin/nonesuch: no such file or directory"),
- "exec: already started",
- } {
- err := cmd.Start()
- if got := fmt.Sprint(err); got != want {
- t.Errorf("Start call #%d return err %q, want %q", i+1, got, want)
- }
+ if err := cmd.Start(); err == nil {
+ t.Fatalf("running invalid command succeeded")
}
-}
-
-func cond[T any](cond bool, t, f T) T {
- if cond {
- return t
- } else {
- return f
+ err := cmd.Start()
+ got := fmt.Sprint(err)
+ want := "exec: already started"
+ if got != want {
+ t.Fatalf("Start call returned err %q, want %q", got, want)
}
}