diff options
Diffstat (limited to 'test/run_suite.py')
-rwxr-xr-x | test/run_suite.py | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/test/run_suite.py b/test/run_suite.py index 2e93502f..84c74dd1 100755 --- a/test/run_suite.py +++ b/test/run_suite.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 -# Copyright 2022-2023 David Robillard <d@drobilla.net> +# Copyright 2022-2025 David Robillard <d@drobilla.net> # SPDX-License-Identifier: ISC """Run a "simple" one-pass RDF-based test suite for serd.""" @@ -43,7 +43,7 @@ def run_eval_test(base_uri, command, in_path, good_path, out_path): syntax = util.syntax_from_path(out_path) command = command + ["-o", syntax, in_path, base_uri] - with subprocess.Popen(command, stdout=PIPE, encoding="utf-8") as proc: + with subprocess.Popen(command, encoding="utf-8", stdout=PIPE) as proc: out = list(proc.stdout) with open(good_path, "r", encoding="utf-8") as good: @@ -58,19 +58,25 @@ def run_positive_test(base_uri, command, in_path): return True -def run_negative_test(base_uri, command, in_path): +def run_negative_test(base_uri, command, in_path, ignore): """Run a negative syntax test and return whether the error was detected.""" if not os.path.exists(in_path): raise RuntimeError("Input file missing: " + in_path) command = command + [in_path, base_uri] - proc = subprocess.run(command, check=False, stderr=PIPE, stdout=DEVNULL) + proc = subprocess.run( + command, check=False, encoding="utf-8", stderr=PIPE, stdout=DEVNULL + ) - if proc.returncode == 0: + if not ignore and proc.returncode == 0: util.error("Unexpected successful return: " + in_path) return False + if proc.returncode < 0: + util.error("Command seems to have crashed: " + in_path) + return False + if len(proc.stderr) == 0: util.error("Command failed with no error output: " + in_path) return False @@ -86,7 +92,7 @@ def run_entry(args, entry, command, out_dir, suite_dir): negative = "Negative" in entry[NS_RDF + "type"][0] if negative and not args.lax: - return run_negative_test(base, command, in_path) + return run_negative_test(base, command, in_path, args.ignore) if NS_MF + "result" not in entry: return run_positive_test(base, command, in_path) @@ -151,6 +157,7 @@ def main(): ) parser.add_argument("--asserter", help="asserter URI for test report") + parser.add_argument("--ignore", action="store_true", help="ignore status") parser.add_argument("--lax", action="store_true", help="tolerate errors") parser.add_argument("--report", help="path to write result report to") parser.add_argument("--reverse", action="store_true", help="reverse test") |