aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorGravatar zinc <zinc@downsta.ir> 2026-10-14 15:43:59 +0330
committerGravatar zinc <zinc@downsta.ir> 2026-10-14 15:43:59 +0330
commit10e8a339b198b6e49e393c457cba7667a2a39ca5 (patch)
treef4888d23ce670a911a4e2822a8394f8ee00192ae /tests
parentmerge 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')
-rw-r--r--tests/drivers/cli_help_test.py2
-rwxr-xr-xtests/runerr.sh27
2 files changed, 20 insertions, 9 deletions
diff --git a/tests/drivers/cli_help_test.py b/tests/drivers/cli_help_test.py
index af3df2e..481d9c0 100644
--- a/tests/drivers/cli_help_test.py
+++ b/tests/drivers/cli_help_test.py
@@ -14,7 +14,7 @@ commands = []
if args.group in ('binaries', 'all'):
commands += [[str(Path(args.bin_dir) / name)] for name in ['zy', 'zym', 'zclsp', 'zc0', 'mkgenome', 'genmap']]
if args.group in ('scripts', 'all'):
- commands += [['bash', name] for name in ['tinyvm.sh', 'src/tools/zcc', 'src/tools/automap.sh', 'src/tools/findcc.sh', 'src/tools/bootstrap-check.sh', 'src/tools/parity.sh', 'src/tools/xref.sh', 'src/tools/mklsp.sh', 'src/tools/mklspwasm.sh', 'src/tools/mkvsix.sh', 'src/web/build.sh', 'src/baremetal/run.sh']]
+ commands += [['bash', name] for name in ['tinyvm.sh', 'src/tools/zcc', 'src/tools/automap.sh', 'src/tools/findcc.sh', 'src/tools/bootstrap-check.sh', 'src/tools/parity.sh', 'src/tools/xref.sh', 'src/tools/xref_selftest.sh', 'src/tools/mklsp.sh', 'src/tools/mklspwasm.sh', 'src/tools/mkvsix.sh', 'src/web/build.sh', 'src/baremetal/run.sh']]
if args.group in ('js', 'all'):
commands += [['node', name] for name in [str(Path(args.js_dir) / 'tinyvm.js'), 'src/js/mklayout.js', 'src/js/extract_lsp.js']]
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 ]