tests/run-tests.py
changeset 24329 e7ca4d4b10e1
parent 24306 6ddc86eedc3b
child 24330 799bc18e14d1
equal deleted inserted replaced
24328:603a8d09e12d 24329:e7ca4d4b10e1
   168         help="run tests matching keywords")
   168         help="run tests matching keywords")
   169     parser.add_option("-l", "--local", action="store_true",
   169     parser.add_option("-l", "--local", action="store_true",
   170         help="shortcut for --with-hg=<testdir>/../hg")
   170         help="shortcut for --with-hg=<testdir>/../hg")
   171     parser.add_option("--loop", action="store_true",
   171     parser.add_option("--loop", action="store_true",
   172         help="loop tests repeatedly")
   172         help="loop tests repeatedly")
       
   173     parser.add_option("--runs-per-test", type="int", dest="runs_per_test",
       
   174         help="run each test N times (default=1)", default=1)
   173     parser.add_option("-n", "--nodiff", action="store_true",
   175     parser.add_option("-n", "--nodiff", action="store_true",
   174         help="skip showing test changes")
   176         help="skip showing test changes")
   175     parser.add_option("-p", "--port", type="int",
   177     parser.add_option("-p", "--port", type="int",
   176         help="port on which servers should listen"
   178         help="port on which servers should listen"
   177              " (default: $%s or %d)" % defaults['port'])
   179              " (default: $%s or %d)" % defaults['port'])
  1286 
  1288 
  1287 class TestSuite(unittest.TestSuite):
  1289 class TestSuite(unittest.TestSuite):
  1288     """Custom unittest TestSuite that knows how to execute Mercurial tests."""
  1290     """Custom unittest TestSuite that knows how to execute Mercurial tests."""
  1289 
  1291 
  1290     def __init__(self, testdir, jobs=1, whitelist=None, blacklist=None,
  1292     def __init__(self, testdir, jobs=1, whitelist=None, blacklist=None,
  1291                  retest=False, keywords=None, loop=False,
  1293                  retest=False, keywords=None, loop=False, runs_per_test=1,
  1292                  *args, **kwargs):
  1294                  *args, **kwargs):
  1293         """Create a new instance that can run tests with a configuration.
  1295         """Create a new instance that can run tests with a configuration.
  1294 
  1296 
  1295         testdir specifies the directory where tests are executed from. This
  1297         testdir specifies the directory where tests are executed from. This
  1296         is typically the ``tests`` directory from Mercurial's source
  1298         is typically the ``tests`` directory from Mercurial's source
  1321         self._whitelist = whitelist
  1323         self._whitelist = whitelist
  1322         self._blacklist = blacklist
  1324         self._blacklist = blacklist
  1323         self._retest = retest
  1325         self._retest = retest
  1324         self._keywords = keywords
  1326         self._keywords = keywords
  1325         self._loop = loop
  1327         self._loop = loop
       
  1328         self._runs_per_test = runs_per_test
  1326 
  1329 
  1327     def run(self, result):
  1330     def run(self, result):
  1328         # We have a number of filters that need to be applied. We do this
  1331         # We have a number of filters that need to be applied. We do this
  1329         # here instead of inside Test because it makes the running logic for
  1332         # here instead of inside Test because it makes the running logic for
  1330         # Test simpler.
  1333         # Test simpler.
  1354                             ignored = True
  1357                             ignored = True
  1355                             break
  1358                             break
  1356 
  1359 
  1357                     if ignored:
  1360                     if ignored:
  1358                         continue
  1361                         continue
  1359 
  1362             for _ in xrange(self._runs_per_test):
  1360             tests.append(test)
  1363                 tests.append(test)
  1361 
  1364 
  1362         runtests = list(tests)
  1365         runtests = list(tests)
  1363         done = queue.Queue()
  1366         done = queue.Queue()
  1364         running = 0
  1367         running = 0
  1365 
  1368 
  1727                               whitelist=self.options.whitelisted,
  1730                               whitelist=self.options.whitelisted,
  1728                               blacklist=self.options.blacklist,
  1731                               blacklist=self.options.blacklist,
  1729                               retest=self.options.retest,
  1732                               retest=self.options.retest,
  1730                               keywords=self.options.keywords,
  1733                               keywords=self.options.keywords,
  1731                               loop=self.options.loop,
  1734                               loop=self.options.loop,
       
  1735                               runs_per_test=self.options.runs_per_test,
  1732                               tests=tests)
  1736                               tests=tests)
  1733             verbosity = 1
  1737             verbosity = 1
  1734             if self.options.verbose:
  1738             if self.options.verbose:
  1735                 verbosity = 2
  1739                 verbosity = 2
  1736             runner = TextTestRunner(self, verbosity=verbosity)
  1740             runner = TextTestRunner(self, verbosity=verbosity)