view run_tests.py @ 43:e45b81cdb4d0

Modified indentation to be 2 spaces instead of 4, as per Mozilla's JS style guidelines.
author Atul Varma <varmaa@toolness.com>
date Thu, 15 May 2008 23:42:23 -0700
parents 4b6b9ea26552
children
line wrap: on
line source

import glob
import os
import subprocess

JS_CMD = "js"

TESTS = glob.glob(os.path.join("tests", "*.js"))

OUTPUT_FILE = "test_output.txt"

def run_tests():
    for test in TESTS:
        output = open(OUTPUT_FILE, "w")
        subprocess.call(
            [JS_CMD, test],
            stdout = output,
            stderr = subprocess.STDOUT
            )
        output.close()

        expected_output_file = "tests/output/%s.txt" % (
            os.path.splitext(os.path.basename(test))[0]
            )

        lines = open(OUTPUT_FILE, "r").readlines()
        expected_lines = open(expected_output_file, "r").readlines()

        if lines != expected_lines:
            print 'Test "%s" failed.' % test
        else:
            print 'Test "%s" passed.' % test
    os.remove(OUTPUT_FILE)

if __name__ == "__main__":
    run_tests()