Mercurial > hg
comparison tests/run-tests.py @ 21997:93c3b3f55d59
run-tests: fix test result counts with --keyword specified or skips occurring
This preserves the current behavior that excludes ignored or skipped
tests from the number of tests run, except when tests are ignored due
to the --retest flag.
author | Augie Fackler <raf@durin42.com> |
---|---|
date | Mon, 28 Jul 2014 19:48:59 -0400 |
parents | 284a8c9f74f3 |
children | a06172e85fd4 |
comparison
equal
deleted
inserted
replaced
21996:947553944e92 | 21997:93c3b3f55d59 |
---|---|
458 except KeyboardInterrupt: | 458 except KeyboardInterrupt: |
459 self._aborted = True | 459 self._aborted = True |
460 raise | 460 raise |
461 except SkipTest, e: | 461 except SkipTest, e: |
462 result.addSkip(self, str(e)) | 462 result.addSkip(self, str(e)) |
463 # The base class will have already counted this as a | |
464 # test we "ran", but we want to exclude skipped tests | |
465 # from those we count towards those run. | |
466 result.testsRun -= 1 | |
463 except IgnoreTest, e: | 467 except IgnoreTest, e: |
464 result.addIgnore(self, str(e)) | 468 result.addIgnore(self, str(e)) |
469 # As with skips, ignores also should be excluded from | |
470 # the number of tests executed. | |
471 result.testsRun -= 1 | |
465 except WarnTest, e: | 472 except WarnTest, e: |
466 result.addWarn(self, str(e)) | 473 result.addWarn(self, str(e)) |
467 except self.failureException, e: | 474 except self.failureException, e: |
468 # This differs from unittest in that we don't capture | 475 # This differs from unittest in that we don't capture |
469 # the stack trace. This is for historical reasons and | 476 # the stack trace. This is for historical reasons and |
1099 self.stop() | 1106 self.stop() |
1100 | 1107 |
1101 # Polyfill. | 1108 # Polyfill. |
1102 def addSkip(self, test, reason): | 1109 def addSkip(self, test, reason): |
1103 self.skipped.append((test, reason)) | 1110 self.skipped.append((test, reason)) |
1104 | |
1105 if self.showAll: | 1111 if self.showAll: |
1106 self.stream.writeln('skipped %s' % reason) | 1112 self.stream.writeln('skipped %s' % reason) |
1107 else: | 1113 else: |
1108 self.stream.write('s') | 1114 self.stream.write('s') |
1109 self.stream.flush() | 1115 self.stream.flush() |
1110 | 1116 |
1111 def addIgnore(self, test, reason): | 1117 def addIgnore(self, test, reason): |
1112 self.ignored.append((test, reason)) | 1118 self.ignored.append((test, reason)) |
1113 | |
1114 if self.showAll: | 1119 if self.showAll: |
1115 self.stream.writeln('ignored %s' % reason) | 1120 self.stream.writeln('ignored %s' % reason) |
1116 else: | 1121 else: |
1117 if reason != 'not retesting': | 1122 if reason != 'not retesting': |
1118 self.stream.write('i') | 1123 self.stream.write('i') |
1124 else: | |
1125 self.testsRun += 1 | |
1119 self.stream.flush() | 1126 self.stream.flush() |
1120 | 1127 |
1121 def addWarn(self, test, reason): | 1128 def addWarn(self, test, reason): |
1122 self.warned.append((test, reason)) | 1129 self.warned.append((test, reason)) |
1123 | 1130 |
1337 for test, msg in result.errors: | 1344 for test, msg in result.errors: |
1338 self.stream.writeln('Errored %s: %s' % (test.name, msg)) | 1345 self.stream.writeln('Errored %s: %s' % (test.name, msg)) |
1339 | 1346 |
1340 self._runner._checkhglib('Tested') | 1347 self._runner._checkhglib('Tested') |
1341 | 1348 |
1342 # When '--retest' is enabled, only failure tests run. At this point | |
1343 # "result.testsRun" holds the count of failure test that has run. But | |
1344 # as while printing output, we have subtracted the skipped and ignored | |
1345 # count from "result.testsRun". Therefore, to make the count remain | |
1346 # the same, we need to add skipped and ignored count in here. | |
1347 if self._runner.options.retest: | |
1348 result.testsRun = result.testsRun + skipped + ignored | |
1349 | |
1350 # This differs from unittest's default output in that we don't count | |
1351 # skipped and ignored tests as part of the total test count. | |
1352 self.stream.writeln('# Ran %d tests, %d skipped, %d warned, %d failed.' | 1349 self.stream.writeln('# Ran %d tests, %d skipped, %d warned, %d failed.' |
1353 % (result.testsRun - skipped - ignored, | 1350 % (result.testsRun, |
1354 skipped + ignored, warned, failed)) | 1351 skipped + ignored, warned, failed)) |
1355 if failed: | 1352 if failed: |
1356 self.stream.writeln('python hash seed: %s' % | 1353 self.stream.writeln('python hash seed: %s' % |
1357 os.environ['PYTHONHASHSEED']) | 1354 os.environ['PYTHONHASHSEED']) |
1358 if self._runner.options.time: | 1355 if self._runner.options.time: |