1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 20:07:35 +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,21 +1,20 @@
#!/bin/sh
source test-commons.inc
setopt --verbose
fail() {
echo $*
exit 1
}
if not test "$(echo {a,b,})" = "a b " { fail normal brace expansion with one empty slot }
if not test "$(echo {a,,b})" = "a b" { fail normal brace expansion with one empty slot }
if not test "$(echo {a,,,b})" = "a b" { fail normal brace expansion with two empty slots }
if not test "$(echo {a,b,,})" = "a b " { fail normal brace expansion with two empty slots }
test "$(echo {a,b,})" = "a b " || fail normal brace expansion with one empty slot
test "$(echo {a,,b})" = "a b" || fail normal brace expansion with one empty slot
test "$(echo {a,,,b})" = "a b" || fail normal brace expansion with two empty slots
test "$(echo {a,b,,})" = "a b " || fail normal brace expansion with two empty slots
test "$(echo {a..c})" = "a b c" || fail range brace expansion, alpha
test "$(echo {0..3})" = "0 1 2 3" || fail range brace expansion, number
test "$(echo {😂..😄})" = "😂 😃 😄" || fail range brace expansion, unicode codepoint
if not test "$(echo {a..c})" = "a b c" { fail range brace expansion, alpha }
if not test "$(echo {0..3})" = "0 1 2 3" { fail range brace expansion, number }
if not test "$(echo {😂..😄})" = "😂 😃 😄" { fail range brace expansion, unicode codepoint }
# Make sure that didn't mess with dots and commas in normal barewords
test .. = ".." || fail range brace expansion delimiter affects normal barewords
test , = "," || fail normal brace expansion delimiter affects normal barewords
if not test .. = ".." { fail range brace expansion delimiter affects normal barewords }
if not test , = "," { fail normal brace expansion delimiter affects normal barewords }
echo PASS