From e098617c2852440ffd4df5732114e4c49f5d1b7a Mon Sep 17 00:00:00 2001 From: Qi Xiao Date: Mon, 30 Mar 2020 23:48:07 +0100 Subject: [PATCH] pkg/eval: Fix test on BSD. --- pkg/eval/exception_unix_test.go | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/pkg/eval/exception_unix_test.go b/pkg/eval/exception_unix_test.go index fbeb0206..8906eb89 100644 --- a/pkg/eval/exception_unix_test.go +++ b/pkg/eval/exception_unix_test.go @@ -4,6 +4,7 @@ package eval import ( "fmt" + "runtime" "syscall" "testing" @@ -21,11 +22,15 @@ func TestExternalCmdExit_Error(t *testing.T) { tt.Args(ExternalCmdExit{0x82, "ls", 1}).Rets("ls killed by signal interrupt (core dumped)"), // 0x7f + signal<<8 for stopped tt.Args(ExternalCmdExit{0x27f, "ls", 1}).Rets("ls stopped by signal interrupt (pid=1)"), - // 0x057f + cause<<16 for trapped. SIGTRAP is 5 on all Unix'es but have - // different string representations on different OSes. - tt.Args(ExternalCmdExit{0x1057f, "ls", 1}).Rets(fmt.Sprintf( - "ls stopped by signal %s (pid=1) (trapped 1)", syscall.SIGTRAP)), - // 0xff is the only exit code that is not exited, signaled or stopped. - tt.Args(ExternalCmdExit{0xff, "ls", 1}).Rets("ls has unknown WaitStatus 255"), }) + if runtime.GOOS == "linux" { + tt.Test(t, tt.Fn("Error", error.Error), tt.Table{ + // 0x057f + cause<<16 for trapped. SIGTRAP is 5 on all Unix'es but have + // different string representations on different OSes. + tt.Args(ExternalCmdExit{0x1057f, "ls", 1}).Rets(fmt.Sprintf( + "ls stopped by signal %s (pid=1) (trapped 1)", syscall.SIGTRAP)), + // 0xff is the only exit code that is not exited, signaled or stopped. + tt.Args(ExternalCmdExit{0xff, "ls", 1}).Rets("ls has unknown WaitStatus 255"), + }) + } }