diff options
| author | 2026-10-14 15:43:59 +0330 | |
|---|---|---|
| committer | 2026-10-14 15:43:59 +0330 | |
| commit | 10e8a339b198b6e49e393c457cba7667a2a39ca5 (patch) | |
| tree | f4888d23ce670a911a4e2822a8394f8ee00192ae /tests/runerr.sh | |
| parent | merge xref report: baseline, --check, self-test (diff) | |
xref self-test: a real write in a compiler copy, reject unknown options; runerr.sh runs every folder it is given
Diffstat (limited to 'tests/runerr.sh')
| -rwxr-xr-x | tests/runerr.sh | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/tests/runerr.sh b/tests/runerr.sh index f7e668c..b3767ae 100755 --- a/tests/runerr.sh +++ b/tests/runerr.sh @@ -1,10 +1,21 @@ #!/bin/bash -# runs every .zc in a folder (tests/errors by default) and checks the compiler -# rejects it with the message on its first `// expect: ...` line -vm=${1:-zy}; dir=${2:-$(dirname "$0")/errors}; pass=0; fail=0 -for f in "$dir"/*.zc; do - want=$(grep -m1 '^// expect: ' "$f" | sed 's#^// expect: ##') - got=$($vm < "$f" 2>&1 | head -1) - if [[ "$got" == *"$want"* ]]; then pass=$((pass+1)); else fail=$((fail+1)); echo "FAIL $(basename $f): got [$got]"; fi +# runs every .zc in one or more folders (tests/errors by default) and checks the +# compiler rejects it with the message on its first `// expect: ...` line. +# usage: tests/runerr.sh [VM] [DIR...]. with several folders each gets its own line +# and the last line is the total; exits 1 when any file fails. +vm=${1:-zy}; shift +[ $# -gt 0 ] || set -- "$(dirname "$0")/errors" +tpass=0; tfail=0 +for dir in "$@"; do + pass=0; fail=0 + if [ ! -d "$dir" ]; then echo "FAIL $dir: no such folder"; tfail=$((tfail+1)); continue; fi + for f in "$dir"/*.zc; do + want=$(grep -m1 '^// expect: ' "$f" | sed 's#^// expect: ##') + got=$($vm < "$f" 2>&1 | head -1) + if [[ "$got" == *"$want"* ]]; then pass=$((pass+1)); else fail=$((fail+1)); echo "FAIL $(basename $f): got [$got]"; fi + done + [ $# -gt 1 ] && echo "rejected in $dir: $pass passed, $fail failed" + tpass=$((tpass+pass)); tfail=$((tfail+fail)) done -echo "rejected: $pass passed, $fail failed" +echo "rejected: $tpass passed, $tfail failed" +[ $tfail = 0 ] |
