Fix failing tests.

This commit is contained in:
Qi Xiao 2016-02-21 23:59:44 +01:00
parent f77fd16a6c
commit ff6a2d025a
2 changed files with 14 additions and 3 deletions

View File

@ -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 {

View File

@ -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",