diff options
author | John Arbash Meinel <john@arbash-meinel.com> | 2010-08-24 17:41:12 -0500 |
---|---|---|
committer | John Arbash Meinel <john@arbash-meinel.com> | 2010-08-24 17:41:12 -0500 |
commit | 8fa9c2b1ac2ab8e9b4df8d6506965d47839e0240 (patch) | |
tree | ea125220c058d91b65cf0117b1b3228d9473a82b | |
parent | 7a7a14024f445a18bbdab8a7dbfe45328ae6e5d6 (diff) | |
download | subunit-8fa9c2b1ac2ab8e9b4df8d6506965d47839e0240.tar.gz |
(bug #623642) Add --no-xfail and -F to subunit-filter.
The existing --no-success only filtered out genuine success cases. Now we
can filter everything down to stuff that would actually be considered a
'failure'.
-rw-r--r-- | NEWS | 10 | ||||
-rwxr-xr-x | filters/subunit-filter | 22 | ||||
-rw-r--r-- | python/subunit/test_results.py | 7 |
3 files changed, 34 insertions, 5 deletions
@@ -5,6 +5,16 @@ subunit release notes NEXT (In development) --------------------- +BUG FIXES +~~~~~~~~~ + +* Add 'subunit --no-xfail', which will omit expected failures from the subunit + stream. (John Arbash Meinel, #623642) + +* Add 'subunit -F/--only-genuine-failures' which sets all of '--no-skips', + '--no-xfail', '--no-passthrough, '--no-success', and gives you just the + failure stream. (John Arbash Meinel) + 0.0.6 ----- diff --git a/filters/subunit-filter b/filters/subunit-filter index c06a03a..ffd43e5 100755 --- a/filters/subunit-filter +++ b/filters/subunit-filter @@ -51,18 +51,34 @@ parser.add_option("--no-passthrough", action="store_true", help="Hide all non subunit input.", default=False, dest="no_passthrough") parser.add_option("-s", "--success", action="store_false", help="include successes", dest="success") -parser.add_option("--no-skip", action="store_true", - help="exclude skips", dest="skip") parser.add_option("--no-success", action="store_true", help="exclude successes", default=True, dest="success") +parser.add_option("--no-skip", action="store_true", + help="exclude skips", dest="skip") +parser.add_option("--xfail", action="store_false", + help="include expected falures", default=True, dest="xfail") +parser.add_option("--no-xfail", action="store_true", + help="exclude expected falures", default=True, dest="xfail") parser.add_option("-m", "--with", type=str, help="regexp to include (case-sensitive by default)", action="append", dest="with_regexps") parser.add_option("--without", type=str, help="regexp to exclude (case-sensitive by default)", action="append", dest="without_regexps") +# TODO: This could be done as a callback to allow following options to override +# parts. As is, we just use it as a big hammer... +parser.add_option("-F", "--only-genuine-failures", action="store_true", + default=False, + help="Only pass through failures and exceptions.") (options, args) = parser.parse_args() +if options.only_genuine_failures: + options.success = True + options.skip = True + options.xfail = True + options.no_passthrough = True + # options.error = False + # options.failures = False def _compile_re_from_list(l): @@ -94,7 +110,7 @@ regexp_filter = _make_regexp_filter(options.with_regexps, result = TestProtocolClient(sys.stdout) result = TestResultFilter(result, filter_error=options.error, filter_failure=options.failure, filter_success=options.success, - filter_skip=options.skip, + filter_skip=options.skip, filter_xfail=options.xfail, filter_predicate=regexp_filter) if options.no_passthrough: passthrough_stream = DiscardStream() diff --git a/python/subunit/test_results.py b/python/subunit/test_results.py index 1c91daa..cc588d2 100644 --- a/python/subunit/test_results.py +++ b/python/subunit/test_results.py @@ -208,7 +208,7 @@ class TestResultFilter(TestResultDecorator): """ def __init__(self, result, filter_error=False, filter_failure=False, - filter_success=True, filter_skip=False, + filter_success=True, filter_skip=False, filter_xfail=False, filter_predicate=None): """Create a FilterResult object filtering to result. @@ -216,6 +216,7 @@ class TestResultFilter(TestResultDecorator): :param filter_failure: Filter out failures. :param filter_success: Filter out successful tests. :param filter_skip: Filter out skipped tests. + :param filter_xfail: Filter out expected failure tests. :param filter_predicate: A callable taking (test, outcome, err, details) and returning True if the result should be passed through. err and details may be none if no error or extra @@ -227,6 +228,7 @@ class TestResultFilter(TestResultDecorator): self._filter_failure = filter_failure self._filter_success = filter_success self._filter_skip = filter_skip + self._filter_xfail = filter_xfail if filter_predicate is None: filter_predicate = lambda test, outcome, err, details: True self.filter_predicate = filter_predicate @@ -270,7 +272,8 @@ class TestResultFilter(TestResultDecorator): self._filtered() def addExpectedFailure(self, test, err=None, details=None): - if self.filter_predicate(test, 'expectedfailure', err, details): + if (not self._filter_xfail and + self.filter_predicate(test, 'expectedfailure', err, details)): self.decorated.startTest(test) return self.decorated.addExpectedFailure(test, err, details=details) |