From 4e1850852a74fe6904beabf793ea8d9915cab246 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Wed, 29 Mar 2023 23:34:40 -0400 Subject: Add support for reading multiple files at once --- test/meson.build | 8 ++++++++ test/multifile/input1.ttl | 2 ++ test/multifile/input2.trig | 7 +++++++ test/multifile/output.nq | 3 +++ test/test_multifile.py | 32 ++++++++++++++++++++++++++++++++ 5 files changed, 52 insertions(+) create mode 100644 test/multifile/input1.ttl create mode 100644 test/multifile/input2.trig create mode 100644 test/multifile/output.nq create mode 100755 test/test_multifile.py (limited to 'test') diff --git a/test/meson.build b/test/meson.build index fd8586a8..489a6ee5 100644 --- a/test/meson.build +++ b/test/meson.build @@ -18,6 +18,7 @@ simple_script_paths = [ 'run_suite.py', 'test_base.py', 'test_empty.py', + 'test_multifile.py', 'test_quiet.py', 'test_stdin.py', 'test_write_error.py', @@ -275,6 +276,13 @@ if is_variable('serd_pipe') env: test_env, suite: input_suite, ) + test( + 'multifile', + files('test_multifile.py'), + args: pipe_script_args + [meson.current_source_dir() / 'multifile'], + env: test_env, + suite: input_suite, + ) # Output diff --git a/test/multifile/input1.ttl b/test/multifile/input1.ttl new file mode 100644 index 00000000..88c3f8e9 --- /dev/null +++ b/test/multifile/input1.ttl @@ -0,0 +1,2 @@ +[] + a . diff --git a/test/multifile/input2.trig b/test/multifile/input2.trig new file mode 100644 index 00000000..260080a8 --- /dev/null +++ b/test/multifile/input2.trig @@ -0,0 +1,7 @@ +[] + a . + + { + [] + a . +} diff --git a/test/multifile/output.nq b/test/multifile/output.nq new file mode 100644 index 00000000..dd35dc4d --- /dev/null +++ b/test/multifile/output.nq @@ -0,0 +1,3 @@ +_:f0b1 . +_:f1b1 . +_:f1b2 . diff --git a/test/test_multifile.py b/test/test_multifile.py new file mode 100755 index 00000000..e8fa0775 --- /dev/null +++ b/test/test_multifile.py @@ -0,0 +1,32 @@ +#!/usr/bin/env python3 + +# Copyright 2019-2023 David Robillard +# SPDX-License-Identifier: ISC + +"""Test reading from several input files.""" + +# pylint: disable=duplicate-code + +import os +import shlex +import subprocess +import tempfile + +import serd_test_util as util + +args = util.wrapper_args(__doc__, True) +testdir = args.input +in1_path = os.path.join(testdir, "input1.ttl") +in2_path = os.path.join(testdir, "input2.trig") +check_path = os.path.join(testdir, "output.nq") +command = shlex.split(args.wrapper) + [args.tool, in1_path, in2_path] + + +with tempfile.TemporaryFile(mode="w+", encoding="utf-8") as out: + proc = subprocess.run(command, check=False, stdout=out) + + assert proc.returncode == 0 + + out.seek(0) + with open(check_path, "r", encoding="utf-8") as check: + assert util.lines_equal(list(check), list(out), check_path, "output") -- cgit v1.2.1