subunit: Update to latest upstream version.
[nivanova/samba-autobuild/.git] / lib / subunit / filters / subunit2junitxml
index bea795d2bdd801f546c41e1d2b6d6dbcefd79ccc..d568c71dd4a668cb0857d6d6ee0456bdd3dba252 100755 (executable)
 
 """Filter a subunit stream to get aggregate statistics."""
 
-from optparse import OptionParser
+
 import sys
-import unittest
+from subunit.filters import run_filter_script
 
-from subunit import DiscardStream, ProtocolTestCase
 try:
     from junitxml import JUnitXmlResult
 except ImportError:
@@ -28,38 +27,5 @@ except ImportError:
         "http://pypi.python.org/pypi/junitxml) is required for this filter.")
     raise
 
-parser = OptionParser(description=__doc__)
-parser.add_option("--no-passthrough", action="store_true",
-    help="Hide all non subunit input.", default=False, dest="no_passthrough")
-parser.add_option("-o", "--output-to",
-    help="Output the XML to this path rather than stdout.")
-parser.add_option("-f", "--forward", action="store_true", default=False,
-    help="Forward subunit stream on stdout.")
-(options, args) = parser.parse_args()
-if options.output_to is None:
-    output_to = sys.stdout
-else:
-    output_to = file(options.output_to, 'wb')
-try:
-    result = JUnitXmlResult(output_to)
-    if options.no_passthrough:
-        passthrough_stream = DiscardStream()
-    else:
-        passthrough_stream = None
-    if options.forward:
-        forward_stream = sys.stdout
-    else:
-        forward_stream = None
-    test = ProtocolTestCase(sys.stdin, passthrough=passthrough_stream,
-       forward=forward_stream)
-    result.startTestRun()
-    test.run(result)
-    result.stopTestRun()
-finally:
-    if options.output_to is not None:
-        output_to.close()
-if result.wasSuccessful():
-    exit_code = 0
-else:
-    exit_code = 1
-sys.exit(exit_code)
+
+run_filter_script(JUnitXmlResult, __doc__)