Added -t (--threshold) option to call gc.set_threshold(N).

This commit is contained in:
Guido van Rossum 2002-06-07 15:17:03 +00:00
parent a4c2b2470f
commit 9e9d4f8ed8
1 changed files with 30 additions and 25 deletions

View File

@ -18,6 +18,7 @@ Command line options:
-l: findleaks -- if GC is available detect tests that leak memory -l: findleaks -- if GC is available detect tests that leak memory
-u: use -- specify which special resource intensive tests to run -u: use -- specify which special resource intensive tests to run
-h: help -- print this text and exit -h: help -- print this text and exit
-t: threshold -- call gc.set_threshold(N)
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.
@ -25,34 +26,35 @@ If no test names are given, all tests are run.
-v is incompatible with -g and does not compare test output files. -v is incompatible with -g and does not compare test output files.
-s means to run only a single test and exit. This is useful when doing memory -s means to run only a single test and exit. This is useful when
analysis on the Python interpreter (which tend to consume too many resources to doing memory analysis on the Python interpreter (which tend to consume
run the full regression test non-stop). The file /tmp/pynexttest is read to too many resources to run the full regression test non-stop). The
find the next test to run. If this file is missing, the first test_*.py file file /tmp/pynexttest is read to find the next test to run. If this
in testdir or on the command line is used. (actually tempfile.gettempdir() is file is missing, the first test_*.py file in testdir or on the command
used instead of /tmp). line is used. (actually tempfile.gettempdir() is used instead of
/tmp).
-f reads the names of tests from the file given as f's argument, one or more -f reads the names of tests from the file given as f's argument, one
test names per line. Whitespace is ignored. Blank lines and lines beginning or more test names per line. Whitespace is ignored. Blank lines and
with '#' are ignored. This is especially useful for whittling down failures lines beginning with '#' are ignored. This is especially useful for
involving interactions among tests. whittling down failures involving interactions among tests.
-u is used to specify which special resource intensive tests to run, such as -u is used to specify which special resource intensive tests to run,
those requiring large file support or network connectivity. The argument is a such as those requiring large file support or network connectivity.
comma-separated list of words indicating the resources to test. Currently The argument is a comma-separated list of words indicating the
only the following are defined: resources to test. Currently only the following are defined:
all - Enable all special resources. all - Enable all special resources.
curses - Tests that use curses and will modify the terminal's curses - Tests that use curses and will modify the terminal's
state and output modes. state and output modes.
largefile - It is okay to run some test that may create huge files. These largefile - It is okay to run some test that may create huge
tests can take a long time and may consume >2GB of disk space files. These tests can take a long time and may
temporarily. consume >2GB of disk space temporarily.
network - It is okay to run tests that use external network resource, network - It is okay to run tests that use external network
e.g. testing SSL support for sockets. resource, e.g. testing SSL support for sockets.
""" """
import sys import sys
@ -93,19 +95,19 @@ 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 default arguments (verbose, quiet, generate, exclude, single, The other default arguments (verbose, quiet, generate, exclude,
randomize, findleaks, and use_resources) allow programmers calling main() single, randomize, findleaks, and use_resources) allow programmers
directly to set the values that would normally be set by flags on the calling main() directly to set the values that would normally be
command line. set by flags on the command line.
""" """
test_support.record_original_stdout(sys.stdout) test_support.record_original_stdout(sys.stdout)
try: try:
opts, args = getopt.getopt(sys.argv[1:], 'hvgqxsrf:lu:', opts, args = getopt.getopt(sys.argv[1:], 'hvgqxsrf:lu:t:',
['help', 'verbose', 'quiet', 'generate', ['help', 'verbose', 'quiet', 'generate',
'exclude', 'single', 'random', 'fromfile', 'exclude', 'single', 'random', 'fromfile',
'findleaks', 'use=']) 'findleaks', 'use=', 'threshold='])
except getopt.error, msg: except getopt.error, msg:
usage(2, msg) usage(2, msg)
@ -132,6 +134,9 @@ def main(tests=None, testdir=None, verbose=0, quiet=0, generate=0,
fromfile = a fromfile = a
elif o in ('-l', '--findleaks'): elif o in ('-l', '--findleaks'):
findleaks = 1 findleaks = 1
elif o in ('-t', '--threshold'):
import gc
gc.set_threshold(int(a))
elif o in ('-u', '--use'): elif o in ('-u', '--use'):
u = [x.lower() for x in a.split(',')] u = [x.lower() for x in a.split(',')]
for r in u: for r in u: