changeset 24329:e7ca4d4b10e1

run-tests: add --runs-per-test flag This is useful when you're working with a flaky test and want to run it (for example) 500 times to see if it'll false-fail. This currently breaks if you use it with more than one thread, but I'm looking into that now.
author Augie Fackler <augie@google.com>
date Fri, 13 Mar 2015 11:21:53 -0400
parents 603a8d09e12d
children 799bc18e14d1
files tests/run-tests.py
diffstat 1 files changed, 7 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/tests/run-tests.py	Thu Mar 12 21:41:50 2015 -0400
+++ b/tests/run-tests.py	Fri Mar 13 11:21:53 2015 -0400
@@ -170,6 +170,8 @@
         help="shortcut for --with-hg=<testdir>/../hg")
     parser.add_option("--loop", action="store_true",
         help="loop tests repeatedly")
+    parser.add_option("--runs-per-test", type="int", dest="runs_per_test",
+        help="run each test N times (default=1)", default=1)
     parser.add_option("-n", "--nodiff", action="store_true",
         help="skip showing test changes")
     parser.add_option("-p", "--port", type="int",
@@ -1288,7 +1290,7 @@
     """Custom unittest TestSuite that knows how to execute Mercurial tests."""
 
     def __init__(self, testdir, jobs=1, whitelist=None, blacklist=None,
-                 retest=False, keywords=None, loop=False,
+                 retest=False, keywords=None, loop=False, runs_per_test=1,
                  *args, **kwargs):
         """Create a new instance that can run tests with a configuration.
 
@@ -1323,6 +1325,7 @@
         self._retest = retest
         self._keywords = keywords
         self._loop = loop
+        self._runs_per_test = runs_per_test
 
     def run(self, result):
         # We have a number of filters that need to be applied. We do this
@@ -1356,8 +1359,8 @@
 
                     if ignored:
                         continue
-
-            tests.append(test)
+            for _ in xrange(self._runs_per_test):
+                tests.append(test)
 
         runtests = list(tests)
         done = queue.Queue()
@@ -1729,6 +1732,7 @@
                               retest=self.options.retest,
                               keywords=self.options.keywords,
                               loop=self.options.loop,
+                              runs_per_test=self.options.runs_per_test,
                               tests=tests)
             verbosity = 1
             if self.options.verbose: