aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/meson.build4
-rw-r--r--test/multifile/input1.ttl2
-rw-r--r--test/multifile/input2.trig7
-rw-r--r--test/multifile/output.nq3
-rwxr-xr-xtest/test_multifile.py52
-rwxr-xr-xtest/test_stdin.py7
6 files changed, 74 insertions, 1 deletions
diff --git a/test/meson.build b/test/meson.build
index 6f6d7378..ac1fb205 100644
--- a/test/meson.build
+++ b/test/meson.build
@@ -89,6 +89,10 @@ if get_option('utils')
args: script_args,
suite: ['serdi', 'input'])
+ test('multiple', files('test_multifile.py'),
+ args: script_args + [meson.current_source_dir() / 'multifile'],
+ suite: ['serdi', 'input'])
+
test('string', serdi,
args: ['-s', '<foo> a <Bar> .'],
should_fail: true,
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 <http://example.org/Type> .
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 <http://example.org/Type> .
+
+<http://example.org/graph> {
+ []
+ a <http://example.org/OtherType> .
+}
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 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://example.org/Type> .
+_:f1b1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://example.org/Type> .
+_:f1b2 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://example.org/OtherType> <http://example.org/graph> .
diff --git a/test/test_multifile.py b/test/test_multifile.py
new file mode 100755
index 00000000..5fb44bc5
--- /dev/null
+++ b/test/test_multifile.py
@@ -0,0 +1,52 @@
+#!/usr/bin/env python3
+
+"""Test reading from several input files."""
+
+import argparse
+import difflib
+import os
+import shlex
+import subprocess
+import sys
+import tempfile
+
+parser = argparse.ArgumentParser(description=__doc__)
+
+parser.add_argument("--serdi", default="./serdi", help="path to serdi")
+parser.add_argument("--wrapper", default="", help="executable wrapper")
+parser.add_argument("testdir", help="multifile test directory")
+
+args = parser.parse_args(sys.argv[1:])
+in1_path = os.path.join(args.testdir, "input1.ttl")
+in2_path = os.path.join(args.testdir, "input2.trig")
+check_path = os.path.join(args.testdir, "output.nq")
+command = shlex.split(args.wrapper) + [args.serdi, in1_path, in2_path]
+
+
+def _show_diff(from_lines, to_lines, from_filename, to_filename):
+ same = True
+ for line in difflib.unified_diff(
+ from_lines,
+ to_lines,
+ fromfile=os.path.abspath(from_filename),
+ tofile=os.path.abspath(to_filename),
+ ):
+ sys.stderr.write(line)
+ same = False
+
+ return same
+
+
+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:
+
+ output_matches = _show_diff(
+ check.readlines(), out.readlines(), check_path, "output"
+ )
+
+ assert output_matches
diff --git a/test/test_stdin.py b/test/test_stdin.py
index 28286e09..9a27fcd9 100755
--- a/test/test_stdin.py
+++ b/test/test_stdin.py
@@ -14,7 +14,12 @@ parser.add_argument("--serdi", default="./serdi", help="path to serdi")
parser.add_argument("--wrapper", default="", help="executable wrapper")
args = parser.parse_args(sys.argv[1:])
-command = shlex.split(args.wrapper) + [args.serdi, "-"]
+command = shlex.split(args.wrapper) + [
+ args.serdi,
+ "-I",
+ "http://example.org",
+ "-",
+]
DOCUMENT = "<{0}s> <{0}p> <{0}o> .".format("http://example.org/")