summaryrefslogtreecommitdiff
path: root/tools/check_output_test.py
diff options
context:
space:
mode:
authorRyan Dahl <ry@tinyclouds.org>2018-07-21 19:08:24 -0400
committerGitHub <noreply@github.com>2018-07-21 19:08:24 -0400
commitdff5c16e85b9ee7e610d17792f8c301af1a9c458 (patch)
treecdb3a7ab2c6e4a1d422776873bea95774ffbe806 /tools/check_output_test.py
parent709b0cb90cec938cbfd3d49ed1c35fa949bda36a (diff)
Add tools/test.py test runner. (#384)
Diffstat (limited to 'tools/check_output_test.py')
-rwxr-xr-xtools/check_output_test.py41
1 files changed, 41 insertions, 0 deletions
diff --git a/tools/check_output_test.py b/tools/check_output_test.py
new file mode 100755
index 000000000..c8b01952d
--- /dev/null
+++ b/tools/check_output_test.py
@@ -0,0 +1,41 @@
+#!/usr/bin/env python
+# Given a deno executable, this script execute several integration tests
+# with it. The tests are stored in //tests/ and each script has a corresponding
+# .out file which specifies what the stdout should be.
+#
+# Usage: check_output_test.py [path to deno executable]
+import os
+import sys
+import subprocess
+
+root_path = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
+tests_path = os.path.join(root_path, "tests")
+
+
+def check_output_test(deno_exe_filename):
+ assert os.path.isfile(deno_exe_filename)
+ outs = [
+ filename for filename in os.listdir(tests_path)
+ if filename.endswith(".out")
+ ]
+ assert len(outs) > 1
+ tests = [(os.path.splitext(filename)[0], filename) for filename in outs]
+ for (script, out_filename) in tests:
+ script_abs = os.path.join(tests_path, script)
+ out_abs = os.path.join(tests_path, out_filename)
+ with open(out_abs, 'r') as f:
+ expected_out = f.read()
+ cmd = [deno_exe_filename, script_abs]
+ print " ".join(cmd)
+ actual_out = subprocess.check_output(cmd)
+ if expected_out != actual_out:
+ print "Expected output does not match actual."
+ sys.exit(1)
+
+
+def main(argv):
+ check_output_test(argv[1])
+
+
+if __name__ == '__main__':
+ sys.exit(main(sys.argv))