Move setting of ioready 'wait' earlier in call chain, to
[python/dscho.git] / Tools / compiler / regrtest.py
blobdef07c2faab6c659da10e97812eec750564dc2ec
1 """Run the Python regression test using the compiler
3 This test runs the standard Python test suite using bytecode generated
4 by this compiler instead of by the builtin compiler.
6 The regression test is run with the interpreter in verbose mode so
7 that import problems can be observed easily.
8 """
10 from compiler import compileFile
12 import os
13 import sys
14 import test
15 import tempfile
17 def copy_test_suite():
18 dest = tempfile.mkdtemp()
19 os.system("cp -r %s/* %s" % (test.__path__[0], dest))
20 print "Creating copy of test suite in", dest
21 return dest
23 def copy_library():
24 dest = tempfile.mkdtemp()
25 libdir = os.path.split(test.__path__[0])[0]
26 print "Found standard library in", libdir
27 print "Creating copy of standard library in", dest
28 os.system("cp -r %s/* %s" % (libdir, dest))
29 return dest
31 def compile_files(dir):
32 print "Compiling", dir, "\n\t",
33 line_len = 10
34 for file in os.listdir(dir):
35 base, ext = os.path.splitext(file)
36 if ext == '.py':
37 source = os.path.join(dir, file)
38 line_len = line_len + len(file) + 1
39 if line_len > 75:
40 print "\n\t",
41 line_len = len(source) + 9
42 print file,
43 try:
44 compileFile(source)
45 except SyntaxError, err:
46 print err
47 continue
48 # make sure the .pyc file is not over-written
49 os.chmod(source + "c", 444)
50 else:
51 path = os.path.join(dir, file)
52 if os.path.isdir(path):
53 print
54 print
55 compile_files(path)
56 print "\t",
57 line_len = 10
58 print
60 def run_regrtest(lib_dir):
61 test_dir = os.path.join(lib_dir, "test")
62 os.chdir(test_dir)
63 os.system("PYTHONPATH=%s %s -v regrtest.py" % (lib_dir, sys.executable))
65 def cleanup(dir):
66 os.system("rm -rf %s" % dir)
68 def main():
69 lib_dir = copy_library()
70 compile_files(lib_dir)
71 run_regrtest(lib_dir)
72 raw_input("Cleanup?")
73 cleanup(lib_dir)
75 if __name__ == "__main__":
76 main()