Mercurial > hg
comparison tests/run-tests.py @ 32943:750c3b1bb8a3
tests: removed ReportedTest exception
The only call site called addFailure before raising, which is
exactly what the failure exception handler does. So this
complexity is not needed.
We have test coverage of this "server failed to start" scenario
and nothing appeared to change.
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Sat, 03 Jun 2017 17:32:52 -0700 |
parents | 5af78c524f34 |
children | 8dc62c97a665 |
comparison
equal
deleted
inserted
replaced
32942:5af78c524f34 | 32943:750c3b1bb8a3 |
---|---|
715 result.addSkip(self, str(e)) | 715 result.addSkip(self, str(e)) |
716 # The base class will have already counted this as a | 716 # The base class will have already counted this as a |
717 # test we "ran", but we want to exclude skipped tests | 717 # test we "ran", but we want to exclude skipped tests |
718 # from those we count towards those run. | 718 # from those we count towards those run. |
719 result.testsRun -= 1 | 719 result.testsRun -= 1 |
720 except ReportedTest as e: | |
721 pass | |
722 except self.failureException as e: | 720 except self.failureException as e: |
723 # This differs from unittest in that we don't capture | 721 # This differs from unittest in that we don't capture |
724 # the stack trace. This is for historical reasons and | 722 # the stack trace. This is for historical reasons and |
725 # this decision could be revisited in the future, | 723 # this decision could be revisited in the future, |
726 # especially for PythonTest instances. | 724 # especially for PythonTest instances. |
1477 def _stringescape(s): | 1475 def _stringescape(s): |
1478 return TTest.ESCAPESUB(TTest._escapef, s) | 1476 return TTest.ESCAPESUB(TTest._escapef, s) |
1479 | 1477 |
1480 iolock = threading.RLock() | 1478 iolock = threading.RLock() |
1481 | 1479 |
1482 class ReportedTest(Exception): | |
1483 """Raised to indicate that a test already reported.""" | |
1484 | |
1485 class TestResult(unittest._TextTestResult): | 1480 class TestResult(unittest._TextTestResult): |
1486 """Holds results when executing via unittest.""" | 1481 """Holds results when executing via unittest.""" |
1487 # Don't worry too much about accessing the non-public _TextTestResult. | 1482 # Don't worry too much about accessing the non-public _TextTestResult. |
1488 # It is relatively common in Python testing tools. | 1483 # It is relatively common in Python testing tools. |
1489 def __init__(self, options, *args, **kwargs): | 1484 def __init__(self, options, *args, **kwargs): |
1576 (v, test.refpath, test.errpath)) | 1571 (v, test.refpath, test.errpath)) |
1577 else: | 1572 else: |
1578 servefail, lines = getdiff(expected, got, | 1573 servefail, lines = getdiff(expected, got, |
1579 test.refpath, test.errpath) | 1574 test.refpath, test.errpath) |
1580 if servefail: | 1575 if servefail: |
1581 self.addFailure( | 1576 raise test.failureException( |
1582 test, | |
1583 'server failed to start (HGPORT=%s)' % test._startport) | 1577 'server failed to start (HGPORT=%s)' % test._startport) |
1584 raise ReportedTest('server failed to start') | |
1585 else: | 1578 else: |
1586 self.stream.write('\n') | 1579 self.stream.write('\n') |
1587 for line in lines: | 1580 for line in lines: |
1588 if PYTHON3: | 1581 if PYTHON3: |
1589 self.stream.flush() | 1582 self.stream.flush() |