s3:doc manpage for "net connections cleanup"
[Samba.git] / lib / subunit / filters / subunit-ls
blob82db4c371ac1e820472d6869c60c86ee549d5815
1 #!/usr/bin/env python
2 # subunit: extensions to python unittest to get test results from subprocesses.
3 # Copyright (C) 2008 Robert Collins <robertc@robertcollins.net>
5 # Licensed under either the Apache License, Version 2.0 or the BSD 3-clause
6 # license at the users choice. A copy of both licenses are available in the
7 # project source as Apache-2.0 and BSD. You may not use this file except in
8 # compliance with one of these two licences.
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under these licenses is distributed on an "AS IS" BASIS, WITHOUT
12 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 # license you chose for the specific language governing permissions and
14 # limitations under that license.
17 """List tests in a subunit stream."""
19 from optparse import OptionParser
20 import sys
22 from subunit import DiscardStream, ProtocolTestCase
23 from subunit.test_results import (
24 AutoTimingTestResultDecorator,
25 TestIdPrintingResult,
29 parser = OptionParser(description=__doc__)
30 parser.add_option("--times", action="store_true",
31 help="list the time each test took (requires a timestamped stream)",
32 default=False)
33 parser.add_option("--no-passthrough", action="store_true",
34 help="Hide all non subunit input.", default=False, dest="no_passthrough")
35 (options, args) = parser.parse_args()
36 result = AutoTimingTestResultDecorator(
37 TestIdPrintingResult(sys.stdout, options.times))
38 if options.no_passthrough:
39 passthrough_stream = DiscardStream()
40 else:
41 passthrough_stream = None
42 test = ProtocolTestCase(sys.stdin, passthrough=passthrough_stream)
43 test.run(result)
44 if result.wasSuccessful():
45 exit_code = 0
46 else:
47 exit_code = 1
48 sys.exit(exit_code)