-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtest_stdlib_3.5_prepare.py
executable file
·47 lines (41 loc) · 1.22 KB
/
test_stdlib_3.5_prepare.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
43
44
45
46
47
#!/usr/bin/env python3
#
# Compile CPython stdlib+tests (Lib/ in distribution) using CPython,
# to serve as comparison reference.
# Make sure you have built CPython3.5 with peephole optimizer disabled
# using build-cpython-compiler.sh script.
#
import glob
import os
import subprocess
CORPUS_PATH_IN = "cpython/Lib"
CORPUS_PATH_OUT = "stdlib-3.5"
IGNORE_PATTERNS = (
# Not a valid Python3 syntax
"lib2to3/tests/data",
"test/badsyntax_",
"test/bad_coding",
)
def ensure_path(path):
dirpath = os.path.dirname(path)
try:
os.makedirs(dirpath)
except OSError:
pass
for fname in glob.glob(CORPUS_PATH_IN + "/**/*.py", recursive=True):
assert fname.startswith(CORPUS_PATH_IN + "/")
ignore = False
for p in IGNORE_PATTERNS:
if p in fname:
ignore = True
break
rel_fname = fname[len(CORPUS_PATH_IN) + 1:]
if ignore:
#print("%s - ignored" % rel_fname)
continue
print(rel_fname)
corpus_output = CORPUS_PATH_OUT + "/" + rel_fname
if os.path.exists(corpus_output + ".exp"):
continue
ensure_path(corpus_output)
subprocess.check_call("./python3.5-nopeephole dis_stable.py %s > %s.exp" % (fname, corpus_output), shell=True)