summaryrefslogtreecommitdiff
path: root/tools/check_output_test.py
diff options
context:
space:
mode:
authorKitson Kelly <me@kitsonkelly.com>2018-11-05 06:52:31 +1100
committerRyan Dahl <ry@tinyclouds.org>2018-11-04 11:52:31 -0800
commit4e07783663d51877e7d41465cf5ef10d1540c4b3 (patch)
treef02336f4f46e8330362f1409d1c298db50dcc98a /tools/check_output_test.py
parente93d686e9d5e797f7e4e02bda56a8b6d535326ca (diff)
Improve integration test harness (#1142)
Diffstat (limited to 'tools/check_output_test.py')
-rwxr-xr-xtools/check_output_test.py63
1 files changed, 0 insertions, 63 deletions
diff --git a/tools/check_output_test.py b/tools/check_output_test.py
deleted file mode 100755
index b2169c12b..000000000
--- a/tools/check_output_test.py
+++ /dev/null
@@ -1,63 +0,0 @@
-#!/usr/bin/env python
-# Copyright 2018 the Deno authors. All rights reserved. MIT license.
-# 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
-from util import pattern_match, parse_exit_code
-
-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 = sorted([
- 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, "--reload"]
- expected_code = parse_exit_code(script)
- print " ".join(cmd)
- actual_code = 0
- try:
- actual_out = subprocess.check_output(cmd, universal_newlines=True)
- except subprocess.CalledProcessError as e:
- actual_code = e.returncode
- actual_out = e.output
- if expected_code == 0:
- print "Expected success but got error. Output:"
- print actual_out
- sys.exit(1)
-
- if expected_code != actual_code:
- print "Expected exit code %d but got %d" % (expected_code,
- actual_code)
- print "Output:"
- print actual_out
- sys.exit(1)
-
- if pattern_match(expected_out, actual_out) != True:
- print "Expected output does not match actual."
- print "Expected: " + expected_out
- print "Actual: " + actual_out
- sys.exit(1)
-
-
-def main(argv):
- check_output_test(argv[1])
-
-
-if __name__ == '__main__':
- sys.exit(main(sys.argv))