From 7d2183d13b298f33733e67184dd86a34a71723bf Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sat, 9 Jan 2021 19:17:31 +0100 Subject: Switch to Meson --- test/test_stdin.py | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100755 test/test_stdin.py (limited to 'test/test_stdin.py') 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 -- cgit v1.2.1