-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_tests.py
42 lines (36 loc) · 974 Bytes
/
run_tests.py
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
import sys, subprocess, os, colorama
nonstop = bool(os.environ.get('NONSTOP'))
ok = 0
fail = 0
for test in sys.argv[1:]:
print(colorama.Fore.GREEN + test + colorama.Style.RESET_ALL)
if subprocess.call(['ocamlc', '-g', test, '-o', 'test.byte']) != 0:
if nonstop:
continue
else:
sys.exit('compilation failed')
CMD = os.environ.get('CMD', 'pypy bytecode.py').split()
try:
out = subprocess.check_output(CMD + ['test.byte'])
except Exception:
if nonstop:
fail += 1
continue
else:
sys.exit('bytecode failed')
try:
exp = open(test[:-3] + '.reference', 'rb').read()
except IOError:
exp = ''
if out != exp:
print('expected:')
print(exp)
print('got:')
print(out)
if nonstop:
fail += 1
else:
sys.exit(1)
else:
ok += 1
print 'ok', ok, 'fail', fail