]> Cypherpunks repositories - gostls13.git/commitdiff
os/exec_test: fix test on Plan 9
authorOri Bernstein <ori@eigenstate.org>
Sun, 28 Dec 2025 00:08:26 +0000 (19:08 -0500)
committerGopher Robot <gobot@golang.org>
Mon, 12 Jan 2026 21:57:21 +0000 (13:57 -0800)
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>
src/os/exec/exec_test.go

index bf2f3da535b8eb13a75099759ba6a26a983c2bcd..2746ad8783ab2264d5375da64b2aa719fdf96b7b 100644 (file)
@@ -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)
        }
 }