mirror of https://github.com/python/cpython
Add -s/--start option that makes it easier to run the tests in batches
when one test fails and you want to start running from that point onwards.
This commit is contained in:
parent
dcb46eda32
commit
801c89be5d
|
@ -15,6 +15,7 @@ Command line options:
|
||||||
-g: generate -- write the output file for a test instead of comparing it
|
-g: generate -- write the output file for a test instead of comparing it
|
||||||
-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)
|
||||||
|
-S: start -- start running all the tests with the specified one first
|
||||||
-r: random -- randomize test execution order
|
-r: random -- randomize test execution order
|
||||||
-f: fromfile -- read names of tests to run from a file (see below)
|
-f: fromfile -- read names of tests to run from a file (see below)
|
||||||
-l: findleaks -- if GC is available detect tests that leak memory
|
-l: findleaks -- if GC is available detect tests that leak memory
|
||||||
|
@ -48,6 +49,12 @@ file is missing, the first test_*.py file in testdir or on the command
|
||||||
line is used. (actually tempfile.gettempdir() is used instead of
|
line is used. (actually tempfile.gettempdir() is used instead of
|
||||||
/tmp).
|
/tmp).
|
||||||
|
|
||||||
|
-S is used to continue running tests after an aborted run. It will
|
||||||
|
maintain the order a standard run (ie, this assumes -r is not used).
|
||||||
|
This is useful after the tests have prematurely stopped for some external
|
||||||
|
reason and you want to start running from where you left off rather
|
||||||
|
than starting from the beginning.
|
||||||
|
|
||||||
-f reads the names of tests from the file given as f's argument, one
|
-f reads the names of tests from the file given as f's argument, one
|
||||||
or more test names per line. Whitespace is ignored. Blank lines and
|
or more test names per line. Whitespace is ignored. Blank lines and
|
||||||
lines beginning with '#' are ignored. This is especially useful for
|
lines beginning with '#' are ignored. This is especially useful for
|
||||||
|
@ -177,7 +184,8 @@ def usage(code, msg=''):
|
||||||
def main(tests=None, testdir=None, verbose=0, quiet=False, generate=False,
|
def main(tests=None, testdir=None, verbose=0, quiet=False, generate=False,
|
||||||
exclude=False, single=False, randomize=False, fromfile=None,
|
exclude=False, single=False, randomize=False, fromfile=None,
|
||||||
findleaks=False, use_resources=None, trace=False, coverdir='coverage',
|
findleaks=False, use_resources=None, trace=False, coverdir='coverage',
|
||||||
runleaks=False, huntrleaks=False, verbose2=False, debug=False):
|
runleaks=False, huntrleaks=False, verbose2=False, debug=False,
|
||||||
|
start=None):
|
||||||
"""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
|
||||||
|
@ -202,13 +210,13 @@ def main(tests=None, testdir=None, verbose=0, quiet=False, generate=False,
|
||||||
|
|
||||||
test_support.record_original_stdout(sys.stdout)
|
test_support.record_original_stdout(sys.stdout)
|
||||||
try:
|
try:
|
||||||
opts, args = getopt.getopt(sys.argv[1:], 'dhvgqxsrf:lu:t:TD:NLR:wM:',
|
opts, args = getopt.getopt(sys.argv[1:], 'dhvgqxsS:rf:lu:t:TD:NLR:wM:',
|
||||||
['help', 'verbose', 'quiet', 'generate',
|
['help', 'verbose', 'quiet', 'generate',
|
||||||
'exclude', 'single', 'random', 'fromfile',
|
'exclude', 'single', 'random', 'fromfile',
|
||||||
'findleaks', 'use=', 'threshold=', 'trace',
|
'findleaks', 'use=', 'threshold=', 'trace',
|
||||||
'coverdir=', 'nocoverdir', 'runleaks',
|
'coverdir=', 'nocoverdir', 'runleaks',
|
||||||
'huntrleaks=', 'verbose2', 'memlimit=',
|
'huntrleaks=', 'verbose2', 'memlimit=',
|
||||||
'debug',
|
'debug', 'start='
|
||||||
])
|
])
|
||||||
except getopt.error as msg:
|
except getopt.error as msg:
|
||||||
usage(2, msg)
|
usage(2, msg)
|
||||||
|
@ -232,6 +240,8 @@ def main(tests=None, testdir=None, verbose=0, quiet=False, generate=False,
|
||||||
generate = True
|
generate = True
|
||||||
elif o in ('-x', '--exclude'):
|
elif o in ('-x', '--exclude'):
|
||||||
exclude = True
|
exclude = True
|
||||||
|
elif o in ('-S', '--start'):
|
||||||
|
start = a
|
||||||
elif o in ('-s', '--single'):
|
elif o in ('-s', '--single'):
|
||||||
single = True
|
single = True
|
||||||
elif o in ('-r', '--randomize'):
|
elif o in ('-r', '--randomize'):
|
||||||
|
@ -345,6 +355,12 @@ def main(tests=None, testdir=None, verbose=0, quiet=False, generate=False,
|
||||||
tests = tests or args or findtests(testdir, stdtests, nottests)
|
tests = tests or args or findtests(testdir, stdtests, nottests)
|
||||||
if single:
|
if single:
|
||||||
tests = tests[:1]
|
tests = tests[:1]
|
||||||
|
# Remove all the tests that precede start if it's set.
|
||||||
|
if start:
|
||||||
|
try:
|
||||||
|
del tests[:tests.index(start)]
|
||||||
|
except ValueError:
|
||||||
|
print("Couldn't find starting test (%s), using all tests" % start)
|
||||||
if randomize:
|
if randomize:
|
||||||
random.shuffle(tests)
|
random.shuffle(tests)
|
||||||
if trace:
|
if trace:
|
||||||
|
|
Loading…
Reference in New Issue