mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 13:27:36 +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:
parent
5ec139e728
commit
86f50aa74e
14 changed files with 177 additions and 128 deletions
|
@ -1,5 +1,7 @@
|
|||
#!/bin/sh
|
||||
|
||||
source test-commons.inc
|
||||
|
||||
rm -rf shell-test
|
||||
mkdir -p shell-test
|
||||
cd shell-test
|
||||
|
@ -7,11 +9,13 @@ cd shell-test
|
|||
time sleep 1 2>timeerr >timeout
|
||||
cat timeout
|
||||
# We cannot be sure about the values, so just assert that they're not empty.
|
||||
test -n "$(cat timeerr)" || echo "Failure: 'time' stderr output not redirected correctly" && exit 1
|
||||
test -e timeout || echo "Failure: 'time' stdout output not redirected correctly" && exit 1
|
||||
if not test -n "$(cat timeerr)" { fail "'time' stderr output not redirected correctly" }
|
||||
if not test -e timeout { fail "'time' stdout output not redirected correctly" }
|
||||
|
||||
time ls 2> /dev/null | head > timeout
|
||||
test -n "$(cat timeout)" || echo "Failure: 'time' stdout not piped correctly" && exit 1
|
||||
if not test -n "$(cat timeout)" { fail "'time' stdout not piped correctly" }
|
||||
|
||||
cd ..
|
||||
rm -rf shell-test # TODO: Remove this file at the end once we have `trap'
|
||||
|
||||
echo PASS
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue