-
Notifications
You must be signed in to change notification settings - Fork 3
/
test_stdlib_3.5_run.py
executable file
·56 lines (47 loc) · 1.49 KB
/
test_stdlib_3.5_run.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
48
49
50
51
52
53
54
55
56
#!/usr/bin/env python3
#
# Compare "compiler" package output against reference data produced
# by test_stdlib_3.5_prepare.py.
#
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",
# Some really weird __class__ usage, gave up to add adhoc exceptions for
# now, should revisit after rewriting symbols.py
"test_super.py",
)
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
if ignore:
continue
rel_fname = fname[len(CORPUS_PATH_IN) + 1:]
corpus_output = CORPUS_PATH_OUT + "/" + rel_fname
if os.path.exists("%s.done" % corpus_output):
print(rel_fname, "already done")
continue
if os.path.exists("%s.skip" % corpus_output):
print(rel_fname, "skipped")
continue
print(rel_fname)
subprocess.check_call("./python3.5-nopeephole compiler_runtest.py %s > %s.out" % (fname, corpus_output), shell=True)
subprocess.check_call("diff -u %s.exp %s.out" % (corpus_output, corpus_output), shell=True)
with open("%s.done" % corpus_output, "w"):
pass