diff options
Diffstat (limited to 'src/os/exec/exec_test.go')
| -rw-r--r-- | src/os/exec/exec_test.go | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/os/exec/exec_test.go b/src/os/exec/exec_test.go index 1decebdc22..bf2f3da535 100644 --- a/src/os/exec/exec_test.go +++ b/src/os/exec/exec_test.go @@ -1839,3 +1839,29 @@ func TestAbsPathExec(t *testing.T) { } }) } + +// Calling Start twice is an error, regardless of outcome. +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) + } + } +} + +func cond[T any](cond bool, t, f T) T { + if cond { + return t + } else { + return f + } +} |
