go/analysis/internal/checker: allow for Plan 9 reduced exit codes in tests
Because process exit status in Plan 9 is a string, not a number,
the current Plan 9 implementation of ExitError.ExitCode returns
only 1 for any sort of failure, but some tests in this package
expect an exit code of 3. Make a special case for Plan 9 to allow
for exit codes being only 0 or 1.
Fixes golang/go#68290
Change-Id: Ie0c106f70620307a2a0ed89aec742ecdc8daeffc
Reviewed-on: https://go-review.googlesource.com/c/tools/+/596735
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Auto-Submit: Than McIntosh <thanm@google.com>
diff --git a/go/analysis/internal/checker/fix_test.go b/go/analysis/internal/checker/fix_test.go
index 45cbe2f..b169d79 100644
--- a/go/analysis/internal/checker/fix_test.go
+++ b/go/analysis/internal/checker/fix_test.go
@@ -13,6 +13,7 @@
"os/exec"
"path"
"regexp"
+ "runtime"
"strings"
"testing"
@@ -81,7 +82,10 @@
if err, ok := err.(*exec.ExitError); !ok {
t.Fatalf("failed to execute multichecker: %v", err)
} else if err.ExitCode() != wantExit {
- t.Errorf("exit code was %d, want %d", err.ExitCode(), wantExit)
+ // plan9 ExitCode() currently only returns 0 for success or 1 for failure
+ if !(runtime.GOOS == "plan9" && wantExit != exitCodeSuccess && err.ExitCode() != exitCodeSuccess) {
+ t.Errorf("exit code was %d, want %d", err.ExitCode(), wantExit)
+ }
}
return out
}