-
Notifications
You must be signed in to change notification settings - Fork 1
/
test
executable file
·50 lines (45 loc) · 1.66 KB
/
test
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/python
import os
import subprocess
import time
def call(command):
subprocess.call(command, shell = True)
def print_info(start, passed_tests, failed_tests, color):
total_tests = passed_tests + failed_tests
print color + str(passed_tests) + ' tests passed, and ' + \
str(failed_tests) + ' failed (' + \
str((failed_tests * 100.0) / total_tests) + '%) in ' + \
str(time.time() - start) + ' seconds.\033[0m'
def run_tests():
print '\033[94mRunning tests...\033[0m'
start = time.time()
total_passed_tests = 0
total_failed_tests = 0
for test_type in ['-eval', '-jit']:
print '\033[93mUsing command \'' + test_type + '\'...\033[0m'
test_start = time.time()
passed_tests = 0
failed_tests = 0
for f in os.listdir('tests/'):
if f.endswith('.cfl'):
in_file = 'tests/' + f
result_file = in_file + '.out'
out_file = f + '.out'
command = './cfl ' + test_type + ' ' + in_file + ' > ' + out_file
call(command)
with open(out_file, 'r') as out:
out_contents = out.read()
with open(result_file, 'r') as result:
result_contents = result.read()
if out_contents != result_contents:
failed_tests += 1
print '\033[91mERROR: Test ' + in_file + ' failed!\033[0m'
else:
passed_tests += 1
print '\033[92mSUCCESS: Test ' + in_file + ' passed.\033[0m'
call('rm ' + out_file)
print_info(test_start, passed_tests, failed_tests, '\033[90m')
total_passed_tests += passed_tests
total_failed_tests += failed_tests
print_info(start, total_passed_tests, total_failed_tests, '\033[94m')
run_tests()