aboutsummaryrefslogtreecommitdiff
path: root/src/os/exec/exec_test.go
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2022-05-03 15:14:56 -0400
committerJulie Qiu <julieqiu@google.com>2022-05-10 17:29:08 +0000
commit960ffa98ce73ef2c2060c84c7ac28d37a83f345e (patch)
tree6834dd92b303ef396e95837b691c15b5a451e726 /src/os/exec/exec_test.go
parent7a574ff23f9cda0967fd63a55c897e7598b60ad2 (diff)
downloadgo-960ffa98ce73ef2c2060c84c7ac28d37a83f345e.tar.xz
os/exec: return clear error for missing cmd.Path
Following up on CL 403694, there is a bit of confusion about when Path is and isn't set, along with now the exported Err field. Catch the case where Path and Err (and lookPathErr) are all unset and give a helpful error. Fixes #52574 Followup after #43724. Change-Id: I03205172aef3801c3194f5098bdb93290c02b1b6 Reviewed-on: https://go-review.googlesource.com/c/go/+/403759 Reviewed-by: Bryan Mills <bcmills@google.com> Reviewed-by: Roland Shoemaker <roland@golang.org>
Diffstat (limited to 'src/os/exec/exec_test.go')
-rw-r--r--src/os/exec/exec_test.go8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/os/exec/exec_test.go b/src/os/exec/exec_test.go
index c593cbd11d..9cc14bdaca 100644
--- a/src/os/exec/exec_test.go
+++ b/src/os/exec/exec_test.go
@@ -1125,3 +1125,11 @@ func TestStringPathNotResolved(t *testing.T) {
t.Errorf("String(%q, %q) = %q, want %q", "makemeasandwich", "-lettuce", got, want)
}
}
+
+func TestNoPath(t *testing.T) {
+ err := new(exec.Cmd).Start()
+ want := "exec: no command"
+ if err == nil || err.Error() != want {
+ t.Errorf("new(Cmd).Start() = %v, want %q", err, want)
+ }
+}