blob: fd990a951485f709d66b8d6e29f1e63c4ff5e9b9 [file] [log] [blame]
Jeremy Hyltonac148b52000-10-13 22:00:13 +00001"""Run the Python regression test using the compiler
2
3This test runs the standard Python test suite using bytecode generated
4by this compiler instead of by the builtin compiler.
5
6The regression test is run with the interpreter in verbose mode so
7that import problems can be observed easily.
8"""
9
10from compiler import compile
11
12import os
13import sys
14import test
15import tempfile
16
17def copy_test_suite():
18 dest = tempfile.mktemp()
19 os.mkdir(dest)
20 os.system("cp -r %s/* %s" % (test.__path__[0], dest))
21 print "Creating copy of test suite in", dest
22 return dest
23
24def compile_files(dir):
25 print "Compiling",
26 line_len = 10
27 for file in os.listdir(dir):
28 base, ext = os.path.splitext(file)
29 if ext == '.py' and base[:4] == 'test':
30 source = os.path.join(dir, file)
31 line_len = line_len + len(file) + 1
32 if line_len > 75:
33 print "\n\t",
34 line_len = len(source) + 9
35 print file,
36 compile(source)
37 # make sure the .pyc file is not over-written
38 os.chmod(source + "c", 444)
39 print
40
41def run_regrtest(test_dir):
42 os.chdir(test_dir)
43 os.system("%s -v regrtest.py" % sys.executable)
44
45def cleanup(dir):
46 os.system("rm -rf %s" % dir)
47
48def main():
49 test_dir = copy_test_suite()
50 compile_files(test_dir)
51 run_regrtest(test_dir)
52 cleanup(test_dir)
53
54if __name__ == "__main__":
55 main()