From: Ori Bernstein Date: Sun, 28 Dec 2025 00:08:26 +0000 (-0500) Subject: os/exec_test: fix test on Plan 9 X-Git-Tag: go1.26rc3~11^2~17 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=b7e6d8b923ad06538c800d635d3ede90d3d0b782;p=gostls13.git 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 --- 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) } }