Show More
@@ -1151,12 +1151,19 b' class TestResult(unittest._TextTestResul' | |||
|
1151 | 1151 | test.name, self.times[-1][1])) |
|
1152 | 1152 | |
|
1153 | 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 | 1163 | super(TestSuite, self).__init__(*args, **kwargs) |
|
1158 | 1164 | |
|
1159 | 1165 | self._runner = runner |
|
1166 | self._jobs = jobs | |
|
1160 | 1167 | |
|
1161 | 1168 | def run(self, result): |
|
1162 | 1169 | options = self._runner.options |
@@ -1196,7 +1203,6 b' class TestSuite(unittest.TestSuite):' | |||
|
1196 | 1203 | tests.append(test) |
|
1197 | 1204 | |
|
1198 | 1205 | runtests = list(tests) |
|
1199 | jobs = self._runner.options.jobs | |
|
1200 | 1206 | done = queue.Queue() |
|
1201 | 1207 | running = 0 |
|
1202 | 1208 | |
@@ -1212,7 +1218,7 b' class TestSuite(unittest.TestSuite):' | |||
|
1212 | 1218 | |
|
1213 | 1219 | try: |
|
1214 | 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 | 1222 | try: |
|
1217 | 1223 | done.get(True, 1) |
|
1218 | 1224 | if result and result.shouldStop: |
@@ -1220,7 +1226,7 b' class TestSuite(unittest.TestSuite):' | |||
|
1220 | 1226 | except queue.Empty: |
|
1221 | 1227 | continue |
|
1222 | 1228 | running -= 1 |
|
1223 | if tests and not running == jobs: | |
|
1229 | if tests and not running == self._jobs: | |
|
1224 | 1230 | test = tests.pop(0) |
|
1225 | 1231 | if self._runner.options.loop: |
|
1226 | 1232 | tests.append(test) |
@@ -1483,7 +1489,7 b' class TestRunner(object):' | |||
|
1483 | 1489 | failed = False |
|
1484 | 1490 | warned = False |
|
1485 | 1491 | |
|
1486 | suite = TestSuite(self, tests=tests) | |
|
1492 | suite = TestSuite(self, jobs=self.options.jobs, tests=tests) | |
|
1487 | 1493 | verbosity = 1 |
|
1488 | 1494 | if self.options.verbose: |
|
1489 | 1495 | verbosity = 2 |
General Comments 0
You need to be logged in to leave comments.
Login now