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 <matloob@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Michael Matloob <matloob@golang.org>
This commit is contained in:
Michael Matloob 2022-11-18 14:33:23 -05:00
parent 6fc1f4f906
commit 7161fc737d
2 changed files with 8 additions and 4 deletions

View file

@ -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 {

View file

@ -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