Skip to content

Commit

Permalink
flag: fix TestExitCode on Plan 9
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
0intro authored and Bryan C. Mills committed Apr 3, 2020
1 parent c4f875e commit e31d741
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/flag/flag_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"io/ioutil"
"os"
"os/exec"
"runtime"
"sort"
"strconv"
"strings"
Expand Down Expand Up @@ -599,6 +600,10 @@ func TestExitCode(t *testing.T) {
)
cmd.Run()
got := cmd.ProcessState.ExitCode()
// ExitCode is either 0 or 1 on Plan 9.
if runtime.GOOS == "plan9" && test.expectExit != 0 {
test.expectExit = 1
}
if got != test.expectExit {
t.Errorf("unexpected exit code for test case %+v \n: got %d, expect %d",
test, got, test.expectExit)
Expand Down

0 comments on commit e31d741

Please sign in to comment.