add an extra global that is never defined; this is used to handle names that never...
[pythonc.git] / test.py
blob34230abd2d0a9b99d3f3cb4b3011c443b2b1d67f
1 #!/usr/bin/python3
2 import os
3 import shutil
4 import subprocess
5 import time
7 # XXX This file is really stupid!! Just a 5-minute effort on my part...
9 if not os.path.exists('.temp'):
10 os.mkdir('.temp')
11 for i in ['pythonc.py', 'syntax.py', 'transform.py', 'backend.cpp', 'alloc.h']:
12 shutil.copy(i, '.temp')
14 for i in os.listdir('tests'):
15 if i.endswith('.py'):
16 shutil.copy('tests/%s' % i, '.temp/test.py')
17 start = time.time()
18 out_p = subprocess.check_output('./pythonc.py -q test.py', cwd='.temp', shell=True)
19 mid = time.time()
20 out_c = subprocess.check_output('python3 test.py', cwd='.temp', shell=True)
21 end = time.time()
22 if out_p != out_c:
23 raise RuntimeError('%s mismatched!\nPythonc:\n%s\nCPython:\n%s' % (i,
24 out_p.decode(), out_c.decode()))
25 time_p = mid - start
26 time_c = end - mid
27 # XXX timing should factor out translation time
28 print('%s: pythonc=%ss cpython=%ss (%.3fx)' % (i, time_p, time_c, time_p / time_c))