summaryrefslogtreecommitdiff
path: root/selftest
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2010-09-28 07:10:43 +0200
committerJelmer Vernooij <jelmer@samba.org>2010-09-28 09:12:39 +0200
commit7ac4a710725d1e439179c3846525b3245dc3f5f6 (patch)
tree77467f38e536730db3e3c7cb5be3326047505fd5 /selftest
parentc12f1a1e912aeca8645b68c0ef720466c13ce8bb (diff)
downloadsamba-7ac4a710725d1e439179c3846525b3245dc3f5f6.tar.gz
samba-7ac4a710725d1e439179c3846525b3245dc3f5f6.tar.bz2
samba-7ac4a710725d1e439179c3846525b3245dc3f5f6.zip
Add dedicated exception for immediate failure in filter-subunit, don't raise it on known exceptions.
Diffstat (limited to 'selftest')
-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)