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

Skip to content

Commit 4336eda

Browse files
committed
Add a trivial test for the compiler package, guarded by compiler resource.
This test is insanely slow, so it requires a resource. On my machine, it also appears to dump core. I think the problem is a stack overflow, but haven't been able to confirm.
1 parent 32dbdda commit 4336eda

2 files changed

Lines changed: 39 additions & 1 deletion

File tree

Lib/test/regrtest.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,10 @@
8383
decimal - Test the decimal module against a large suite that
8484
verifies compliance with standards.
8585
86+
compiler - Test the compiler package by compiling all the source
87+
in the standard library and test suite. This takes
88+
a long time.
89+
8690
To enable all resources except one, use '-uall,-<resource>'. For
8791
example, to run all the tests except for the bsddb tests, give the
8892
option '-uall,-bsddb'.
@@ -126,7 +130,7 @@
126130
from test import test_support
127131

128132
RESOURCE_NAMES = ('audio', 'curses', 'largefile', 'network', 'bsddb',
129-
'decimal')
133+
'decimal', 'compiler')
130134

131135

132136
def usage(code, msg=''):

Lib/test/test_compiler.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import compiler
2+
import os
3+
import test.test_support
4+
import unittest
5+
6+
class CompilerTest(unittest.TestCase):
7+
8+
def testCompileLibrary(self):
9+
# A simple but large test. Compile all the code in the
10+
# standard library and its test suite. This doesn't verify
11+
# that any of the code is correct, merely the compiler is able
12+
# to generate some kind of code for it.
13+
14+
libdir = os.path.dirname(unittest.__file__)
15+
testdir = os.path.dirname(test.test_support.__file__)
16+
17+
for dir in [libdir, testdir]:
18+
for path in os.listdir(dir):
19+
if not path.endswith(".py"):
20+
continue
21+
f = open(os.path.join(dir, path), "r")
22+
buf = f.read()
23+
f.close()
24+
compiler.compile(buf, path, "exec")
25+
26+
def test_main():
27+
test.test_support.requires("compiler")
28+
test.test_support.run_unittest(CompilerTest)
29+
30+
if __name__ == "__main__":
31+
test_main()
32+
33+
34+

0 commit comments

Comments
 (0)