Patchwork [5,of,5] tests: removed ReportedTest exception

login
register
mail settings
Submitter Gregory Szorc
Date June 20, 2017, 6:12 a.m.
Message ID <0d9883e1033ff9da6df5.1497939173@ubuntu-vm-main>
Download mbox | patch
Permalink /patch/21525/
State Accepted
Headers show

Comments

Gregory Szorc - June 20, 2017, 6:12 a.m.
# HG changeset patch
# User Gregory Szorc <gregory.szorc@gmail.com>
# Date 1496536372 25200
#      Sat Jun 03 17:32:52 2017 -0700
# Node ID 0d9883e1033ff9da6df5906a375b393a98922ca8
# Parent  7714abde10367a3a9cc8fa7445fe0057ba556631
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.
via Mercurial-devel - June 20, 2017, 3:55 p.m.
On Mon, Jun 19, 2017 at 11:12 PM, Gregory Szorc <gregory.szorc@gmail.com> wrote:
> # HG changeset patch
> # User Gregory Szorc <gregory.szorc@gmail.com>
> # Date 1496536372 25200
> #      Sat Jun 03 17:32:52 2017 -0700
> # Node ID 0d9883e1033ff9da6df5906a375b393a98922ca8
> # Parent  7714abde10367a3a9cc8fa7445fe0057ba556631
> tests: removed ReportedTest exception

Queued, thanks.

Patch

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -717,8 +717,6 @@  class Test(unittest.TestCase):
                 # test we "ran", but we want to exclude skipped tests
                 # from those we count towards those run.
                 result.testsRun -= 1
-            except ReportedTest as e:
-                pass
             except self.failureException as e:
                 # This differs from unittest in that we don't capture
                 # the stack trace. This is for historical reasons and
@@ -1479,9 +1477,6 @@  class TTest(Test):
 
 iolock = threading.RLock()
 
-class ReportedTest(Exception):
-    """Raised to indicate that a test already reported."""
-
 class TestResult(unittest._TextTestResult):
     """Holds results when executing via unittest."""
     # Don't worry too much about accessing the non-public _TextTestResult.
@@ -1578,10 +1573,8 @@  class TestResult(unittest._TextTestResul
                 servefail, lines = getdiff(expected, got,
                                            test.refpath, test.errpath)
                 if servefail:
-                    self.addFailure(
-                        test,
+                    raise test.failureException(
                         'server failed to start (HGPORT=%s)' % test._startport)
-                    raise ReportedTest('server failed to start')
                 else:
                     self.stream.write('\n')
                     for line in lines: