1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 04:57:45 +00:00

Shell: Make tests use PASS/FAIL instead of exit codes

There's no guarantee that the last executed command will have a zero
exit code, and so the shell exit code may or may not be zero, even if
all the tests pass.
Also changes the `test || echo fail && exit` to
`if not test { echo fail && exit }`, since that's nicer-looking.
This commit is contained in:
AnotherTest 2021-01-18 10:08:30 +03:30 committed by Andreas Kling
parent 5ec139e728
commit 86f50aa74e
14 changed files with 177 additions and 128 deletions

View file

@ -1,5 +1,7 @@
#!/bin/sh
source test-commons.inc
# `head -n 1` should close stdout of the `Shell -c` command, which means the
# second echo should exit unsuccessfully and sigpipe.sh.out should not be
# created.
@ -10,4 +12,8 @@ rm -f sigpipe.sh.out
# Failing commands don't make the test fail, just an explicit `exit 1` does.
# So the test only fails if sigpipe.sh.out exists (since then `exit 1` runs),
# not if the `test` statement returns false.
test -e sigpipe.sh.out && exit 1
if test -e sigpipe.sh.out {
fail sigpipe did not terminate further commands
} else {
echo PASS
}