]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Backport changes from the 2.2 trunk
authorJeremy Hylton <jeremy@alum.mit.edu>
Wed, 19 Dec 2001 19:42:52 +0000 (19:42 +0000)
committerJeremy Hylton <jeremy@alum.mit.edu>
Wed, 19 Dec 2001 19:42:52 +0000 (19:42 +0000)
Tools/compiler/regrtest.py

index fd990a951485f709d66b8d6e29f1e63c4ff5e9b9..d7bb39a768c6d99f110f77d8574336b58cc49b05 100644 (file)
@@ -21,35 +21,58 @@ def copy_test_suite():
     print "Creating copy of test suite in", dest
     return dest
 
+def copy_library():
+    dest = tempfile.mktemp()
+    os.mkdir(dest)
+    libdir = os.path.split(test.__path__[0])[0]
+    print "Found standard library in", libdir
+    print "Creating copy of standard library in", dest
+    os.system("cp -r %s/* %s" % (libdir, dest))
+    return dest
+
 def compile_files(dir):
-    print "Compiling",
+    print "Compiling", dir, "\n\t",
     line_len = 10
     for file in os.listdir(dir):
         base, ext = os.path.splitext(file)
-        if ext == '.py' and base[:4] == 'test':
+        if ext == '.py':
             source = os.path.join(dir, file)
             line_len = line_len + len(file) + 1
             if line_len > 75:
                 print "\n\t",
                 line_len = len(source) + 9
             print file,
-            compile(source)
+            try:
+                compile(source)
+            except SyntaxError, err:
+                print err
+                continue
             # make sure the .pyc file is not over-written
             os.chmod(source + "c", 444)
+        else:
+            path = os.path.join(dir, file)
+            if os.path.isdir(path):
+                print
+                print
+                compile_files(path)
+                print "\t",
+                line_len = 10
     print
 
-def run_regrtest(test_dir):
+def run_regrtest(lib_dir):
+    test_dir = os.path.join(lib_dir, "test")
     os.chdir(test_dir)
-    os.system("%s -v regrtest.py" % sys.executable)
+    os.system("PYTHONPATH=%s %s -v regrtest.py" % (lib_dir, sys.executable))
 
 def cleanup(dir):
     os.system("rm -rf %s" % dir)
 
 def main():
-    test_dir = copy_test_suite()
-    compile_files(test_dir)
-    run_regrtest(test_dir)
-    cleanup(test_dir)
+    lib_dir = copy_library()
+    compile_files(lib_dir)
+    run_regrtest(lib_dir)
+    raw_input("Cleanup?")
+    cleanup(lib_dir)
 
 if __name__ == "__main__":
     main()