summaryrefslogtreecommitdiff
path: root/tools/integration_tests.py
diff options
context:
space:
mode:
authorKevin (Kun) "Kassimo" Qian <kevinkassimo@gmail.com>2019-05-03 13:24:09 -0700
committerRyan Dahl <ry@tinyclouds.org>2019-05-03 16:24:09 -0400
commit36081171323e266760db8bed2f31a6e3be7d8839 (patch)
tree6f4dc276656c7b119fc5efad5368e847f9cf7f19 /tools/integration_tests.py
parent401a5c021141d4ba5a71078b28f6daefcd1826a6 (diff)
feat(cli cmd): deno xeval (#2260)
Diffstat (limited to 'tools/integration_tests.py')
-rwxr-xr-xtools/integration_tests.py22
1 files changed, 20 insertions, 2 deletions
diff --git a/tools/integration_tests.py b/tools/integration_tests.py
index 5c3b24f75..32a53e3f7 100755
--- a/tools/integration_tests.py
+++ b/tools/integration_tests.py
@@ -65,6 +65,12 @@ def integration_tests(deno_exe, test_filter=None):
stderr = subprocess.STDOUT if check_stderr else open(os.devnull, 'w')
+ stdin_input = (test.get("input",
+ "").strip().decode("string_escape").replace(
+ "\r\n", "\n"))
+
+ has_stdin_input = len(stdin_input) > 0
+
output_abs = os.path.join(root_path, test.get("output", ""))
with open(output_abs, 'r') as f:
expected_out = f.read()
@@ -73,8 +79,20 @@ def integration_tests(deno_exe, test_filter=None):
sys.stdout.flush()
actual_code = 0
try:
- actual_out = subprocess.check_output(
- cmd, universal_newlines=True, stderr=stderr)
+ if has_stdin_input:
+ # Provided stdin
+ proc = subprocess.Popen(
+ cmd,
+ stdin=subprocess.PIPE,
+ stdout=subprocess.PIPE,
+ stderr=stderr)
+ actual_out, _ = proc.communicate(stdin_input)
+ actual_out = actual_out.replace("\r\n", "\n")
+ else:
+ # No stdin sent
+ actual_out = subprocess.check_output(
+ cmd, universal_newlines=True, stderr=stderr)
+
except subprocess.CalledProcessError as e:
actual_code = e.returncode
actual_out = e.output