From b7e6d8b923ad06538c800d635d3ede90d3d0b782 Mon Sep 17 00:00:00 2001 From: Ori Bernstein Date: Sat, 27 Dec 2025 19:08:26 -0500 Subject: [PATCH] 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 Reviewed-by: Richard Miller Reviewed-by: Alan Donovan Auto-Submit: Alan Donovan Reviewed-by: Michael Pratt --- src/os/exec/exec_test.go | 24 +++++++----------------- 1 file 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) } } -- 2.52.0