Esempio n. 1
0
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)
Esempio n. 2
0
 def test_parse_exit_code(self):
     assert 54 == parse_exit_code('hello_error54_world')
     assert 1 == parse_exit_code('hello_error_world')
     assert 0 == parse_exit_code('hello_world')
Esempio n. 3
0
 def test_parse_exit_code(self):
     assert parse_exit_code('hello_error54_world') == 54
     assert parse_exit_code('hello_error_world') == 1
     assert parse_exit_code('hello_world') == 0
Esempio n. 4
0
def parse_exit_code_test():
    print "Testing util.parse_exit_code()..."
    assert 54 == parse_exit_code('hello_error54_world')
    assert 1 == parse_exit_code('hello_error_world')
    assert 0 == parse_exit_code('hello_world')
Esempio n. 5
0
def parse_exit_code_test():
    print "Testing util.parse_exit_code()..."
    assert 54 == parse_exit_code('hello_error54_world')
    assert 1 == parse_exit_code('hello_error_world')
    assert 0 == parse_exit_code('hello_world')