From: Michael Matloob Date: Fri, 18 Nov 2022 19:33:23 +0000 (-0500) Subject: cmd/go/internal/script: check lack of error for non-waiting cmds X-Git-Tag: go1.20rc1~157 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=7161fc737dab823f94d77810953493a0f458284f;p=gostls13.git cmd/go/internal/script: check lack of error for non-waiting cmds In the script engine, if a command does not return a Wait function and it succeeds, we won't call checkStatus. That means that commands that don't have a wait function, have a "!" indicating that they are supposed to fail, and then succeed will spuriously not fail the script engine test even they were supposed to fail but didn't. Change-Id: Ic88c3cdd628064d48f14a8a4a2e97cded48890fb Reviewed-on: https://go-review.googlesource.com/c/go/+/451284 Reviewed-by: Michael Matloob Reviewed-by: Bryan Mills TryBot-Result: Gopher Robot Run-TryBot: Michael Matloob --- diff --git a/src/cmd/go/internal/script/engine.go b/src/cmd/go/internal/script/engine.go index 88b10228c7..dfce755522 100644 --- a/src/cmd/go/internal/script/engine.go +++ b/src/cmd/go/internal/script/engine.go @@ -564,11 +564,14 @@ func (e *Engine) runCommand(s *State, cmd *command, impl Cmd) error { } wait, runErr := impl.Run(s, cmd.args...) - if runErr != nil { + if wait == nil { + if async && runErr == nil { + return cmdError(cmd, errors.New("internal error: async command returned a nil WaitFunc")) + } return checkStatus(cmd, runErr) } - if async && wait == nil { - return cmdError(cmd, errors.New("internal error: async command returned a nil WaitFunc")) + if runErr != nil { + return cmdError(cmd, errors.New("internal error: command returned both an error and a WaitFunc")) } if cmd.background { diff --git a/src/cmd/go/testdata/script/list_issue_56509.txt b/src/cmd/go/testdata/script/list_issue_56509.txt index d0ed9e4517..b402b2b397 100644 --- a/src/cmd/go/testdata/script/list_issue_56509.txt +++ b/src/cmd/go/testdata/script/list_issue_56509.txt @@ -4,9 +4,10 @@ # leading the package matching code to think there were Go files in the # directory.) +cd bar go list ./... ! stdout . - +cd .. [short] skip