Progress, of a sort.
[third_party/subunit] / filters / subunit-filter
index 66759ff59868da110f92982d7dea8409615c5d55..017eddd208e33a26386162f4fe24379201157699 100755 (executable)
@@ -36,7 +36,11 @@ from subunit import (
     TestProtocolClient,
     read_test_list,
     )
-from subunit.test_results import TestResultFilter
+from subunit.test_results import (
+    and_predicates,
+    _make_tag_filter,
+    TestResultFilter,
+    )
 
 parser = OptionParser(description=__doc__)
 parser.add_option("--error", action="store_false",
@@ -61,6 +65,12 @@ 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(
+    "--with-tag", type=str,
+    help="include tests with these tags", action="append", dest="with_tags")
+parser.add_option(
+    "--without-tag", type=str,
+    help="exclude tests with these tags", action="append", dest="without_tags")
 parser.add_option("-m", "--with", type=str,
     help="regexp to include (case-sensitive by default)",
     action="append", dest="with_regexps")
@@ -110,6 +120,10 @@ def _make_regexp_filter(with_regexps, without_regexps):
 
 regexp_filter = _make_regexp_filter(options.with_regexps,
         options.without_regexps)
+tag_filter = _make_tag_filter(options.with_tags, options.without_tags)
+
+filter_predicate = and_predicates([regexp_filter, tag_filter])
+
 fixup_expected_failures = set()
 for path in options.fixup_expected_failures or ():
     fixup_expected_failures.update(read_test_list(path))
@@ -117,7 +131,7 @@ result = TestProtocolClient(sys.stdout)
 result = TestResultFilter(result, filter_error=options.error,
     filter_failure=options.failure, filter_success=options.success,
     filter_skip=options.skip, filter_xfail=options.xfail,
-    filter_predicate=regexp_filter,
+    filter_predicate=tag_filter,
     fixup_expected_failures=fixup_expected_failures)
 if options.no_passthrough:
     passthrough_stream = DiscardStream()