aboutsummaryrefslogtreecommitdiffstats
path: root/test/test_stdin.py
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2022-06-27 12:59:34 -0400
committerDavid Robillard <d@drobilla.net>2022-07-10 13:39:53 -0400
commit5e78edf6e09373938a796cf44fb38d2309d04b4d (patch)
treee80618e5e092dcb3d9501a2568cf67489fe3d1bd /test/test_stdin.py
parentbcc1c936b15782d8fa59e2ebf471cf686527135c (diff)
downloadserd-5e78edf6e09373938a796cf44fb38d2309d04b4d.tar.gz
serd-5e78edf6e09373938a796cf44fb38d2309d04b4d.tar.bz2
serd-5e78edf6e09373938a796cf44fb38d2309d04b4d.zip
Switch to meson build system
Diffstat (limited to 'test/test_stdin.py')
-rwxr-xr-xtest/test_stdin.py38
1 files changed, 38 insertions, 0 deletions
diff --git a/test/test_stdin.py b/test/test_stdin.py
new file mode 100755
index 00000000..84b6a8b2
--- /dev/null
+++ b/test/test_stdin.py
@@ -0,0 +1,38 @@
+#!/usr/bin/env python3
+
+"""Test reading from stdin with serdi."""
+
+import argparse
+import sys
+import shlex
+import subprocess
+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")
+
+args = parser.parse_args(sys.argv[1:])
+command = shlex.split(args.wrapper) + [args.serdi, "-"]
+
+DOCUMENT = "<{0}s> <{0}p> <{0}o> .".format("http://example.org/")
+
+with tempfile.TemporaryFile() as out:
+ proc = subprocess.run(
+ command,
+ check=False,
+ encoding="utf-8",
+ input=DOCUMENT,
+ stdout=out,
+ stderr=subprocess.PIPE,
+ )
+
+ assert proc.returncode == 0
+ assert args.wrapper or len(proc.stderr) == 0
+
+ out.seek(0)
+ lines = out.readlines()
+
+ assert len(lines) == 1
+ assert lines[0].decode("utf-8").strip() == DOCUMENT