Mercurial > hg
comparison tests/run-tests.py @ 21529:117e027390ab
run-tests: move whitelist and blacklist to named arguments of TestSuite
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Fri, 25 Apr 2014 15:00:54 -0700 |
parents | 32b9bbca2052 |
children | 78289625e986 |
comparison
equal
deleted
inserted
replaced
21528:32b9bbca2052 | 21529:117e027390ab |
---|---|
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 Mercurial tests.""" | 1154 """Custom unitest TestSuite that knows how to execute Mercurial tests.""" |
1155 | 1155 |
1156 def __init__(self, runner, jobs=1, *args, **kwargs): | 1156 def __init__(self, runner, jobs=1, whitelist=None, blacklist=None, |
1157 *args, **kwargs): | |
1157 """Create a new instance that can run tests with a configuration. | 1158 """Create a new instance that can run tests with a configuration. |
1158 | 1159 |
1159 jobs specifies the number of jobs to run concurrently. Each test | 1160 jobs specifies the number of jobs to run concurrently. Each test |
1160 executes on its own thread. Tests actually spawn new processes, so | 1161 executes on its own thread. Tests actually spawn new processes, so |
1161 state mutation should not be an issue. | 1162 state mutation should not be an issue. |
1163 | |
1164 whitelist and blacklist denote tests that have been whitelisted and | |
1165 blacklisted, respectively. These arguments don't belong in TestSuite. | |
1166 Instead, whitelist and blacklist should be handled by the thing that | |
1167 populates the TestSuite with tests. They are present to preserve | |
1168 backwards compatible behavior which reports skipped tests as part | |
1169 of the results. | |
1162 """ | 1170 """ |
1163 super(TestSuite, self).__init__(*args, **kwargs) | 1171 super(TestSuite, self).__init__(*args, **kwargs) |
1164 | 1172 |
1165 self._runner = runner | 1173 self._runner = runner |
1166 self._jobs = jobs | 1174 self._jobs = jobs |
1175 self._whitelist = whitelist | |
1176 self._blacklist = blacklist | |
1167 | 1177 |
1168 def run(self, result): | 1178 def run(self, result): |
1169 options = self._runner.options | 1179 options = self._runner.options |
1170 | 1180 |
1171 # We have a number of filters that need to be applied. We do this | 1181 # We have a number of filters that need to be applied. We do this |
1175 for test in self._tests: | 1185 for test in self._tests: |
1176 if not os.path.exists(test.path): | 1186 if not os.path.exists(test.path): |
1177 result.addSkip(test, "Doesn't exist") | 1187 result.addSkip(test, "Doesn't exist") |
1178 continue | 1188 continue |
1179 | 1189 |
1180 if not (options.whitelisted and test.name in options.whitelisted): | 1190 if not (self._whitelist and test.name in self._whitelist): |
1181 if options.blacklist and test.name in options.blacklist: | 1191 if self._blacklist and test.name in self._blacklist: |
1182 result.addSkip(test, 'blacklisted') | 1192 result.addSkip(test, 'blacklisted') |
1183 continue | 1193 continue |
1184 | 1194 |
1185 if options.retest and not os.path.exists(test.errpath): | 1195 if options.retest and not os.path.exists(test.errpath): |
1186 result.addIgnore(test, 'not retesting') | 1196 result.addIgnore(test, 'not retesting') |
1487 tests = [self._gettest(t, i) for i, t in enumerate(tests)] | 1497 tests = [self._gettest(t, i) for i, t in enumerate(tests)] |
1488 | 1498 |
1489 failed = False | 1499 failed = False |
1490 warned = False | 1500 warned = False |
1491 | 1501 |
1492 suite = TestSuite(self, jobs=self.options.jobs, tests=tests) | 1502 suite = TestSuite(self, jobs=self.options.jobs, |
1503 whitelist=self.options.whitelisted, | |
1504 blacklist=self.options.blacklist, | |
1505 tests=tests) | |
1493 verbosity = 1 | 1506 verbosity = 1 |
1494 if self.options.verbose: | 1507 if self.options.verbose: |
1495 verbosity = 2 | 1508 verbosity = 2 |
1496 runner = TextTestRunner(self, verbosity=verbosity) | 1509 runner = TextTestRunner(self, verbosity=verbosity) |
1497 runner.run(suite) | 1510 runner.run(suite) |