1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 22:17:44 +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,12 +1,14 @@
#!/bin/Shell
source test-commons.inc
result=no
match hello {
he* { result=yes }
* { result=fail }
};
test "$result" = yes || echo invalid result $result for normal string match, single option && exit 1
if not test "$result" = yes { fail invalid result $result for normal string match, single option }
result=no
match hello {
@ -14,7 +16,7 @@ match hello {
* { result=fail }
};
test "$result" = yes || echo invalid result $result for normal string match, multiple options && exit 1
if not test "$result" = yes { fail invalid result $result for normal string match, multiple options }
result=no
match (well hello friends) {
@ -23,7 +25,7 @@ match (well hello friends) {
* { result=fail }
};
test "$result" = yes || echo invalid result $result for list match && exit 1
if not test "$result" = yes { fail invalid result $result for list match }
result=no
match yes as v {
@ -32,7 +34,7 @@ match yes as v {
* { result=$v }
};
test "$result" = yes || echo invalid result $result for match with name && exit 1
if not test "$result" = yes { fail invalid result $result for match with name }
result=no
# $(...) is a list, $(echo) should be an empty list, not an empty string
@ -41,7 +43,7 @@ match $(echo) {
() { result=yes }
};
test "$result" = yes || echo invalid result $result for list subst match && exit 1
if not test "$result" = yes { fail invalid result $result for list subst match }
result=no
# "$(...)" is a string, "$(echo)" should be an empty string, not an empty list
@ -50,7 +52,7 @@ match "$(echo)" {
() { result=fail }
};
test "$result" = yes || echo invalid result $result for string subst match && exit 1
if not test "$result" = yes { fail invalid result $result for string subst match }
match (foo bar) {
(f? *) as (x y) {
@ -65,7 +67,7 @@ match (foo bar) {
}
}
test "$result" = yes || echo invalid result $result for subst match with name && exit 1
if not test "$result" = yes { fail invalid result $result for subst match with name }
match (foo bar baz) {
(f? * *z) as (x y z) {
@ -80,4 +82,6 @@ match (foo bar baz) {
}
}
test "$result" = yes || echo invalid result $result for subst match with name 2 && exit 1
if not test "$result" = yes { fail invalid result $result for subst match with name 2 }
echo PASS