diff options
author | Jonathan Lange <jml@mumak.net> | 2012-03-27 11:52:50 +0100 |
---|---|---|
committer | Jonathan Lange <jml@mumak.net> | 2012-03-27 11:52:50 +0100 |
commit | f4da65cf39c91fe5a95c282e26f5d6a19a8d845f (patch) | |
tree | 178cad5309c91125ff9b25a9a732f9905867af00 /filters | |
parent | 86289bccd89206bc1fe1aa2ce34954c388fd8353 (diff) | |
download | subunit-f4da65cf39c91fe5a95c282e26f5d6a19a8d845f.tar.gz |
Factor out JUnitXML
Diffstat (limited to 'filters')
-rwxr-xr-x | filters/subunit2csv | 6 | ||||
-rwxr-xr-x | filters/subunit2junitxml | 42 |
2 files changed, 5 insertions, 43 deletions
diff --git a/filters/subunit2csv b/filters/subunit2csv index 74b7944..0357b1d 100755 --- a/filters/subunit2csv +++ b/filters/subunit2csv @@ -14,14 +14,10 @@ # limitations under that license. # -# XXX: This is almost exactly the same as subunit2junitxml. The only -# difference is that we instantiate 'CsvResult' rather than 'JUnitXmlResult'. -# Consider factoring this out into a common script helper. - """Turn a subunit stream into a CSV""" from subunit.filters import main from subunit.test_results import CsvResult -main(CsvResult) +main(CsvResult, __doc__) diff --git a/filters/subunit2junitxml b/filters/subunit2junitxml index bea795d..18d170e 100755 --- a/filters/subunit2junitxml +++ b/filters/subunit2junitxml @@ -16,11 +16,10 @@ """Filter a subunit stream to get aggregate statistics.""" -from optparse import OptionParser + import sys -import unittest +from subunit.filters import main -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) + +main(JUnitXmlResult, __doc__) |