Show More
@@ -1151,12 +1151,19 b' class TestResult(unittest._TextTestResul' | |||||
1151 | test.name, self.times[-1][1])) |
|
1151 | test.name, self.times[-1][1])) | |
1152 |
|
1152 | |||
1153 | class TestSuite(unittest.TestSuite): |
|
1153 | class TestSuite(unittest.TestSuite): | |
1154 |
"""Custom unitest TestSuite that knows how to execute |
|
1154 | """Custom unitest TestSuite that knows how to execute Mercurial tests.""" | |
|
1155 | ||||
|
1156 | def __init__(self, runner, jobs=1, *args, **kwargs): | |||
|
1157 | """Create a new instance that can run tests with a configuration. | |||
1155 |
|
|
1158 | ||
1156 | def __init__(self, runner, *args, **kwargs): |
|
1159 | jobs specifies the number of jobs to run concurrently. Each test | |
|
1160 | executes on its own thread. Tests actually spawn new processes, so | |||
|
1161 | state mutation should not be an issue. | |||
|
1162 | """ | |||
1157 | super(TestSuite, self).__init__(*args, **kwargs) |
|
1163 | super(TestSuite, self).__init__(*args, **kwargs) | |
1158 |
|
1164 | |||
1159 | self._runner = runner |
|
1165 | self._runner = runner | |
|
1166 | self._jobs = jobs | |||
1160 |
|
1167 | |||
1161 | def run(self, result): |
|
1168 | def run(self, result): | |
1162 | options = self._runner.options |
|
1169 | options = self._runner.options | |
@@ -1196,7 +1203,6 b' class TestSuite(unittest.TestSuite):' | |||||
1196 | tests.append(test) |
|
1203 | tests.append(test) | |
1197 |
|
1204 | |||
1198 | runtests = list(tests) |
|
1205 | runtests = list(tests) | |
1199 | jobs = self._runner.options.jobs |
|
|||
1200 | done = queue.Queue() |
|
1206 | done = queue.Queue() | |
1201 | running = 0 |
|
1207 | running = 0 | |
1202 |
|
1208 | |||
@@ -1212,7 +1218,7 b' class TestSuite(unittest.TestSuite):' | |||||
1212 |
|
1218 | |||
1213 | try: |
|
1219 | try: | |
1214 | while tests or running: |
|
1220 | while tests or running: | |
1215 | if not done.empty() or running == jobs or not tests: |
|
1221 | if not done.empty() or running == self._jobs or not tests: | |
1216 | try: |
|
1222 | try: | |
1217 | done.get(True, 1) |
|
1223 | done.get(True, 1) | |
1218 | if result and result.shouldStop: |
|
1224 | if result and result.shouldStop: | |
@@ -1220,7 +1226,7 b' class TestSuite(unittest.TestSuite):' | |||||
1220 | except queue.Empty: |
|
1226 | except queue.Empty: | |
1221 | continue |
|
1227 | continue | |
1222 | running -= 1 |
|
1228 | running -= 1 | |
1223 | if tests and not running == jobs: |
|
1229 | if tests and not running == self._jobs: | |
1224 | test = tests.pop(0) |
|
1230 | test = tests.pop(0) | |
1225 | if self._runner.options.loop: |
|
1231 | if self._runner.options.loop: | |
1226 | tests.append(test) |
|
1232 | tests.append(test) | |
@@ -1483,7 +1489,7 b' class TestRunner(object):' | |||||
1483 | failed = False |
|
1489 | failed = False | |
1484 | warned = False |
|
1490 | warned = False | |
1485 |
|
1491 | |||
1486 | suite = TestSuite(self, tests=tests) |
|
1492 | suite = TestSuite(self, jobs=self.options.jobs, tests=tests) | |
1487 | verbosity = 1 |
|
1493 | verbosity = 1 | |
1488 | if self.options.verbose: |
|
1494 | if self.options.verbose: | |
1489 | verbosity = 2 |
|
1495 | verbosity = 2 |
General Comments 0
You need to be logged in to leave comments.
Login now