[Python-checkins] python/dist/src/Lib/test regrtest.py,1.83,1.84
tim_one@users.sourceforge.net
tim_one@users.sourceforge.net
Sun, 02 Jun 2002 14:42:03 -0700
Update of /cvsroot/python/python/dist/src/Lib/test
In directory usw-pr-cvs1:/tmp/cvs-serv31955
Modified Files:
regrtest.py
Log Message:
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).
Index: regrtest.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/regrtest.py,v
retrieving revision 1.83
retrieving revision 1.84
diff -C2 -d -r1.83 -r1.84
*** regrtest.py 30 Apr 2002 12:11:04 -0000 1.83
--- regrtest.py 2 Jun 2002 21:42:01 -0000 1.84
***************
*** 15,18 ****
--- 15,19 ----
-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
***************
*** 32,35 ****
--- 33,41 ----
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
***************
*** 70,74 ****
def main(tests=None, testdir=None, verbose=0, quiet=0, generate=0,
! exclude=0, single=0, randomize=0, findleaks=0,
use_resources=None):
"""Execute a test suite.
--- 76,80 ----
def main(tests=None, testdir=None, verbose=0, quiet=0, generate=0,
! exclude=0, single=0, randomize=0, fromfile=None, findleaks=0,
use_resources=None):
"""Execute a test suite.
***************
*** 97,103 ****
test_support.record_original_stdout(sys.stdout)
try:
! opts, args = getopt.getopt(sys.argv[1:], 'hvgqxsrlu:',
['help', 'verbose', 'quiet', 'generate',
! 'exclude', 'single', 'random',
'findleaks', 'use='])
except getopt.error, msg:
--- 103,109 ----
test_support.record_original_stdout(sys.stdout)
try:
! opts, args = getopt.getopt(sys.argv[1:], 'hvgqxsrf:lu:',
['help', 'verbose', 'quiet', 'generate',
! 'exclude', 'single', 'random', 'fromfile',
'findleaks', 'use='])
except getopt.error, msg:
***************
*** 123,126 ****
--- 129,134 ----
elif o in ('-r', '--randomize'):
randomize = 1
+ elif o in ('-f', '--fromfile'):
+ fromfile = a
elif o in ('-l', '--findleaks'):
findleaks = 1
***************
*** 137,140 ****
--- 145,150 ----
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 = []
***************
*** 165,172 ****
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]
stdtests = STDTESTS[:]
nottests = NOTTESTS[:]
--- 175,194 ----
except IOError:
pass
!
! 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[:]
***************
*** 418,421 ****
--- 440,448 ----
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):