aboutsummaryrefslogtreecommitdiffstats
path: root/test/run_suite.py
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2023-03-31 17:17:41 -0400
committerDavid Robillard <d@drobilla.net>2023-12-02 18:49:08 -0500
commitb5956c4dc6b065d664908104d5fc6752a87e3364 (patch)
tree6be1fa515891e759092bb9bea082e27c78bfb6de /test/run_suite.py
parent439d6ec3d6dfbea74334beace790f500e61c9b7d (diff)
downloadserd-b5956c4dc6b065d664908104d5fc6752a87e3364.tar.gz
serd-b5956c4dc6b065d664908104d5fc6752a87e3364.tar.bz2
serd-b5956c4dc6b065d664908104d5fc6752a87e3364.zip
Add model and serd-sort utility
With all the new functionality, the complexity of the serd-pipe command-line interface is starting to push the limits of available flags. So, instead of grafting on further options to control a model, this commit adds a new tool, serd-sort, which acts somewhat like a stripped-down serd-pipe that stores statements in a model in memory. This keeps the complexity (including the user-facing complexity) of any one tool down, since other more focused tools can be used for streaming tasks in a pipeline. In other words, abandon Swissarmyknifeism, take a page from the Unix philosophy, and try to expose the model functionality to the command-line in a dedicated focused tool. The model implementation is tested by using this tool to run a subset of the usual test suites, and a special suite to test statement sorting.
Diffstat (limited to 'test/run_suite.py')
-rwxr-xr-xtest/run_suite.py16
1 files changed, 12 insertions, 4 deletions
diff --git a/test/run_suite.py b/test/run_suite.py
index 463e40c4..aa95b90f 100755
--- a/test/run_suite.py
+++ b/test/run_suite.py
@@ -37,7 +37,7 @@ TEST_TYPES = [
]
-def run_eval_test(command, in_path, good_path, out_path):
+def run_eval_test(command, in_path, good_path, out_path, getlines):
"""Run a positive eval test and return whether the output matches."""
command = command + ["-o", out_path, in_path]
@@ -45,7 +45,9 @@ def run_eval_test(command, in_path, good_path, out_path):
with open(good_path, "r", encoding="utf-8") as good:
with open(out_path, "r", encoding="utf-8") as out:
- return util.lines_equal(list(good), list(out), good_path, out_path)
+ return util.lines_equal(
+ getlines(good), getlines(out), good_path, out_path
+ )
def run_positive_test(command, in_path):
@@ -93,8 +95,13 @@ def run_entry(args, entry, command, out_dir, suite_dir):
if args.reverse:
in_path, good_path = good_path, in_path
- out_path = os.path.join(out_dir, os.path.basename(good_path))
- return run_eval_test(command, in_path, good_path, out_path)
+ return run_eval_test(
+ command,
+ in_path,
+ good_path,
+ os.path.join(out_dir, os.path.basename(good_path)),
+ lambda f: sorted(set(f)) if args.unique else list(f),
+ )
def run_suite(args, command, out_dir):
@@ -154,6 +161,7 @@ def main():
parser.add_argument("--report", help="path to write result report to")
parser.add_argument("--reverse", action="store_true", help="reverse test")
parser.add_argument("--tool", default="tools/serd-pipe", help="executable")
+ parser.add_argument("--unique", action="store_true", help="sort lines")
parser.add_argument("--wrapper", default="", help="executable wrapper")
parser.add_argument("manifest", help="test suite manifest.ttl file")
parser.add_argument("base_uri", help="base URI for tests")