mirror of
https://github.com/python/cpython.git
synced 2025-09-27 02:39:58 +00:00
regrtest has a new
-f/--fromfile <filename> option. This runs all and only the tests named in the file, in the order given (although -x may weed that list, and -r may shuffle it). Lines starting with '#' are ignored. This goes a long way toward helping to automate the binary-search-like procedure I keep reinventing by hand when a test fails due to interaction among tests (no failure in isolation, and some unknown number of predecessor tests need to run first -- now you can stick all the test names in a file, and comment/uncomment blocks of lines until finding a minimal set of predecessors).
This commit is contained in:
parent
69e18af968
commit
c5000dfc40
1 changed files with 34 additions and 7 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
|
||||||
|
-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
|
||||||
-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
|
||||||
|
@ -31,6 +32,11 @@ find the next test to run. If this file is missing, the first test_*.py file
|
||||||
in testdir or on the command line is used. (actually tempfile.gettempdir() is
|
in testdir or on the command line is used. (actually tempfile.gettempdir() is
|
||||||
used instead of /tmp).
|
used instead of /tmp).
|
||||||
|
|
||||||
|
-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 lines beginning
|
||||||
|
with '#' are ignored. This is especially useful for 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, such as
|
||||||
those requiring large file support or network connectivity. The argument is a
|
those requiring large file support or network connectivity. The argument is a
|
||||||
comma-separated list of words indicating the resources to test. Currently
|
comma-separated list of words indicating the resources to test. Currently
|
||||||
|
@ -69,7 +75,7 @@ def usage(code, msg=''):
|
||||||
|
|
||||||
|
|
||||||
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, findleaks=0,
|
exclude=0, single=0, randomize=0, fromfile=None, findleaks=0,
|
||||||
use_resources=None):
|
use_resources=None):
|
||||||
"""Execute a test suite.
|
"""Execute a test suite.
|
||||||
|
|
||||||
|
@ -96,9 +102,9 @@ def main(tests=None, testdir=None, verbose=0, quiet=0, generate=0,
|
||||||
|
|
||||||
test_support.record_original_stdout(sys.stdout)
|
test_support.record_original_stdout(sys.stdout)
|
||||||
try:
|
try:
|
||||||
opts, args = getopt.getopt(sys.argv[1:], 'hvgqxsrlu:',
|
opts, args = getopt.getopt(sys.argv[1:], 'hvgqxsrf:lu:',
|
||||||
['help', 'verbose', 'quiet', 'generate',
|
['help', 'verbose', 'quiet', 'generate',
|
||||||
'exclude', 'single', 'random',
|
'exclude', 'single', 'random', 'fromfile',
|
||||||
'findleaks', 'use='])
|
'findleaks', 'use='])
|
||||||
except getopt.error, msg:
|
except getopt.error, msg:
|
||||||
usage(2, msg)
|
usage(2, msg)
|
||||||
|
@ -122,6 +128,8 @@ def main(tests=None, testdir=None, verbose=0, quiet=0, generate=0,
|
||||||
single = 1
|
single = 1
|
||||||
elif o in ('-r', '--randomize'):
|
elif o in ('-r', '--randomize'):
|
||||||
randomize = 1
|
randomize = 1
|
||||||
|
elif o in ('-f', '--fromfile'):
|
||||||
|
fromfile = a
|
||||||
elif o in ('-l', '--findleaks'):
|
elif o in ('-l', '--findleaks'):
|
||||||
findleaks = 1
|
findleaks = 1
|
||||||
elif o in ('-u', '--use'):
|
elif o in ('-u', '--use'):
|
||||||
|
@ -136,6 +144,8 @@ def main(tests=None, testdir=None, verbose=0, quiet=0, generate=0,
|
||||||
use_resources.append(r)
|
use_resources.append(r)
|
||||||
if generate and verbose:
|
if generate and verbose:
|
||||||
usage(2, "-g and -v don't go together!")
|
usage(2, "-g and -v don't go together!")
|
||||||
|
if single and fromfile:
|
||||||
|
usage(2, "-s and -f don't go together!")
|
||||||
|
|
||||||
good = []
|
good = []
|
||||||
bad = []
|
bad = []
|
||||||
|
@ -164,10 +174,22 @@ def main(tests=None, testdir=None, verbose=0, quiet=0, generate=0,
|
||||||
fp.close()
|
fp.close()
|
||||||
except IOError:
|
except IOError:
|
||||||
pass
|
pass
|
||||||
for i in range(len(args)):
|
|
||||||
# Strip trailing ".py" from arguments
|
if fromfile:
|
||||||
if args[i][-3:] == os.extsep+'py':
|
tests = []
|
||||||
args[i] = args[i][:-3]
|
fp = open(fromfile)
|
||||||
|
for line in fp:
|
||||||
|
guts = line.split() # assuming no test has whitespace in its name
|
||||||
|
if guts and not guts[0].startswith('#'):
|
||||||
|
tests.extend(guts)
|
||||||
|
fp.close()
|
||||||
|
|
||||||
|
# Strip .py extensions.
|
||||||
|
if args:
|
||||||
|
args = map(removepy, args)
|
||||||
|
if tests:
|
||||||
|
tests = map(removepy, tests)
|
||||||
|
|
||||||
stdtests = STDTESTS[:]
|
stdtests = STDTESTS[:]
|
||||||
nottests = NOTTESTS[:]
|
nottests = NOTTESTS[:]
|
||||||
if exclude:
|
if exclude:
|
||||||
|
@ -418,6 +440,11 @@ def findtestdir():
|
||||||
testdir = os.path.dirname(file) or os.curdir
|
testdir = os.path.dirname(file) or os.curdir
|
||||||
return testdir
|
return testdir
|
||||||
|
|
||||||
|
def removepy(name):
|
||||||
|
if name.endswith(os.extsep + "py"):
|
||||||
|
name = name[:-3]
|
||||||
|
return name
|
||||||
|
|
||||||
def count(n, word):
|
def count(n, word):
|
||||||
if n == 1:
|
if n == 1:
|
||||||
return "%d %s" % (n, word)
|
return "%d %s" % (n, word)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue