mirror of
https://github.com/python/cpython.git
synced 2025-09-27 02:39:58 +00:00
Added a -l/--leakdebug option which turns on DEBUG_LEAK if the gc
module is importable.
This commit is contained in:
parent
e027d8dc81
commit
a873b03ebb
1 changed files with 23 additions and 12 deletions
|
@ -14,6 +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
|
||||||
|
|
||||||
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,
|
||||||
unless -x is given, in which case they are names for tests not 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
|
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):
|
exclude=0, single=0, randomize=0, leakdebug=0):
|
||||||
"""Execute a test suite.
|
"""Execute a test suite.
|
||||||
|
|
||||||
This also parses command-line options and modifies its behavior
|
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
|
command-line will be used. If that's empty, too, then all *.py
|
||||||
files beginning with test_ will be used.
|
files beginning with test_ will be used.
|
||||||
|
|
||||||
The other six default arguments (verbose, quiet, generate, exclude,
|
The other seven default arguments (verbose, quiet, generate, exclude,
|
||||||
single, and randomize) allow programmers calling main() directly to
|
single, randomize, and leakdebug) allow programmers calling main()
|
||||||
set the values that would normally be set by flags on the command
|
directly to set the values that would normally be set by flags on the
|
||||||
line.
|
command line.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
try:
|
try:
|
||||||
opts, args = getopt.getopt(sys.argv[1:], 'vgqxsr')
|
opts, args = getopt.getopt(sys.argv[1:], 'vgqxsrl')
|
||||||
except getopt.error, msg:
|
except getopt.error, msg:
|
||||||
print msg
|
print msg
|
||||||
print __doc__
|
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 == '-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 generate and verbose:
|
if generate and verbose:
|
||||||
print "-g and -v don't go together!"
|
print "-g and -v don't go together!"
|
||||||
return 2
|
return 2
|
||||||
|
@ -82,6 +85,14 @@ def main(tests=None, testdir=None, verbose=0, quiet=0, generate=0,
|
||||||
bad = []
|
bad = []
|
||||||
skipped = []
|
skipped = []
|
||||||
|
|
||||||
|
if leakdebug:
|
||||||
|
try:
|
||||||
|
import gc
|
||||||
|
except ImportError:
|
||||||
|
print 'cycle garbage collection not available'
|
||||||
|
else:
|
||||||
|
gc.set_debug(gc.DEBUG_LEAK)
|
||||||
|
|
||||||
if single:
|
if single:
|
||||||
from tempfile import gettempdir
|
from tempfile import gettempdir
|
||||||
filename = os.path.join(gettempdir(), 'pynexttest')
|
filename = os.path.join(gettempdir(), 'pynexttest')
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue