Created
September 13, 2014 22:57
-
-
Save csaftoiu/1d2b87d4870cd0d65c64 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import subprocess | |
from clemtest_data import test_data | |
TMPF = "____tmptest_____" | |
def run_test(test_name, program, expected_out, stdin=''): | |
with open(TMPF, "wb") as f: | |
f.write(program) | |
p = subprocess.Popen(["python", "clemint.py", TMPF], | |
stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) | |
gold = subprocess.Popen(["./clem", TMPF], | |
stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) | |
out, err = p.communicate(stdin) | |
out = out.replace('\r\n', '\n') | |
expected_out, _ = gold.communicate(stdin) | |
if out != expected_out: | |
print "FAILED TEST %s" % (test_name,) | |
print "expected:\n%s\ngot:\n%s" % (`expected_out`, `out`) | |
#print err | |
else: | |
print "PASSED TEST %s" % (test_name,) | |
for suite, runs in test_data: | |
for i, test in enumerate(runs): | |
run_test("%s #%d" % (suite, i+1), *test) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment