summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@jelmer.uk>2022-11-05 19:50:47 +0000
committerJelmer Vernooij <jelmer@jelmer.uk>2022-11-05 19:50:47 +0000
commita9508172f4e3adf38ff5c132216f74f77339c0d2 (patch)
tree49d2e4cbc855e6d06b2e2624d952a058dfb3b735
parent966545998f7fb94400fe262dccc48f1e858dd661 (diff)
parent73451b78c45941ed83c33ed1a2cbf01ef9c650ff (diff)
downloadsubunit-git-a9508172f4e3adf38ff5c132216f74f77339c0d2.tar.gz
Merge branch 'fix-filter-entrypoints' of https://github.com/mtreinish/subunit
-rw-r--r--Makefile.am52
-rwxr-xr-xfilters/subunit-ls60
-rwxr-xr-xfilters/subunit2pyunit59
-rw-r--r--python/subunit/filter_scripts/__init__.py0
-rwxr-xr-xpython/subunit/filter_scripts/subunit2csv.py (renamed from filters/subunit2csv)9
-rwxr-xr-xpython/subunit/filter_scripts/subunit2disk.py (renamed from filters/subunit2disk)8
-rwxr-xr-xpython/subunit/filter_scripts/subunit2gtk.py (renamed from filters/subunit2gtk)66
-rwxr-xr-xpython/subunit/filter_scripts/subunit2junitxml.py (renamed from filters/subunit2junitxml)13
-rwxr-xr-xpython/subunit/filter_scripts/subunit2pyunit.py67
-rwxr-xr-xpython/subunit/filter_scripts/subunit_1to2.py (renamed from filters/subunit-1to2)2
-rwxr-xr-xpython/subunit/filter_scripts/subunit_2to1.py (renamed from filters/subunit-2to1)4
-rwxr-xr-xpython/subunit/filter_scripts/subunit_filter.py (renamed from filters/subunit-filter)6
-rwxr-xr-xpython/subunit/filter_scripts/subunit_ls.py65
-rwxr-xr-xpython/subunit/filter_scripts/subunit_notify.py (renamed from filters/subunit-notify)11
-rwxr-xr-xpython/subunit/filter_scripts/subunit_output.py (renamed from filters/subunit-output)7
-rwxr-xr-xpython/subunit/filter_scripts/subunit_stats.py (renamed from filters/subunit-stats)18
-rwxr-xr-xpython/subunit/filter_scripts/subunit_tags.py (renamed from filters/subunit-tags)8
-rwxr-xr-xpython/subunit/filter_scripts/tap2subunit.py (renamed from filters/tap2subunit)9
-rw-r--r--python/subunit/tests/test_subunit_filter.py5
-rwxr-xr-xsetup.py37
20 files changed, 256 insertions, 250 deletions
diff --git a/Makefile.am b/Makefile.am
index 1053348..fedcbb2 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -16,29 +16,6 @@ EXTRA_DIST = \
perl/lib/Subunit.pm \
perl/lib/Subunit/Diff.pm \
perl/subunit-diff \
- python/iso8601/LICENSE \
- python/iso8601/README \
- python/iso8601/README.subunit \
- python/iso8601/setup.py \
- python/iso8601/test_iso8601.py \
- python/subunit/tests/__init__.py \
- python/subunit/tests/sample-script.py \
- python/subunit/tests/sample-two-script.py \
- python/subunit/tests/test_chunked.py \
- python/subunit/tests/test_details.py \
- python/subunit/tests/test_filters.py \
- python/subunit/tests/test_filter_to_disk.py \
- python/subunit/tests/test_output_filter.py \
- python/subunit/tests/test_progress_model.py \
- python/subunit/tests/test_run.py \
- python/subunit/tests/test_subunit_filter.py \
- python/subunit/tests/test_subunit_stats.py \
- python/subunit/tests/test_subunit_tags.py \
- python/subunit/tests/test_tap2subunit.py \
- python/subunit/tests/test_test_protocol.py \
- python/subunit/tests/test_test_protocol2.py \
- python/subunit/tests/test_test_results.py \
- setup.py \
shell/README \
shell/share/subunit.sh \
shell/subunit-ui.patch \
@@ -49,22 +26,6 @@ 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 \
- filters/subunit-output \
- filters/subunit-stats \
- filters/subunit-tags \
- filters/subunit2csv \
- filters/subunit2disk \
- filters/subunit2gtk \
- filters/subunit2junitxml \
- filters/subunit2pyunit \
- filters/tap2subunit
-
TESTS = $(check_PROGRAMS)
## install libsubunit.pc
@@ -73,19 +34,6 @@ pcdata_DATA = \
libsubunit.pc \
libcppunit_subunit.pc
-pkgpython_PYTHON = \
- python/subunit/__init__.py \
- python/subunit/chunked.py \
- python/subunit/details.py \
- python/subunit/filters.py \
- python/subunit/iso8601.py \
- python/subunit/progress_model.py \
- python/subunit/run.py \
- python/subunit/v2.py \
- python/subunit/test_results.py \
- python/subunit/_output.py \
- python/subunit/_to_disk.py
-
lib_LTLIBRARIES = libsubunit.la
lib_LTLIBRARIES += libcppunit_subunit.la
diff --git a/filters/subunit-ls b/filters/subunit-ls
deleted file mode 100755
index 0e61d27..0000000
--- a/filters/subunit-ls
+++ /dev/null
@@ -1,60 +0,0 @@
-#!/usr/bin/env python3
-# subunit: extensions to python unittest to get test results from subprocesses.
-# Copyright (C) 2008 Robert Collins <robertc@robertcollins.net>
-#
-# 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.
-#
-
-"""List tests in a subunit stream."""
-
-from optparse import OptionParser
-import sys
-
-from testtools import (
- CopyStreamResult, StreamToExtendedDecorator, StreamResultRouter,
- StreamSummary)
-
-from subunit import ByteStreamToStreamResult
-from subunit.filters import find_stream, run_tests_from_stream
-from subunit.test_results import (
- CatFiles,
- TestIdPrintingResult,
- )
-
-
-parser = OptionParser(description=__doc__)
-parser.add_option("--times", action="store_true",
- help="list the time each test took (requires a timestamped stream)",
- default=False)
-parser.add_option("--exists", action="store_true",
- help="list tests that are reported as existing (as well as ran)",
- default=False)
-parser.add_option("--no-passthrough", action="store_true",
- help="Hide all non subunit input.", default=False, dest="no_passthrough")
-(options, args) = parser.parse_args()
-test = ByteStreamToStreamResult(
- find_stream(sys.stdin, args), non_subunit_name="stdout")
-result = TestIdPrintingResult(sys.stdout, options.times, options.exists)
-if not options.no_passthrough:
- result = StreamResultRouter(result)
- cat = CatFiles(sys.stdout)
- result.add_rule(cat, 'test_id', test_id=None)
-summary = StreamSummary()
-result = CopyStreamResult([result, summary])
-result.startTestRun()
-test.run(result)
-result.stopTestRun()
-if summary.wasSuccessful():
- exit_code = 0
-else:
- exit_code = 1
-sys.exit(exit_code)
diff --git a/filters/subunit2pyunit b/filters/subunit2pyunit
deleted file mode 100755
index 3b7d23e..0000000
--- a/filters/subunit2pyunit
+++ /dev/null
@@ -1,59 +0,0 @@
-#!/usr/bin/env python3
-# subunit: extensions to python unittest to get test results from subprocesses.
-# Copyright (C) 2009 Robert Collins <robertc@robertcollins.net>
-#
-# 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.
-#
-
-"""Display a subunit stream through python's unittest test runner."""
-
-from operator import methodcaller
-from optparse import OptionParser
-import sys
-import unittest
-
-from testtools import StreamToExtendedDecorator, DecorateTestCaseResult, StreamResultRouter
-
-from subunit import ByteStreamToStreamResult
-from subunit.filters import find_stream
-from subunit.test_results import CatFiles
-
-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("--progress", action="store_true",
- help="Use bzrlib's test reporter (requires bzrlib)",
- default=False)
-(options, args) = parser.parse_args()
-test = ByteStreamToStreamResult(
- find_stream(sys.stdin, args), non_subunit_name='stdout')
-def wrap_result(result):
- result = StreamToExtendedDecorator(result)
- if not options.no_passthrough:
- result = StreamResultRouter(result)
- result.add_rule(CatFiles(sys.stdout), 'test_id', test_id=None)
- return result
-test = DecorateTestCaseResult(test, wrap_result,
- before_run=methodcaller('startTestRun'),
- after_run=methodcaller('stopTestRun'))
-if options.progress:
- from bzrlib.tests import TextTestRunner
- from bzrlib import ui
- ui.ui_factory = ui.make_ui_for_terminal(None, sys.stdout, sys.stderr)
- runner = TextTestRunner()
-else:
- runner = unittest.TextTestRunner(verbosity=2)
-if runner.run(test).wasSuccessful():
- exit_code = 0
-else:
- exit_code = 1
-sys.exit(exit_code)
diff --git a/python/subunit/filter_scripts/__init__.py b/python/subunit/filter_scripts/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/python/subunit/filter_scripts/__init__.py
diff --git a/filters/subunit2csv b/python/subunit/filter_scripts/subunit2csv.py
index abbd57f..c8e48a5 100755
--- a/filters/subunit2csv
+++ b/python/subunit/filter_scripts/subunit2csv.py
@@ -22,5 +22,10 @@ from subunit.filters import run_filter_script
from subunit.test_results import CsvResult
-run_filter_script(lambda output:StreamToExtendedDecorator(CsvResult(output)),
- __doc__, protocol_version=2)
+def main():
+ run_filter_script(lambda output: StreamToExtendedDecorator(
+ CsvResult(output)), __doc__, protocol_version=2)
+
+
+if __name__ == '__main__':
+ main()
diff --git a/filters/subunit2disk b/python/subunit/filter_scripts/subunit2disk.py
index 134fe53..da1c09c 100755
--- a/filters/subunit2disk
+++ b/python/subunit/filter_scripts/subunit2disk.py
@@ -16,8 +16,14 @@
"""Export a stream to files and directories on disk."""
+import sys
+
from subunit._to_disk import to_disk
+def main():
+ sys.exit(to_disk())
+
+
if __name__ == '__main__':
- exit(to_disk())
+ main()
diff --git a/filters/subunit2gtk b/python/subunit/filter_scripts/subunit2gtk.py
index 4e0818b..bcfd1e7 100755
--- a/filters/subunit2gtk
+++ b/python/subunit/filter_scripts/subunit2gtk.py
@@ -6,7 +6,7 @@
# 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
@@ -16,28 +16,28 @@
### The GTK progress bar __init__ function is derived from the pygtk tutorial:
# The PyGTK Tutorial is Copyright (C) 2001-2005 John Finlay.
-#
+#
# The GTK Tutorial is Copyright (C) 1997 Ian Main.
-#
+#
# Copyright (C) 1998-1999 Tony Gale.
-#
+#
# Permission is granted to make and distribute verbatim copies of this manual
# provided the copyright notice and this permission notice are preserved on all
# copies.
-#
+#
# Permission is granted to copy and distribute modified versions of this
# document under the conditions for verbatim copying, provided that this
# copyright notice is included exactly as in the original, and that the entire
# resulting derived work is distributed under the terms of a permission notice
# identical to this one.
-#
+#
# Permission is granted to copy and distribute translations of this document
# into another language, under the above conditions for modified versions.
-#
+#
# If you are intending to incorporate this document into a published work,
# please contact the maintainer, and we will make an effort to ensure that you
# have the most up to date information available.
-#
+#
# There is no guarantee that this document lives up to its intended purpose.
# This is simply provided as a free resource. As such, the authors and
# maintainers of the information provided within can not make any guarantee
@@ -208,27 +208,29 @@ class GTKTestResult(unittest.TestResult):
self.not_ok_label.set_text(str(bad))
-GObject.threads_init()
-result = StreamToExtendedDecorator(GTKTestResult())
-test = ByteStreamToStreamResult(sys.stdin, non_subunit_name='stdout')
-# Get setup
-while Gtk.events_pending():
- Gtk.main_iteration()
-
-
-# Start IO
-def run_and_finish():
- test.run(result)
- result.stopTestRun()
-
-
-t = threading.Thread(target=run_and_finish)
-t.daemon = True
-result.startTestRun()
-t.start()
-Gtk.main()
-if result.decorated.wasSuccessful():
- exit_code = 0
-else:
- exit_code = 1
-sys.exit(exit_code)
+def main():
+ GObject.threads_init()
+ result = StreamToExtendedDecorator(GTKTestResult())
+ test = ByteStreamToStreamResult(sys.stdin, non_subunit_name='stdout')
+ # Get setup
+ while Gtk.events_pending():
+ Gtk.main_iteration()
+
+ # Start IO
+ def run_and_finish():
+ test.run(result)
+ result.stopTestRun()
+ t = threading.Thread(target=run_and_finish)
+ t.daemon = True
+ result.startTestRun()
+ t.start()
+ Gtk.main()
+ if result.decorated.wasSuccessful():
+ exit_code = 0
+ else:
+ exit_code = 1
+ sys.exit(exit_code)
+
+
+if __name__ == '__main__':
+ main()
diff --git a/filters/subunit2junitxml b/python/subunit/filter_scripts/subunit2junitxml.py
index 72fafc3..db85040 100755
--- a/filters/subunit2junitxml
+++ b/python/subunit/filter_scripts/subunit2junitxml.py
@@ -6,7 +6,7 @@
# 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
@@ -31,6 +31,11 @@ except ImportError:
raise
-run_filter_script(
- lambda output:StreamToExtendedDecorator(JUnitXmlResult(output)), __doc__,
- protocol_version=2)
+def main():
+ run_filter_script(
+ lambda output: StreamToExtendedDecorator(
+ JUnitXmlResult(output)), __doc__, protocol_version=2)
+
+
+if __name__ == '__main__':
+ main()
diff --git a/python/subunit/filter_scripts/subunit2pyunit.py b/python/subunit/filter_scripts/subunit2pyunit.py
new file mode 100755
index 0000000..2a040ec
--- /dev/null
+++ b/python/subunit/filter_scripts/subunit2pyunit.py
@@ -0,0 +1,67 @@
+#!/usr/bin/env python
+# subunit: extensions to python unittest to get test results from subprocesses.
+# Copyright (C) 2009 Robert Collins <robertc@robertcollins.net>
+#
+# 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.
+#
+
+"""Display a subunit stream through python's unittest test runner."""
+
+from operator import methodcaller
+from optparse import OptionParser
+import sys
+import unittest
+
+from testtools import StreamToExtendedDecorator, DecorateTestCaseResult, StreamResultRouter
+
+from subunit import ByteStreamToStreamResult
+from subunit.filters import find_stream
+from subunit.test_results import CatFiles
+
+
+def main():
+ 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("--progress", action="store_true",
+ help="Use bzrlib's test reporter (requires bzrlib)",
+ default=False)
+ (options, args) = parser.parse_args()
+ test = ByteStreamToStreamResult(
+ find_stream(sys.stdin, args), non_subunit_name='stdout')
+
+ def wrap_result(result):
+ result = StreamToExtendedDecorator(result)
+ if not options.no_passthrough:
+ result = StreamResultRouter(result)
+ result.add_rule(CatFiles(sys.stdout), 'test_id', test_id=None)
+ return result
+ test = DecorateTestCaseResult(test, wrap_result,
+ before_run=methodcaller('startTestRun'),
+ after_run=methodcaller('stopTestRun'))
+ if options.progress:
+ from bzrlib.tests import TextTestRunner
+ from bzrlib import ui
+ ui.ui_factory = ui.make_ui_for_terminal(None, sys.stdout, sys.stderr)
+ runner = TextTestRunner()
+ else:
+ runner = unittest.TextTestRunner(verbosity=2)
+ if runner.run(test).wasSuccessful():
+ exit_code = 0
+ else:
+ exit_code = 1
+ sys.exit(exit_code)
+
+
+if __name__ == '__main__':
+ main()
diff --git a/filters/subunit-1to2 b/python/subunit/filter_scripts/subunit_1to2.py
index 2b70ce4..085c0fe 100755
--- a/filters/subunit-1to2
+++ b/python/subunit/filter_scripts/subunit_1to2.py
@@ -6,7 +6,7 @@
# 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
diff --git a/filters/subunit-2to1 b/python/subunit/filter_scripts/subunit_2to1.py
index fa03442..1f2716a 100755
--- a/filters/subunit-2to1
+++ b/python/subunit/filter_scripts/subunit_2to1.py
@@ -6,7 +6,7 @@
# 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
@@ -25,7 +25,7 @@ from testtools import (
)
from subunit import ByteStreamToStreamResult, TestProtocolClient
-from subunit.filters import find_stream, run_tests_from_stream
+from subunit.filters import find_stream
from subunit.test_results import CatFiles
diff --git a/filters/subunit-filter b/python/subunit/filter_scripts/subunit_filter.py
index ce05452..951672f 100755
--- a/filters/subunit-filter
+++ b/python/subunit/filter_scripts/subunit_filter.py
@@ -7,7 +7,7 @@
# 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
@@ -33,8 +33,6 @@ import re
from testtools import ExtendedToStreamDecorator, StreamToExtendedDecorator
from subunit import (
- DiscardStream,
- ProtocolTestCase,
StreamResultToBytes,
read_test_list,
)
@@ -143,7 +141,7 @@ def _make_result(output, options, predicate):
fixup_expected_failures.update(read_test_list(path))
return StreamToExtendedDecorator(TestResultFilter(
ExtendedToStreamDecorator(
- StreamResultToBytes(output)),
+ StreamResultToBytes(output)),
filter_error=options.error,
filter_failure=options.failure,
filter_success=options.success,
diff --git a/python/subunit/filter_scripts/subunit_ls.py b/python/subunit/filter_scripts/subunit_ls.py
new file mode 100755
index 0000000..0eee267
--- /dev/null
+++ b/python/subunit/filter_scripts/subunit_ls.py
@@ -0,0 +1,65 @@
+#!/usr/bin/env python
+# subunit: extensions to python unittest to get test results from subprocesses.
+# Copyright (C) 2008 Robert Collins <robertc@robertcollins.net>
+#
+# 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.
+#
+
+"""List tests in a subunit stream."""
+
+from optparse import OptionParser
+import sys
+
+from testtools import (
+ CopyStreamResult, StreamResultRouter,
+ StreamSummary)
+
+from subunit import ByteStreamToStreamResult
+from subunit.filters import find_stream
+from subunit.test_results import (
+ CatFiles,
+ TestIdPrintingResult,
+ )
+
+
+def main():
+ parser = OptionParser(description=__doc__)
+ parser.add_option("--times", action="store_true",
+ help="list the time each test took (requires a timestamped stream)",
+ default=False)
+ parser.add_option("--exists", action="store_true",
+ help="list tests that are reported as existing (as well as ran)",
+ default=False)
+ parser.add_option("--no-passthrough", action="store_true",
+ help="Hide all non subunit input.", default=False, dest="no_passthrough")
+ (options, args) = parser.parse_args()
+ test = ByteStreamToStreamResult(
+ find_stream(sys.stdin, args), non_subunit_name="stdout")
+ result = TestIdPrintingResult(sys.stdout, options.times, options.exists)
+ if not options.no_passthrough:
+ result = StreamResultRouter(result)
+ cat = CatFiles(sys.stdout)
+ result.add_rule(cat, 'test_id', test_id=None)
+ summary = StreamSummary()
+ result = CopyStreamResult([result, summary])
+ result.startTestRun()
+ test.run(result)
+ result.stopTestRun()
+ if summary.wasSuccessful():
+ exit_code = 0
+ else:
+ exit_code = 1
+ sys.exit(exit_code)
+
+
+if __name__ == '__main__':
+ main()
diff --git a/filters/subunit-notify b/python/subunit/filter_scripts/subunit_notify.py
index e35bf67..44ca758 100755
--- a/filters/subunit-notify
+++ b/python/subunit/filter_scripts/subunit_notify.py
@@ -43,6 +43,11 @@ def notify_of_result(result):
nw.show()
-run_filter_script(
- lambda output:StreamToExtendedDecorator(TestResultStats(output)),
- __doc__, notify_of_result, protocol_version=2)
+def main():
+ run_filter_script(
+ lambda output:StreamToExtendedDecorator(TestResultStats(output)),
+ __doc__, notify_of_result, protocol_version=2)
+
+
+if __name__ == '__main__':
+ main()
diff --git a/filters/subunit-output b/python/subunit/filter_scripts/subunit_output.py
index 839baa4..a587e87 100755
--- a/filters/subunit-output
+++ b/python/subunit/filter_scripts/subunit_output.py
@@ -16,8 +16,13 @@
"""A command-line tool to generate a subunit result byte-stream."""
+import sys
+
from subunit._output import output_main
+def main():
+ sys.exit(output_main())
+
if __name__ == '__main__':
- exit(output_main())
+ main()
diff --git a/filters/subunit-stats b/python/subunit/filter_scripts/subunit_stats.py
index cc8e2e5..53814d1 100755
--- a/filters/subunit-stats
+++ b/python/subunit/filter_scripts/subunit_stats.py
@@ -24,9 +24,15 @@ from subunit import TestResultStats
from subunit.filters import run_filter_script
-result = TestResultStats(sys.stdout)
-def show_stats(r):
- r.decorated.formatStats()
-run_filter_script(
- lambda output:StreamToExtendedDecorator(result),
- __doc__, show_stats, protocol_version=2, passthrough_subunit=False)
+def main():
+ result = TestResultStats(sys.stdout)
+
+ def show_stats(r):
+ r.decorated.formatStats()
+
+ run_filter_script(
+ lambda output:StreamToExtendedDecorator(result),
+ __doc__, show_stats, protocol_version=2, passthrough_subunit=False)
+
+if __name__ == '__main__':
+ main()
diff --git a/filters/subunit-tags b/python/subunit/filter_scripts/subunit_tags.py
index 7c8cecb..31b45cc 100755
--- a/filters/subunit-tags
+++ b/python/subunit/filter_scripts/subunit_tags.py
@@ -24,4 +24,10 @@ import sys
from subunit import tag_stream
-sys.exit(tag_stream(sys.stdin, sys.stdout, sys.argv[1:]))
+
+def main():
+ sys.exit(tag_stream(sys.stdin, sys.stdout, sys.argv[1:]))
+
+
+if __name__ == '__main__':
+ main()
diff --git a/filters/tap2subunit b/python/subunit/filter_scripts/tap2subunit.py
index d24172b..d39e8ce 100755
--- a/filters/tap2subunit
+++ b/python/subunit/filter_scripts/tap2subunit.py
@@ -23,4 +23,11 @@ http://testanything.org/wiki/index.php/Main_Page.
import sys
from subunit import TAP2SubUnit
-sys.exit(TAP2SubUnit(sys.stdin, sys.stdout))
+
+
+def main():
+ sys.exit(TAP2SubUnit(sys.stdin, sys.stdout))
+
+
+if __name__ == '__main__':
+ main()
diff --git a/python/subunit/tests/test_subunit_filter.py b/python/subunit/tests/test_subunit_filter.py
index 7ca0081..d14415a 100644
--- a/python/subunit/tests/test_subunit_filter.py
+++ b/python/subunit/tests/test_subunit_filter.py
@@ -301,10 +301,7 @@ xfail todo
class TestFilterCommand(TestCase):
def run_command(self, args, stream):
- root = os.path.dirname(
- os.path.dirname(os.path.dirname(os.path.dirname(__file__))))
- script_path = os.path.join(root, 'filters', 'subunit-filter')
- command = [sys.executable, script_path] + list(args)
+ command = ['subunit-filter'] + list(args)
ps = subprocess.Popen(
command, stdin=subprocess.PIPE, stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
diff --git a/setup.py b/setup.py
index ea8edf2..54ba083 100755
--- a/setup.py
+++ b/setup.py
@@ -53,29 +53,32 @@ setup(
"Bug Tracker": "https://bugs.launchpad.net/subunit",
"Source Code": "https://github.com/testing-cabal/subunit/",
},
- packages=['subunit', 'subunit.tests'],
+ packages=['subunit', 'subunit.tests', 'subunit.filter_scripts'],
+
package_dir={'subunit': 'python/subunit'},
- scripts=[
- 'filters/subunit-1to2',
- 'filters/subunit-2to1',
- 'filters/subunit-filter',
- 'filters/subunit-ls',
- 'filters/subunit-notify',
- 'filters/subunit-output',
- 'filters/subunit-stats',
- 'filters/subunit-tags',
- 'filters/subunit2csv',
- 'filters/subunit2disk',
- 'filters/subunit2gtk',
- 'filters/subunit2junitxml',
- 'filters/subunit2pyunit',
- 'filters/tap2subunit',
- ],
python_requires=">=3.6",
install_requires=[
'extras',
'testtools>=0.9.34',
],
+ entry_points={
+ 'console_scripts': [
+ 'subunit-1to2=subunit.filter_scripts.subunit_1to2:main',
+ 'subunit-2to1=subunit.filter_scripts.subunit_2to1:main',
+ 'subunit-filter=subunit.filter_scripts.subunit_filter:main',
+ 'subunit-ls=subunit.filter_scripts.subunit_ls:main',
+ 'subunit-notify=subunit.filter_scripts.subunit_notify:main',
+ 'subunit-output=subunit.filter_scripts.subunit_output:main',
+ 'subunit-stats=subunit.filter_scripts.subunit_stats:main',
+ 'subunit-tags=subunit.filter_scripts.subunit_tags:main',
+ 'subunit2csv=subunit.filter_scripts.subunit2csv:main',
+ 'subunit2disk=subunit.filter_scripts.subunit2disk:main',
+ 'subunit2gtk=subunit.filter_scripts.subunit2gtk:main',
+ 'subunit2junitxml=subunit.filter_scripts.subunit2junitxml:main',
+ 'subunit2pyunit=subunit.filter_scripts.subunit2pyunit:main',
+ 'tap2subunit=subunit.filter_scripts.tap2subunit:main',
+ ]
+ },
tests_require=[
'fixtures',
'hypothesis',