]> granicus.if.org Git - python/commitdiff
Add -s/--start option that makes it easier to run the tests in batches
authorNeal Norwitz <nnorwitz@gmail.com>
Sun, 12 Aug 2007 01:31:40 +0000 (01:31 +0000)
committerNeal Norwitz <nnorwitz@gmail.com>
Sun, 12 Aug 2007 01:31:40 +0000 (01:31 +0000)
when one test fails and you want to start running from that point onwards.

Lib/test/regrtest.py

index 6f6436f89b8b69b26c2e349369bbef22e103aabe..07c49ad7e36ba44cb0bd69906b7e62060e7fdd21 100755 (executable)
@@ -15,6 +15,7 @@ Command line options:
 -g: generate   -- write the output file for a test instead of comparing it
 -x: exclude    -- arguments are tests to *exclude*
 -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
 -f: fromfile   -- read names of tests to run from a file (see below)
 -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
 /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
 or more test names per line.  Whitespace is ignored.  Blank lines and
 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,
          exclude=False, single=False, randomize=False, fromfile=None,
          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.
 
     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)
     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',
                                     'exclude', 'single', 'random', 'fromfile',
                                     'findleaks', 'use=', 'threshold=', 'trace',
                                     'coverdir=', 'nocoverdir', 'runleaks',
                                     'huntrleaks=', 'verbose2', 'memlimit=',
-                                    'debug',
+                                    'debug', 'start='
                                     ])
     except getopt.error as msg:
         usage(2, msg)
@@ -232,6 +240,8 @@ def main(tests=None, testdir=None, verbose=0, quiet=False, generate=False,
             generate = True
         elif o in ('-x', '--exclude'):
             exclude = True
+        elif o in ('-S', '--start'):
+            start = a
         elif o in ('-s', '--single'):
             single = True
         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)
     if single:
         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:
         random.shuffle(tests)
     if trace: