blob: b3767ae93f737f797017660ede6a732b9fb0b5d9 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
#!/bin/bash
# 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: $tpass passed, $tfail failed"
[ $tfail = 0 ]
|