Commit d569f23d authored by Neil Schemenauer's avatar Neil Schemenauer

- Replace debugleak flag with findleaks flag. The new SAVEALL GC option is

  used to find cyclic garbage produced by tests.
parent faae266e
...@@ -14,7 +14,7 @@ Command line options: ...@@ -14,7 +14,7 @@ Command line options:
-x: exclude -- arguments are tests to *exclude* -x: exclude -- arguments are tests to *exclude*
-s: single -- run only a single test (see below) -s: single -- run only a single test (see below)
-r: random -- randomize test execution order -r: random -- randomize test execution order
-l: leakdebug -- if cycle garbage collection is enabled, run with DEBUG_LEAK -l: findleaks -- if GC is available detect and print cyclic garbage
--have-resources -- run tests that require large resources (time/space) --have-resources -- run tests that require large resources (time/space)
If non-option arguments are present, they are names for tests to run, If non-option arguments are present, they are names for tests to run,
...@@ -41,7 +41,7 @@ import random ...@@ -41,7 +41,7 @@ import random
import test_support import test_support
def main(tests=None, testdir=None, verbose=0, quiet=0, generate=0, def main(tests=None, testdir=None, verbose=0, quiet=0, generate=0,
exclude=0, single=0, randomize=0, leakdebug=0, exclude=0, single=0, randomize=0, findleaks=0,
use_large_resources=0): use_large_resources=0):
"""Execute a test suite. """Execute a test suite.
...@@ -60,7 +60,7 @@ def main(tests=None, testdir=None, verbose=0, quiet=0, generate=0, ...@@ -60,7 +60,7 @@ def main(tests=None, testdir=None, verbose=0, quiet=0, generate=0,
files beginning with test_ will be used. files beginning with test_ will be used.
The other seven default arguments (verbose, quiet, generate, exclude, The other seven default arguments (verbose, quiet, generate, exclude,
single, randomize, and leakdebug) allow programmers calling main() single, randomize, and findleaks) allow programmers calling main()
directly to set the values that would normally be set by flags on the directly to set the values that would normally be set by flags on the
command line. command line.
...@@ -79,7 +79,7 @@ def main(tests=None, testdir=None, verbose=0, quiet=0, generate=0, ...@@ -79,7 +79,7 @@ def main(tests=None, testdir=None, verbose=0, quiet=0, generate=0,
if o == '-x': exclude = 1 if o == '-x': exclude = 1
if o == '-s': single = 1 if o == '-s': single = 1
if o == '-r': randomize = 1 if o == '-r': randomize = 1
if o == '-l': leakdebug = 1 if o == '-l': findleaks = 1
if o == '--have-resources': use_large_resources = 1 if o == '--have-resources': use_large_resources = 1
if generate and verbose: if generate and verbose:
print "-g and -v don't go together!" print "-g and -v don't go together!"
...@@ -88,13 +88,15 @@ def main(tests=None, testdir=None, verbose=0, quiet=0, generate=0, ...@@ -88,13 +88,15 @@ def main(tests=None, testdir=None, verbose=0, quiet=0, generate=0,
bad = [] bad = []
skipped = [] skipped = []
if leakdebug: if findleaks:
try: try:
import gc import gc
except ImportError: except ImportError:
print 'cycle garbage collection not available' print 'cycle garbage collection not available'
findleaks = 0
else: else:
gc.set_debug(gc.DEBUG_LEAK) gc.set_debug(gc.DEBUG_SAVEALL)
found_garbage = []
if single: if single:
from tempfile import gettempdir from tempfile import gettempdir
...@@ -136,6 +138,12 @@ def main(tests=None, testdir=None, verbose=0, quiet=0, generate=0, ...@@ -136,6 +138,12 @@ def main(tests=None, testdir=None, verbose=0, quiet=0, generate=0,
bad.append(test) bad.append(test)
else: else:
skipped.append(test) skipped.append(test)
if findleaks:
gc.collect()
if gc.garbage:
print "garbage:", repr(gc.garbage)
found_garbage.extend(gc.garbage)
del gc.garbage[:]
# Unload the newly imported modules (best effort finalization) # Unload the newly imported modules (best effort finalization)
for module in sys.modules.keys(): for module in sys.modules.keys():
if module not in save_modules and module.startswith("test."): if module not in save_modules and module.startswith("test."):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment