summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xselftest/filter-subunit11
-rw-r--r--selftest/subunithelper.py3
2 files changed, 11 insertions, 3 deletions
diff --git a/selftest/filter-subunit b/selftest/filter-subunit
index 872d07fdb1..84b6610480 100755
--- a/selftest/filter-subunit
+++ b/selftest/filter-subunit
@@ -21,10 +21,10 @@ 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")
-
+parser.add_option("--fail-on-empty", default=False,
+ action="store_true", help="Fail if there was no subunit output")
opts, args = parser.parse_args()
if opts.expected_failures:
@@ -51,7 +51,12 @@ msg_ops = subunithelper.FilterOps(out, opts.prefix, expected_failures,
fail_immediately=opts.fail_immediately)
try:
- sys.exit(subunithelper.parse_results(msg_ops, statistics, sys.stdin))
+ ret = subunithelper.parse_results(msg_ops, statistics, sys.stdin)
except subunithelper.ImmediateFail:
sys.stdout.flush()
sys.exit(1)
+
+if opts.fail_on_empty and not msg_ops.seen_output:
+ sys.exit(1)
+else:
+ sys.exit(ret)
diff --git a/selftest/subunithelper.py b/selftest/subunithelper.py
index b9291b8f25..5d2d665825 100644
--- a/selftest/subunithelper.py
+++ b/selftest/subunithelper.py
@@ -247,6 +247,7 @@ class FilterOps(testtools.testresult.TestResult):
self.output+=msg
def startTest(self, test):
+ self.seen_output = True
test = self._add_prefix(test)
if self.strip_ok_output:
self.output = ""
@@ -269,6 +270,7 @@ class FilterOps(testtools.testresult.TestResult):
raise ImmediateFail()
def addSkip(self, test, details=None):
+ self.seen_output = True
test = self._add_prefix(test)
self._ops.addSkip(test, details)
self.output = None
@@ -341,6 +343,7 @@ class FilterOps(testtools.testresult.TestResult):
def __init__(self, out, prefix=None, expected_failures=None,
strip_ok_output=False, fail_immediately=False):
self._ops = out
+ self.seen_output = False
self.output = None
self.prefix = prefix
if expected_failures is not None: