From ff6a2d025a28f5aaca69eccf8bde0467f394d975 Mon Sep 17 00:00:00 2001 From: Qi Xiao Date: Sun, 21 Feb 2016 23:59:44 +0100 Subject: [PATCH] Fix failing tests. --- eval/error.go | 7 +++++++ eval/eval_test.go | 10 +++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/eval/error.go b/eval/error.go index 2b4370b9..f0bbf47c 100644 --- a/eval/error.go +++ b/eval/error.go @@ -117,9 +117,16 @@ func NewExternalCmdExit(ws syscall.WaitStatus, pid int) error { if ws.Exited() && ws.ExitStatus() == 0 { return nil } + if !ws.Stopped() { + pid = 0 + } return ExternalCmdExit{ws, pid} } +func FakeExternalCmdExit(exit int, sig syscall.Signal) ExternalCmdExit { + return ExternalCmdExit{syscall.WaitStatus(exit<<8 + int(sig)), 0} +} + func (exit ExternalCmdExit) Error() string { ws := exit.WaitStatus switch { diff --git a/eval/eval_test.go b/eval/eval_test.go index 7c16b4d9..8a1824bd 100644 --- a/eval/eval_test.go +++ b/eval/eval_test.go @@ -40,7 +40,8 @@ var evalTests = []struct { // Outputs of pipelines in a chunk are concatenated {"put x; put y; put z", strs("x", "y", "z"), nomore}, // A failed pipeline cause the whole chunk to fail - {"put a; false; put b", strs("a"), more{wantError: errors.New("1")}}, + {"put a; false; put b", strs("a"), more{ + wantError: FakeExternalCmdExit(1, 0)}}, // Pipelines. // Pure byte pipeline @@ -104,8 +105,11 @@ var evalTests = []struct { // Status capture {"put ?(true|false|false)", - []Value{newMultiError(OK, Error{errors.New("1")}, - Error{errors.New("1")})}, nomore}, + []Value{newMultiError( + OK, + Error{FakeExternalCmdExit(1, 0)}, + Error{FakeExternalCmdExit(1, 0)}, + )}, nomore}, // Variable and compounding {"x='SHELL'\nput 'WOW, SUCH '$x', MUCH COOL'\n",