summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xselftest/filter-subunit5
-rw-r--r--selftest/subunithelper.py13
2 files changed, 14 insertions, 4 deletions
diff --git a/selftest/filter-subunit b/selftest/filter-subunit
index 9b46d616f4..3ec74c46c7 100755
--- a/selftest/filter-subunit
+++ b/selftest/filter-subunit
@@ -50,4 +50,7 @@ msg_ops = subunithelper.FilterOps(out, opts.prefix, expected_failures,
opts.strip_passed_output,
fail_immediately=opts.fail_immediately)
-sys.exit(subunithelper.parse_results(msg_ops, statistics, sys.stdin))
+try:
+ sys.exit(subunithelper.parse_results(msg_ops, statistics, sys.stdin))
+except subunithelper.ImmediateFail:
+ sys.exit(1)
diff --git a/selftest/subunithelper.py b/selftest/subunithelper.py
index c9d3daaaba..163f2ba7db 100644
--- a/selftest/subunithelper.py
+++ b/selftest/subunithelper.py
@@ -222,6 +222,13 @@ def find_in_list(regexes, fullname):
return None
+class ImmediateFail(Exception):
+ """Raised to abort immediately."""
+
+ def __init__(self):
+ super(ImmediateFail, self).__init__("test failed and fail_immediately set")
+
+
class FilterOps(testtools.testresult.TestResult):
def control_msg(self, msg):
@@ -259,7 +266,7 @@ class FilterOps(testtools.testresult.TestResult):
self._ops.addError(test, details)
self.output = None
if self.fail_immediately:
- raise Exception("test failed and fail_immediately set")
+ raise ImmediateFail()
def addSkip(self, test, details=None):
test = self._add_prefix(test)
@@ -288,9 +295,9 @@ class FilterOps(testtools.testresult.TestResult):
self._ops.addFailure(test, details)
if self.output:
self._ops.output_msg(self.output)
+ if self.fail_immediately:
+ raise ImmediateFail()
self.output = None
- if self.fail_immediately:
- raise Exception("test failed and fail_immediately set")
def addSuccess(self, test, details=None):
test = self._add_prefix(test)