run-tests: move loop to a named argument of TestSuite.__init__
authorGregory Szorc <gregory.szorc@gmail.com>
Fri, 25 Apr 2014 15:08:03 -0700
changeset 21532 9d2ba7e2324d
parent 21531 7fcda22acc43
child 21533 aecac8059c00
run-tests: move loop to a named argument of TestSuite.__init__
tests/run-tests.py
--- a/tests/run-tests.py	Fri Apr 25 15:06:23 2014 -0700
+++ b/tests/run-tests.py	Fri Apr 25 15:08:03 2014 -0700
@@ -1154,7 +1154,7 @@
     """Custom unitest TestSuite that knows how to execute Mercurial tests."""
 
     def __init__(self, runner, jobs=1, whitelist=None, blacklist=None,
-                 retest=False, keywords=None,
+                 retest=False, keywords=None, loop=False,
                  *args, **kwargs):
         """Create a new instance that can run tests with a configuration.
 
@@ -1174,6 +1174,8 @@
 
         keywords denotes key words that will be used to filter which tests
         to execute. This arguably belongs outside of TestSuite.
+
+        loop denotes whether to loop over tests forever.
         """
         super(TestSuite, self).__init__(*args, **kwargs)
 
@@ -1183,6 +1185,7 @@
         self._blacklist = blacklist
         self._retest = retest
         self._keywords = keywords
+        self._loop = loop
 
     def run(self, result):
         # We have a number of filters that need to be applied. We do this
@@ -1245,7 +1248,7 @@
                     running -= 1
                 if tests and not running == self._jobs:
                     test = tests.pop(0)
-                    if self._runner.options.loop:
+                    if self._loop:
                         tests.append(test)
                     t = threading.Thread(target=job, name=test.name,
                                          args=(test, result))
@@ -1511,6 +1514,7 @@
                               blacklist=self.options.blacklist,
                               retest=self.options.retest,
                               keywords=self.options.keywords,
+                              loop=self.options.loop,
                               tests=tests)
             verbosity = 1
             if self.options.verbose: