From 4336eda88640695b23790e4f52de9ee92c7fee73 Mon Sep 17 00:00:00 2001 From: Jeremy Hylton Date: Sat, 7 Aug 2004 19:25:33 +0000 Subject: [PATCH] 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. --- Lib/test/regrtest.py | 6 +++++- Lib/test/test_compiler.py | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 Lib/test/test_compiler.py diff --git a/Lib/test/regrtest.py b/Lib/test/regrtest.py index e1ad55d48a..fc7c633374 100755 --- a/Lib/test/regrtest.py +++ b/Lib/test/regrtest.py @@ -83,6 +83,10 @@ resources to test. Currently only the following are defined: decimal - Test the decimal module against a large suite that verifies compliance with standards. + compiler - Test the compiler package by compiling all the source + in the standard library and test suite. This takes + a long time. + To enable all resources except one, use '-uall,-'. For example, to run all the tests except for the bsddb tests, give the option '-uall,-bsddb'. @@ -126,7 +130,7 @@ if sys.platform == 'darwin': from test import test_support RESOURCE_NAMES = ('audio', 'curses', 'largefile', 'network', 'bsddb', - 'decimal') + 'decimal', 'compiler') def usage(code, msg=''): diff --git a/Lib/test/test_compiler.py b/Lib/test/test_compiler.py new file mode 100644 index 0000000000..fea68564ef --- /dev/null +++ b/Lib/test/test_compiler.py @@ -0,0 +1,34 @@ +import compiler +import os +import test.test_support +import unittest + +class CompilerTest(unittest.TestCase): + + def testCompileLibrary(self): + # A simple but large test. Compile all the code in the + # standard library and its test suite. This doesn't verify + # that any of the code is correct, merely the compiler is able + # to generate some kind of code for it. + + libdir = os.path.dirname(unittest.__file__) + testdir = os.path.dirname(test.test_support.__file__) + + for dir in [libdir, testdir]: + for path in os.listdir(dir): + if not path.endswith(".py"): + continue + f = open(os.path.join(dir, path), "r") + buf = f.read() + f.close() + compiler.compile(buf, path, "exec") + +def test_main(): + test.test_support.requires("compiler") + test.test_support.run_unittest(CompilerTest) + +if __name__ == "__main__": + test_main() + + + -- 2.50.1