diff options
author | Barry Warsaw <barry@python.org> | 2000-08-03 15:50:37 (GMT) |
---|---|---|
committer | Barry Warsaw <barry@python.org> | 2000-08-03 15:50:37 (GMT) |
commit | a873b03ebb24076b3664ba694eeed4ab07d176d9 (patch) | |
tree | 9db1f2fddb1aabfeb647903aa9de6676efecb196 | |
parent | e027d8dc815ab9851287ddd0ada39428733e9b27 (diff) | |
download | cpython-a873b03ebb24076b3664ba694eeed4ab07d176d9.zip cpython-a873b03ebb24076b3664ba694eeed4ab07d176d9.tar.gz cpython-a873b03ebb24076b3664ba694eeed4ab07d176d9.tar.bz2 |
Added a -l/--leakdebug option which turns on DEBUG_LEAK if the gc
module is importable.
-rwxr-xr-x | Lib/test/regrtest.py | 35 |
1 files changed, 23 insertions, 12 deletions
diff --git a/Lib/test/regrtest.py b/Lib/test/regrtest.py index e96ba81..69bbf14 100755 --- a/Lib/test/regrtest.py +++ b/Lib/test/regrtest.py @@ -8,12 +8,13 @@ additional facilities. Command line options: --v: verbose -- run tests in verbose mode with output to stdout --q: quiet -- don't print anything except if a test fails --g: generate -- write the output file for a test instead of comparing it --x: exclude -- arguments are tests to *exclude* --s: single -- run only a single test (see below) --r: random -- randomize test execution order +-v: verbose -- run tests in verbose mode with output to stdout +-q: quiet -- don't print anything except if a test fails +-g: generate -- write the output file for a test instead of comparing it +-x: exclude -- arguments are tests to *exclude* +-s: single -- run only a single test (see below) +-r: random -- randomize test execution order +-l: leakdebug -- if cycle garbage collection is enabled, run with DEBUG_LEAK If non-option arguments are present, they are names for tests to run, unless -x is given, in which case they are names for tests not to run. @@ -39,7 +40,7 @@ import random import test_support def main(tests=None, testdir=None, verbose=0, quiet=0, generate=0, - exclude=0, single=0, randomize=0): + exclude=0, single=0, randomize=0, leakdebug=0): """Execute a test suite. This also parses command-line options and modifies its behavior @@ -56,14 +57,15 @@ def main(tests=None, testdir=None, verbose=0, quiet=0, generate=0, command-line will be used. If that's empty, too, then all *.py files beginning with test_ will be used. - The other six default arguments (verbose, quiet, generate, exclude, - single, and randomize) allow programmers calling main() directly to - set the values that would normally be set by flags on the command - line. + The other seven default arguments (verbose, quiet, generate, exclude, + single, randomize, and leakdebug) allow programmers calling main() + directly to set the values that would normally be set by flags on the + command line. + """ try: - opts, args = getopt.getopt(sys.argv[1:], 'vgqxsr') + opts, args = getopt.getopt(sys.argv[1:], 'vgqxsrl') except getopt.error, msg: print msg print __doc__ @@ -75,6 +77,7 @@ def main(tests=None, testdir=None, verbose=0, quiet=0, generate=0, if o == '-x': exclude = 1 if o == '-s': single = 1 if o == '-r': randomize = 1 + if o == '-l': leakdebug = 1 if generate and verbose: print "-g and -v don't go together!" return 2 @@ -82,6 +85,14 @@ def main(tests=None, testdir=None, verbose=0, quiet=0, generate=0, bad = [] skipped = [] + if leakdebug: + try: + import gc + except ImportError: + print 'cycle garbage collection not available' + else: + gc.set_debug(gc.DEBUG_LEAK) + if single: from tempfile import gettempdir filename = os.path.join(gettempdir(), 'pynexttest') |