Skip to content

Commit e31d741

Browse files
0introBryan C. Mills
authored and
Bryan C. Mills
committed
flag: fix TestExitCode on Plan 9
CL 221427 added TestExitCode. This test is failing on Plan 9 because ExitCode is always equal to 1 on error since Plan 9 use error strings. This change fixes TestExitCode by checking that ExitCode is equal to 1 on error instead of the specific value. Fixes #38237. Change-Id: Ie269722e731e275e5bfc51644c1fa6be76525f1f Reviewed-on: https://go-review.googlesource.com/c/go/+/227158 Run-TryBot: David du Colombier <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Bryan C. Mills <[email protected]>
1 parent c4f875e commit e31d741

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/flag/flag_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"io/ioutil"
1414
"os"
1515
"os/exec"
16+
"runtime"
1617
"sort"
1718
"strconv"
1819
"strings"
@@ -599,6 +600,10 @@ func TestExitCode(t *testing.T) {
599600
)
600601
cmd.Run()
601602
got := cmd.ProcessState.ExitCode()
603+
// ExitCode is either 0 or 1 on Plan 9.
604+
if runtime.GOOS == "plan9" && test.expectExit != 0 {
605+
test.expectExit = 1
606+
}
602607
if got != test.expectExit {
603608
t.Errorf("unexpected exit code for test case %+v \n: got %d, expect %d",
604609
test, got, test.expectExit)

0 commit comments

Comments
 (0)