view run_tests.py @ 85:7ddacb62f0e5

Fixed a bug in the error reporting mechanism raised by the black & white version of Photopia on if-archive.
author Atul Varma <varmaa@toolness.com>
date Wed, 21 May 2008 16:00:46 -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()