Mercurial > cpython-lru_cache-weakref
annotate Tools/compiler/regrtest.py @ 54294:dba767bc3155 legacy-trunk
remove mention of old ctypes version
| author | Benjamin Peterson <benjamin@python.org> |
|---|---|
| date | Sat, 23 May 2009 20:59:09 +0000 |
| parents | c7e03cf8333e |
| children | 081b4f0e81b7 |
| rev | line source |
|---|---|
|
15207
701a561bdefa
run the std regression test suite using bytecode produced by the compiler
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
1 """Run the Python regression test using the compiler |
|
701a561bdefa
run the std regression test suite using bytecode produced by the compiler
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
2 |
|
701a561bdefa
run the std regression test suite using bytecode produced by the compiler
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
3 This test runs the standard Python test suite using bytecode generated |
|
701a561bdefa
run the std regression test suite using bytecode produced by the compiler
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
4 by this compiler instead of by the builtin compiler. |
|
701a561bdefa
run the std regression test suite using bytecode produced by the compiler
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
5 |
|
701a561bdefa
run the std regression test suite using bytecode produced by the compiler
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
6 The regression test is run with the interpreter in verbose mode so |
|
701a561bdefa
run the std regression test suite using bytecode produced by the compiler
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
7 that import problems can be observed easily. |
|
701a561bdefa
run the std regression test suite using bytecode produced by the compiler
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
8 """ |
|
701a561bdefa
run the std regression test suite using bytecode produced by the compiler
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
9 |
|
19947
3f1922990903
Track changes to compiler API
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
19506
diff
changeset
|
10 from compiler import compileFile |
|
15207
701a561bdefa
run the std regression test suite using bytecode produced by the compiler
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
11 |
|
701a561bdefa
run the std regression test suite using bytecode produced by the compiler
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
12 import os |
|
701a561bdefa
run the std regression test suite using bytecode produced by the compiler
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
13 import sys |
|
701a561bdefa
run the std regression test suite using bytecode produced by the compiler
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
14 import test |
|
701a561bdefa
run the std regression test suite using bytecode produced by the compiler
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
15 import tempfile |
|
701a561bdefa
run the std regression test suite using bytecode produced by the compiler
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
16 |
|
701a561bdefa
run the std regression test suite using bytecode produced by the compiler
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
17 def copy_test_suite(): |
|
24710
11c701038805
Massive changes from SF 589982 (tempfile.py rewrite, by Zack
Guido van Rossum <guido@python.org>
parents:
19947
diff
changeset
|
18 dest = tempfile.mkdtemp() |
|
15207
701a561bdefa
run the std regression test suite using bytecode produced by the compiler
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
19 os.system("cp -r %s/* %s" % (test.__path__[0], dest)) |
|
701a561bdefa
run the std regression test suite using bytecode produced by the compiler
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
20 print "Creating copy of test suite in", dest |
|
701a561bdefa
run the std regression test suite using bytecode produced by the compiler
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
21 return dest |
|
701a561bdefa
run the std regression test suite using bytecode produced by the compiler
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
22 |
|
19506
87628030ad75
Revise regrtest to compile entire standard library.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
15207
diff
changeset
|
23 def copy_library(): |
|
24710
11c701038805
Massive changes from SF 589982 (tempfile.py rewrite, by Zack
Guido van Rossum <guido@python.org>
parents:
19947
diff
changeset
|
24 dest = tempfile.mkdtemp() |
|
19506
87628030ad75
Revise regrtest to compile entire standard library.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
15207
diff
changeset
|
25 libdir = os.path.split(test.__path__[0])[0] |
|
19947
3f1922990903
Track changes to compiler API
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
19506
diff
changeset
|
26 print "Found standard library in", libdir |
|
3f1922990903
Track changes to compiler API
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
19506
diff
changeset
|
27 print "Creating copy of standard library in", dest |
|
19506
87628030ad75
Revise regrtest to compile entire standard library.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
15207
diff
changeset
|
28 os.system("cp -r %s/* %s" % (libdir, dest)) |
|
87628030ad75
Revise regrtest to compile entire standard library.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
15207
diff
changeset
|
29 return dest |
|
87628030ad75
Revise regrtest to compile entire standard library.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
15207
diff
changeset
|
30 |
|
15207
701a561bdefa
run the std regression test suite using bytecode produced by the compiler
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
31 def compile_files(dir): |
|
19947
3f1922990903
Track changes to compiler API
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
19506
diff
changeset
|
32 print "Compiling", dir, "\n\t", |
|
15207
701a561bdefa
run the std regression test suite using bytecode produced by the compiler
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
33 line_len = 10 |
|
701a561bdefa
run the std regression test suite using bytecode produced by the compiler
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
34 for file in os.listdir(dir): |
|
701a561bdefa
run the std regression test suite using bytecode produced by the compiler
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
35 base, ext = os.path.splitext(file) |
|
19506
87628030ad75
Revise regrtest to compile entire standard library.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
15207
diff
changeset
|
36 if ext == '.py': |
|
15207
701a561bdefa
run the std regression test suite using bytecode produced by the compiler
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
37 source = os.path.join(dir, file) |
|
701a561bdefa
run the std regression test suite using bytecode produced by the compiler
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
38 line_len = line_len + len(file) + 1 |
|
701a561bdefa
run the std regression test suite using bytecode produced by the compiler
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
39 if line_len > 75: |
|
701a561bdefa
run the std regression test suite using bytecode produced by the compiler
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
40 print "\n\t", |
|
701a561bdefa
run the std regression test suite using bytecode produced by the compiler
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
41 line_len = len(source) + 9 |
|
701a561bdefa
run the std regression test suite using bytecode produced by the compiler
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
42 print file, |
|
19506
87628030ad75
Revise regrtest to compile entire standard library.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
15207
diff
changeset
|
43 try: |
|
19947
3f1922990903
Track changes to compiler API
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
19506
diff
changeset
|
44 compileFile(source) |
|
19506
87628030ad75
Revise regrtest to compile entire standard library.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
15207
diff
changeset
|
45 except SyntaxError, err: |
|
87628030ad75
Revise regrtest to compile entire standard library.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
15207
diff
changeset
|
46 print err |
|
87628030ad75
Revise regrtest to compile entire standard library.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
15207
diff
changeset
|
47 continue |
|
15207
701a561bdefa
run the std regression test suite using bytecode produced by the compiler
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
48 # make sure the .pyc file is not over-written |
|
701a561bdefa
run the std regression test suite using bytecode produced by the compiler
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
49 os.chmod(source + "c", 444) |
|
32888
c7e03cf8333e
PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents:
24710
diff
changeset
|
50 elif file == 'CVS': |
|
c7e03cf8333e
PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents:
24710
diff
changeset
|
51 pass |
|
19506
87628030ad75
Revise regrtest to compile entire standard library.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
15207
diff
changeset
|
52 else: |
|
87628030ad75
Revise regrtest to compile entire standard library.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
15207
diff
changeset
|
53 path = os.path.join(dir, file) |
|
87628030ad75
Revise regrtest to compile entire standard library.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
15207
diff
changeset
|
54 if os.path.isdir(path): |
|
87628030ad75
Revise regrtest to compile entire standard library.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
15207
diff
changeset
|
55 print |
|
19947
3f1922990903
Track changes to compiler API
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
19506
diff
changeset
|
56 print |
|
19506
87628030ad75
Revise regrtest to compile entire standard library.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
15207
diff
changeset
|
57 compile_files(path) |
|
19947
3f1922990903
Track changes to compiler API
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
19506
diff
changeset
|
58 print "\t", |
|
3f1922990903
Track changes to compiler API
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
19506
diff
changeset
|
59 line_len = 10 |
|
15207
701a561bdefa
run the std regression test suite using bytecode produced by the compiler
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
60 print |
|
701a561bdefa
run the std regression test suite using bytecode produced by the compiler
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
61 |
|
19506
87628030ad75
Revise regrtest to compile entire standard library.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
15207
diff
changeset
|
62 def run_regrtest(lib_dir): |
|
87628030ad75
Revise regrtest to compile entire standard library.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
15207
diff
changeset
|
63 test_dir = os.path.join(lib_dir, "test") |
|
15207
701a561bdefa
run the std regression test suite using bytecode produced by the compiler
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
64 os.chdir(test_dir) |
|
19947
3f1922990903
Track changes to compiler API
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
19506
diff
changeset
|
65 os.system("PYTHONPATH=%s %s -v regrtest.py" % (lib_dir, sys.executable)) |
|
15207
701a561bdefa
run the std regression test suite using bytecode produced by the compiler
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
66 |
|
701a561bdefa
run the std regression test suite using bytecode produced by the compiler
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
67 def cleanup(dir): |
|
701a561bdefa
run the std regression test suite using bytecode produced by the compiler
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
68 os.system("rm -rf %s" % dir) |
|
701a561bdefa
run the std regression test suite using bytecode produced by the compiler
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
69 |
|
701a561bdefa
run the std regression test suite using bytecode produced by the compiler
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
70 def main(): |
|
19506
87628030ad75
Revise regrtest to compile entire standard library.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
15207
diff
changeset
|
71 lib_dir = copy_library() |
|
87628030ad75
Revise regrtest to compile entire standard library.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
15207
diff
changeset
|
72 compile_files(lib_dir) |
|
87628030ad75
Revise regrtest to compile entire standard library.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
15207
diff
changeset
|
73 run_regrtest(lib_dir) |
|
87628030ad75
Revise regrtest to compile entire standard library.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
15207
diff
changeset
|
74 raw_input("Cleanup?") |
|
87628030ad75
Revise regrtest to compile entire standard library.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
15207
diff
changeset
|
75 cleanup(lib_dir) |
|
15207
701a561bdefa
run the std regression test suite using bytecode produced by the compiler
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
76 |
|
701a561bdefa
run the std regression test suite using bytecode produced by the compiler
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
77 if __name__ == "__main__": |
|
701a561bdefa
run the std regression test suite using bytecode produced by the compiler
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
78 main() |
