diff --git a/subprojects/wren/find_scripts.py b/subprojects/wren/find_scripts.py index eb0fc72..cf28a26 100755 --- a/subprojects/wren/find_scripts.py +++ b/subprojects/wren/find_scripts.py @@ -2,11 +2,16 @@ from pathlib import Path import sys +import os -if len(sys.argv) < 2: - sys.stderr.write("Please specify a search directory\n") +if len(sys.argv) < 3: + sys.stderr.write("Usage: {0} ...\n".format(sys.argv[0])) exit(2) -for search_path in sys.argv[1:]: - for path in Path(search_path).rglob('*.wren'): +prefix = sys.argv[1] +search_paths = sys.argv[2:] + +for search_path in search_paths: + curr_path = os.path.join(prefix, search_path) + for path in Path(curr_path).rglob('*.wren'): sys.stdout.write(str(path) + "\n") diff --git a/subprojects/wren/guess_test_outcome.py b/subprojects/wren/guess_test_outcome.py new file mode 100755 index 0000000..48386b7 --- /dev/null +++ b/subprojects/wren/guess_test_outcome.py @@ -0,0 +1,20 @@ +#!/usr/bin/env python + +import sys +import re + +if len(sys.argv) != 2: + sys.stderr.write("Please specify a file path\n") + exit(2) + +try: + my_file = open(sys.argv[1], mode='r') + text = my_file.read() + my_file.close() +except UnicodeDecodeError: + exit(0) + +if re.search(r"expect\s+(?:runtime\s+)?\berror", text): + exit(0) +else: + exit(1) diff --git a/subprojects/wren/meson.build b/subprojects/wren/meson.build index b356d86..48c7f46 100644 --- a/subprojects/wren/meson.build +++ b/subprojects/wren/meson.build @@ -67,6 +67,7 @@ wren_dep = declare_dependency( if get_option('build_testing') fs = import('fs') + test_src = [ 'wren/test/api/api_tests.c', 'wren/test/api/benchmark.c', @@ -101,8 +102,8 @@ if get_option('build_testing') endif test_scripts = run_command( - meson.current_source_dir() / 'find_scripts.py', - meson.current_source_dir(), + files('find_scripts.py'), + meson.current_source_dir() / 'wren/test', test_script_paths, ).stdout().strip().split('\n') @@ -115,8 +116,20 @@ if get_option('build_testing') ) foreach test_script : test_scripts + expects_fail = run_command( + files('guess_test_outcome.py'), + test_script, + ).returncode() == 0 + name = fs.stem(test_script) - test(meson.project_name() + ' test ' + name, test_api, args: files(test_script)) + test( + meson.project_name() + ' test ' + name, + test_api, + args: test_script, + is_parallel: true, + should_fail: expects_fail, + workdir: meson.current_source_dir() / 'wren', + ) endforeach endif