Skip to content

Commit 3968e70

Browse files
millerresearchgopherbot
authored andcommitted
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 <[email protected]> Reviewed-by: Robert Findley <[email protected]> Reviewed-by: Than McIntosh <[email protected]> Auto-Submit: Than McIntosh <[email protected]>
1 parent 33be3ef commit 3968e70

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

go/analysis/internal/checker/fix_test.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"os/exec"
1414
"path"
1515
"regexp"
16+
"runtime"
1617
"strings"
1718
"testing"
1819

@@ -81,7 +82,10 @@ func fix(t *testing.T, dir, analyzers string, wantExit int, patterns ...string)
8182
if err, ok := err.(*exec.ExitError); !ok {
8283
t.Fatalf("failed to execute multichecker: %v", err)
8384
} else if err.ExitCode() != wantExit {
84-
t.Errorf("exit code was %d, want %d", err.ExitCode(), wantExit)
85+
// plan9 ExitCode() currently only returns 0 for success or 1 for failure
86+
if !(runtime.GOOS == "plan9" && wantExit != exitCodeSuccess && err.ExitCode() != exitCodeSuccess) {
87+
t.Errorf("exit code was %d, want %d", err.ExitCode(), wantExit)
88+
}
8589
}
8690
return out
8791
}

0 commit comments

Comments
 (0)