aboutsummaryrefslogtreecommitdiff
path: root/tests/drivers/icon_test.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/drivers/icon_test.py')
-rw-r--r--tests/drivers/icon_test.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/drivers/icon_test.py b/tests/drivers/icon_test.py
new file mode 100644
index 0000000..560c622
--- /dev/null
+++ b/tests/drivers/icon_test.py
@@ -0,0 +1,32 @@
+#!/usr/bin/env python3
+# execute isolated icon acceptance, rejection and regression fixtures.
+from pathlib import Path
+import argparse
+import subprocess
+
+parser = argparse.ArgumentParser()
+parser.add_argument('vm', nargs='?', default='bin/zy')
+parser.add_argument('--case', default='')
+parser.add_argument('--js', action='store_true')
+parser.add_argument('--source', action='store_true', help='test the working library source instead of the embedded module')
+args = parser.parse_args()
+root = Path(__file__).resolve().parents[2]
+cases = sorted((root / 'tests/icon').glob('*/*.zc'))
+count = 0
+for case in cases:
+ if args.case and args.case not in str(case):
+ continue
+ expected = case.with_suffix('.expected').read_text()
+ command = ['node', str(root / 'src/js/tinyvm.js')] if args.js else [str(root / args.vm)]
+ program = case.read_text()
+ if args.source:
+ # keep module imports while suppressing its embedded source loader.
+ library = (root / 'src/lib/icon.zc').read_text()
+ setup = '\nnamespace;\ninclude run;\nimmediate fn icon_working_source() { run.icon_done = 1; run.next(); return 0; }\nicon_working_source\n'
+ program = library + setup + program
+ proc = subprocess.run(command, input=program, text=True, capture_output=True, cwd=root, timeout=30)
+ assert proc.returncode == 0 and proc.stdout == expected, f'{case.relative_to(root)}\nstdout: {proc.stdout}\nstderr: {proc.stderr}\nexpected: {expected}'
+ print(f'ok {case.relative_to(root)}')
+ count += 1
+assert count, 'no icon fixtures selected'
+print(f'{count} icon fixtures passed')