summaryrefslogtreecommitdiff
path: root/python/subunit
diff options
context:
space:
mode:
Diffstat (limited to 'python/subunit')
-rw-r--r--python/subunit/filters.py16
1 files changed, 14 insertions, 2 deletions
diff --git a/python/subunit/filters.py b/python/subunit/filters.py
index 0bab9ed..f8ce2dd 100644
--- a/python/subunit/filters.py
+++ b/python/subunit/filters.py
@@ -18,7 +18,6 @@ from optparse import OptionParser
import sys
from subunit import DiscardStream, ProtocolTestCase
-from subunit.test_results import CsvResult
def make_options(description):
@@ -106,7 +105,20 @@ def filter_by_result(result_factory, output_path, no_passthrough, forward,
return 1
-def main(result_factory, description):
+def run_filter_script(result_factory, description):
+ """Main function for simple subunit filter scripts.
+
+ Many subunit filter scripts take a stream of subunit input and use a
+ TestResult to handle the events generated by that stream. This function
+ wraps a lot of the boiler-plate around that by making a script with
+ options for handling passthrough information and stream forwarding, and
+ that will exit with a successful return code (i.e. 0) if the input stream
+ represents a successful test run.
+
+ :param result_factory: A callable that takes an output stream and returns
+ a test result that outputs to that stream.
+ :param description: A description of the filter script.
+ """
parser = make_options(description)
(options, args) = parser.parse_args()
sys.exit(