From c960118f3bcefc95deb3499e655c3ef0d6f9981c Mon Sep 17 00:00:00 2001 From: Robert Collins Date: Mon, 25 Feb 2013 23:21:38 +1300 Subject: [PATCH] Add basic 1to2 and 2to1 filters. --- Makefile.am | 2 ++ filters/subunit-1to2 | 42 ++++++++++++++++++++++++++++++++++++++++ filters/subunit-2to1 | 46 ++++++++++++++++++++++++++++++++++++++++++++ setup.py | 2 ++ 4 files changed, 92 insertions(+) create mode 100755 filters/subunit-1to2 create mode 100755 filters/subunit-2to1 diff --git a/Makefile.am b/Makefile.am index da16020..dfc3d2f 100644 --- a/Makefile.am +++ b/Makefile.am @@ -47,6 +47,8 @@ ACLOCAL_AMFLAGS = -I m4 include_subunitdir = $(includedir)/subunit dist_bin_SCRIPTS = \ + filters/subunit-1to2 \ + filters/subunit-2to1 \ filters/subunit-filter \ filters/subunit-ls \ filters/subunit-notify \ diff --git a/filters/subunit-1to2 b/filters/subunit-1to2 new file mode 100755 index 0000000..bfb6658 --- /dev/null +++ b/filters/subunit-1to2 @@ -0,0 +1,42 @@ +#!/usr/bin/env python +# subunit: extensions to python unittest to get test results from subprocesses. +# Copyright (C) 2013 Robert Collins +# +# Licensed under either the Apache License, Version 2.0 or the BSD 3-clause +# license at the users choice. A copy of both licenses are available in the +# project source as Apache-2.0 and BSD. You may not use this file except in +# compliance with one of these two licences. +# +# Unless required by applicable law or agreed to in writing, software +# distributed under these licenses is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# license you chose for the specific language governing permissions and +# limitations under that license. +# + +"""Convert a version 1 subunit stream to version 2 stream.""" + +from optparse import OptionParser +import sys + +from testtools import ExtendedToStreamDecorator + +from subunit import StreamResultToBytes +from subunit.filters import run_tests_from_stream + + +def make_options(description): + parser = OptionParser(description=__doc__) + return parser + + +def main(): + parser = make_options(__doc__) + (options, args) = parser.parse_args() + run_tests_from_stream(sys.stdin, + ExtendedToStreamDecorator(StreamResultToBytes(sys.stdout))) + sys.exit(0) + + +if __name__ == '__main__': + main() diff --git a/filters/subunit-2to1 b/filters/subunit-2to1 new file mode 100755 index 0000000..ed210f9 --- /dev/null +++ b/filters/subunit-2to1 @@ -0,0 +1,46 @@ +#!/usr/bin/env python +# subunit: extensions to python unittest to get test results from subprocesses. +# Copyright (C) 2013 Robert Collins +# +# Licensed under either the Apache License, Version 2.0 or the BSD 3-clause +# license at the users choice. A copy of both licenses are available in the +# project source as Apache-2.0 and BSD. You may not use this file except in +# compliance with one of these two licences. +# +# Unless required by applicable law or agreed to in writing, software +# distributed under these licenses is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# license you chose for the specific language governing permissions and +# limitations under that license. +# + +"""Convert a version 2 subunit stream to a version 1 stream.""" + +from optparse import OptionParser +import sys + +from testtools import StreamToExtendedDecorator + +from subunit import ByteStreamToStreamResult, TestProtocolClient +from subunit.filters import run_tests_from_stream + + +def make_options(description): + parser = OptionParser(description=__doc__) + return parser + + +def main(): + parser = make_options(__doc__) + (options, args) = parser.parse_args() + case = ByteStreamToStreamResult(sys.stdin) + result = StreamToExtendedDecorator(TestProtocolClient(sys.stdout)) + # What about stdout chunks? + result.startTestRun() + case.run(result) + result.stopTestRun() + sys.exit(0) + + +if __name__ == '__main__': + main() diff --git a/setup.py b/setup.py index 1a0b192..947554b 100755 --- a/setup.py +++ b/setup.py @@ -49,6 +49,8 @@ setup( packages=['subunit', 'subunit.tests'], package_dir={'subunit': 'python/subunit'}, scripts = [ + 'filters/subunit-1to2', + 'filters/subunit-2to1', 'filters/subunit2gtk', 'filters/subunit2junitxml', 'filters/subunit2pyunit',