Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2a8ec79

Browse files
committed
Revise regrtest to compile entire standard library.
The tests are run from a copy of the library directory, where everything has been compiled by the compiler package. Add a raw_input() call at the end of the script, so that I can check the output before the temp directory with the compiled code is removed.
1 parent 33c2a62 commit 2a8ec79

1 file changed

Lines changed: 28 additions & 9 deletions

File tree

Tools/compiler/regrtest.py

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,35 +21,54 @@ def copy_test_suite():
2121
print "Creating copy of test suite in", dest
2222
return dest
2323

24+
def copy_library():
25+
dest = tempfile.mktemp()
26+
os.mkdir(dest)
27+
libdir = os.path.split(test.__path__[0])[0]
28+
os.system("cp -r %s/* %s" % (libdir, dest))
29+
print "Creating copy of standard library in", dest
30+
return dest
31+
2432
def compile_files(dir):
25-
print "Compiling",
33+
print "Compiling", dir
2634
line_len = 10
2735
for file in os.listdir(dir):
2836
base, ext = os.path.splitext(file)
29-
if ext == '.py' and base[:4] == 'test':
37+
if ext == '.py':
3038
source = os.path.join(dir, file)
3139
line_len = line_len + len(file) + 1
3240
if line_len > 75:
3341
print "\n\t",
3442
line_len = len(source) + 9
3543
print file,
36-
compile(source)
44+
try:
45+
compile(source)
46+
except SyntaxError, err:
47+
print err
48+
continue
3749
# make sure the .pyc file is not over-written
3850
os.chmod(source + "c", 444)
51+
else:
52+
path = os.path.join(dir, file)
53+
if os.path.isdir(path):
54+
print
55+
compile_files(path)
3956
print
4057

41-
def run_regrtest(test_dir):
58+
def run_regrtest(lib_dir):
59+
test_dir = os.path.join(lib_dir, "test")
4260
os.chdir(test_dir)
43-
os.system("%s -v regrtest.py" % sys.executable)
61+
os.system("PYTHONPATH=%s %s -v regrtest.py -r" % (lib_dir, sys.executable))
4462

4563
def cleanup(dir):
4664
os.system("rm -rf %s" % dir)
4765

4866
def main():
49-
test_dir = copy_test_suite()
50-
compile_files(test_dir)
51-
run_regrtest(test_dir)
52-
cleanup(test_dir)
67+
lib_dir = copy_library()
68+
compile_files(lib_dir)
69+
run_regrtest(lib_dir)
70+
raw_input("Cleanup?")
71+
cleanup(lib_dir)
5372

5473
if __name__ == "__main__":
5574
main()

0 commit comments

Comments
 (0)