]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go/internal/script: check lack of error for non-waiting cmds
authorMichael Matloob <matloob@golang.org>
Fri, 18 Nov 2022 19:33:23 +0000 (14:33 -0500)
committerMichael Matloob <matloob@golang.org>
Fri, 18 Nov 2022 21:02:24 +0000 (21:02 +0000)
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>

src/cmd/go/internal/script/engine.go
src/cmd/go/testdata/script/list_issue_56509.txt

index 88b10228c70d98a16733b005e127ea2b48676af3..dfce75552223db2f9f857b7a5cbc7646b9e0e6a5 100644 (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 {
index d0ed9e4517540db1c9e56d08a6e05b0309d63497..b402b2b3973c796037134608f5a940625a33e053 100644 (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