From e31d741801514f2a008625fd246644d2214f4516 Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Fri, 3 Apr 2020 18:57:46 +0200 Subject: 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 <0intro@gmail.com> TryBot-Result: Gobot Gobot Reviewed-by: Bryan C. Mills --- src/flag/flag_test.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/flag/flag_test.go b/src/flag/flag_test.go index a7450f3f48..a01a5e4cea 100644 --- a/src/flag/flag_test.go +++ b/src/flag/flag_test.go @@ -13,6 +13,7 @@ import ( "io/ioutil" "os" "os/exec" + "runtime" "sort" "strconv" "strings" @@ -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) -- cgit v1.2.3-54-g00ecf