diff options
author | AnotherTest <ali.mpfard@gmail.com> | 2021-01-18 10:08:30 +0330 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-01-19 08:19:43 +0100 |
commit | 86f50aa74ecf8917bfe78532ded60c0ffd4de536 (patch) | |
tree | 45ac042cb407903c3b54b3c99c084d77ae8b92fe /Userland/Shell/Tests/match.sh | |
parent | 5ec139e7280e6beca4a15d5ab7dc24fa105905ad (diff) | |
download | serenity-86f50aa74ecf8917bfe78532ded60c0ffd4de536.zip |
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.
Diffstat (limited to 'Userland/Shell/Tests/match.sh')
-rw-r--r-- | Userland/Shell/Tests/match.sh | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/Userland/Shell/Tests/match.sh b/Userland/Shell/Tests/match.sh index 1f1809166c..ff21227869 100644 --- a/Userland/Shell/Tests/match.sh +++ b/Userland/Shell/Tests/match.sh @@ -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 |