aboutsummaryrefslogtreecommitdiff
path: root/tests/runerr.sh
blob: f7e668cbd036fef140564d19fcc1e2d2ba552278 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
#!/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
done
echo "rejected: $pass passed, $fail failed"