1152 |
1152 |
1153 class TestSuite(unittest.TestSuite): |
1153 class TestSuite(unittest.TestSuite): |
1154 """Custom unitest TestSuite that knows how to execute Mercurial tests.""" |
1154 """Custom unitest TestSuite that knows how to execute Mercurial tests.""" |
1155 |
1155 |
1156 def __init__(self, runner, jobs=1, whitelist=None, blacklist=None, |
1156 def __init__(self, runner, jobs=1, whitelist=None, blacklist=None, |
|
1157 retest=False, |
1157 *args, **kwargs): |
1158 *args, **kwargs): |
1158 """Create a new instance that can run tests with a configuration. |
1159 """Create a new instance that can run tests with a configuration. |
1159 |
1160 |
1160 jobs specifies the number of jobs to run concurrently. Each test |
1161 jobs specifies the number of jobs to run concurrently. Each test |
1161 executes on its own thread. Tests actually spawn new processes, so |
1162 executes on its own thread. Tests actually spawn new processes, so |
1165 blacklisted, respectively. These arguments don't belong in TestSuite. |
1166 blacklisted, respectively. These arguments don't belong in TestSuite. |
1166 Instead, whitelist and blacklist should be handled by the thing that |
1167 Instead, whitelist and blacklist should be handled by the thing that |
1167 populates the TestSuite with tests. They are present to preserve |
1168 populates the TestSuite with tests. They are present to preserve |
1168 backwards compatible behavior which reports skipped tests as part |
1169 backwards compatible behavior which reports skipped tests as part |
1169 of the results. |
1170 of the results. |
|
1171 |
|
1172 retest denotes whether to retest failed tests. This arguably belongs |
|
1173 outside of TestSuite. |
1170 """ |
1174 """ |
1171 super(TestSuite, self).__init__(*args, **kwargs) |
1175 super(TestSuite, self).__init__(*args, **kwargs) |
1172 |
1176 |
1173 self._runner = runner |
1177 self._runner = runner |
1174 self._jobs = jobs |
1178 self._jobs = jobs |
1175 self._whitelist = whitelist |
1179 self._whitelist = whitelist |
1176 self._blacklist = blacklist |
1180 self._blacklist = blacklist |
|
1181 self._retest = retest |
1177 |
1182 |
1178 def run(self, result): |
1183 def run(self, result): |
1179 options = self._runner.options |
1184 options = self._runner.options |
1180 |
1185 |
1181 # We have a number of filters that need to be applied. We do this |
1186 # We have a number of filters that need to be applied. We do this |
1190 if not (self._whitelist and test.name in self._whitelist): |
1195 if not (self._whitelist and test.name in self._whitelist): |
1191 if self._blacklist and test.name in self._blacklist: |
1196 if self._blacklist and test.name in self._blacklist: |
1192 result.addSkip(test, 'blacklisted') |
1197 result.addSkip(test, 'blacklisted') |
1193 continue |
1198 continue |
1194 |
1199 |
1195 if options.retest and not os.path.exists(test.errpath): |
1200 if self._retest and not os.path.exists(test.errpath): |
1196 result.addIgnore(test, 'not retesting') |
1201 result.addIgnore(test, 'not retesting') |
1197 continue |
1202 continue |
1198 |
1203 |
1199 if options.keywords: |
1204 if options.keywords: |
1200 f = open(test.path) |
1205 f = open(test.path) |
1500 warned = False |
1505 warned = False |
1501 |
1506 |
1502 suite = TestSuite(self, jobs=self.options.jobs, |
1507 suite = TestSuite(self, jobs=self.options.jobs, |
1503 whitelist=self.options.whitelisted, |
1508 whitelist=self.options.whitelisted, |
1504 blacklist=self.options.blacklist, |
1509 blacklist=self.options.blacklist, |
|
1510 retest=self.options.retest, |
1505 tests=tests) |
1511 tests=tests) |
1506 verbosity = 1 |
1512 verbosity = 1 |
1507 if self.options.verbose: |
1513 if self.options.verbose: |
1508 verbosity = 2 |
1514 verbosity = 2 |
1509 runner = TextTestRunner(self, verbosity=verbosity) |
1515 runner = TextTestRunner(self, verbosity=verbosity) |