summaryrefslogtreecommitdiff
path: root/selftest
diff options
context:
space:
mode:
Diffstat (limited to 'selftest')
-rwxr-xr-xselftest/filter-subunit5
-rw-r--r--selftest/subunithelper.py8
2 files changed, 11 insertions, 2 deletions
diff --git a/selftest/filter-subunit b/selftest/filter-subunit
index f5ab660350..9b46d616f4 100755
--- a/selftest/filter-subunit
+++ b/selftest/filter-subunit
@@ -19,6 +19,8 @@ parser.add_option("--expected-failures", type="string",
"failures")
parser.add_option("--strip-passed-output", action="store_true",
help="Whether to strip output from tests that passed")
+parser.add_option("--fail-immediately", action="store_true",
+ help="Whether to stop on the first error", default=False)
parser.add_option("--prefix", type="string",
help="Add prefix to all test names")
@@ -45,6 +47,7 @@ signal.signal(signal.SIGINT, handle_sigint)
out = subunithelper.SubunitOps(sys.stdout)
msg_ops = subunithelper.FilterOps(out, opts.prefix, expected_failures,
- opts.strip_passed_output)
+ opts.strip_passed_output,
+ fail_immediately=opts.fail_immediately)
sys.exit(subunithelper.parse_results(msg_ops, statistics, sys.stdin))
diff --git a/selftest/subunithelper.py b/selftest/subunithelper.py
index 2a5d9ecc20..c9d3daaaba 100644
--- a/selftest/subunithelper.py
+++ b/selftest/subunithelper.py
@@ -258,6 +258,8 @@ class FilterOps(testtools.testresult.TestResult):
self.total_error+=1
self._ops.addError(test, details)
self.output = None
+ if self.fail_immediately:
+ raise Exception("test failed and fail_immediately set")
def addSkip(self, test, details=None):
test = self._add_prefix(test)
@@ -287,6 +289,8 @@ class FilterOps(testtools.testresult.TestResult):
if self.output:
self._ops.output_msg(self.output)
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)
@@ -327,7 +331,7 @@ class FilterOps(testtools.testresult.TestResult):
self._ops.end_testsuite(name, result, reason)
- def __init__(self, out, prefix, expected_failures, strip_ok_output):
+ def __init__(self, out, prefix, expected_failures, strip_ok_output, fail_immediately=False):
self._ops = out
self.output = None
self.prefix = prefix
@@ -339,3 +343,5 @@ class FilterOps(testtools.testresult.TestResult):
self.total_error = 0
self.total_fail = 0
self.error_added = 0
+ self.fail_immediately = fail_immediately
+