diff options
| author | 2026-10-15 17:03:03 +0330 | |
|---|---|---|
| committer | 2026-10-15 17:03:03 +0330 | |
| commit | 7cb983bbea98d2038b2a8015a6d1f1afd40991c9 (patch) | |
| tree | ec3d88a15801207fc6d8d3c6d142617ffec85460 /tests/drivers/hold_test.py | |
| parent | merge work/borrow: borrow returns before definition, borrows clause, borrow m... (diff) | |
| parent | bench: rss probe path fix (diff) | |
merge work/actors: wasm seed bootstrap (seed/MANIFEST), shared copy-on-write actor memory, top-level hold blocks on all backends and lsp
Diffstat (limited to 'tests/drivers/hold_test.py')
| -rw-r--r-- | tests/drivers/hold_test.py | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/drivers/hold_test.py b/tests/drivers/hold_test.py new file mode 100644 index 0000000..1f6ea39 --- /dev/null +++ b/tests/drivers/hold_test.py @@ -0,0 +1,28 @@ +#!/usr/bin/env python3 +# hold blocks (spec 4.16): accepted programs print what their first line expects, rejected +# ones report the error their first line names (exit 1), and trapping ones stop with +# exit 2 and the message named. usage: hold_test.py [VM] +from pathlib import Path +import subprocess, sys +root = Path(__file__).resolve().parents[2] +vm = sys.argv[1] if len(sys.argv) > 1 else 'build/bin/zy' +count = bad = 0 +for case in sorted((root / 'tests/hold').glob('*/*.zc')): + src = case.read_text(); first = src.splitlines()[0] + p = subprocess.run([str(root / vm) if not Path(vm).is_absolute() else vm], input=src, text=True, capture_output=True, cwd=root, timeout=60) + out = p.stdout + p.stderr + if first.startswith('// expect: '): + ok = p.returncode == 0 and p.stdout.strip() == first[11:].strip() + elif first.startswith('// error: '): + ok = p.returncode == 1 and first[10:].strip() in out + elif first.startswith('// trap: '): + ok = p.returncode == 2 and first[9:].strip() in out + else: + ok = False + count += 1 + if not ok: + bad += 1; print(f'FAIL {case.relative_to(root)}: rc={p.returncode} out={out[:300]!r}') + else: + print(f'ok {case.relative_to(root)}') +print(f'{count - bad}/{count} hold fixtures passed') +sys.exit(1 if bad or not count else 0) |
