summaryrefslogtreecommitdiffstats
path: root/Lib/test/regrtest.py
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2002-06-02 21:42:01 (GMT)
committerTim Peters <tim.peters@gmail.com>2002-06-02 21:42:01 (GMT)
commitc5000dfc4098f8547461e790a91536a923124261 (patch)
tree3125b1eb8c5e6e5836b2860b1fcf2e061a03435d /Lib/test/regrtest.py
parent69e18af96868cfd1f41bedc4eb494408c9c363f5 (diff)
downloadcpython-c5000dfc4098f8547461e790a91536a923124261.zip
cpython-c5000dfc4098f8547461e790a91536a923124261.tar.gz
cpython-c5000dfc4098f8547461e790a91536a923124261.tar.bz2
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).
Diffstat (limited to 'Lib/test/regrtest.py')
-rwxr-xr-xLib/test/regrtest.py41
1 files changed, 34 insertions, 7 deletions
diff --git a/Lib/test/regrtest.py b/Lib/test/regrtest.py
index cd2442d..9358d5f 100755
--- a/Lib/test/regrtest.py
+++ b/Lib/test/regrtest.py
@@ -14,6 +14,7 @@ Command line options:
-x: exclude -- arguments are tests to *exclude*
-s: single -- run only a single test (see below)
-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
-u: use -- specify which special resource intensive tests to run
-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
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
those requiring large file support or network connectivity. The argument is a
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,
- exclude=0, single=0, randomize=0, findleaks=0,
+ exclude=0, single=0, randomize=0, fromfile=None, findleaks=0,
use_resources=None):
"""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)
try:
- opts, args = getopt.getopt(sys.argv[1:], 'hvgqxsrlu:',
+ opts, args = getopt.getopt(sys.argv[1:], 'hvgqxsrf:lu:',
['help', 'verbose', 'quiet', 'generate',
- 'exclude', 'single', 'random',
+ 'exclude', 'single', 'random', 'fromfile',
'findleaks', 'use='])
except getopt.error, msg:
usage(2, msg)
@@ -122,6 +128,8 @@ def main(tests=None, testdir=None, verbose=0, quiet=0, generate=0,
single = 1
elif o in ('-r', '--randomize'):
randomize = 1
+ elif o in ('-f', '--fromfile'):
+ fromfile = a
elif o in ('-l', '--findleaks'):
findleaks = 1
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)
if generate and verbose:
usage(2, "-g and -v don't go together!")
+ if single and fromfile:
+ usage(2, "-s and -f don't go together!")
good = []
bad = []
@@ -164,10 +174,22 @@ def main(tests=None, testdir=None, verbose=0, quiet=0, generate=0,
fp.close()
except IOError:
pass
- for i in range(len(args)):
- # Strip trailing ".py" from arguments
- if args[i][-3:] == os.extsep+'py':
- args[i] = args[i][:-3]
+
+ if fromfile:
+ tests = []
+ 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[:]
nottests = NOTTESTS[:]
if exclude:
@@ -418,6 +440,11 @@ def findtestdir():
testdir = os.path.dirname(file) or os.curdir
return testdir
+def removepy(name):
+ if name.endswith(os.extsep + "py"):
+ name = name[:-3]
+ return name
+
def count(n, word):
if n == 1:
return "%d %s" % (n, word)