selftest: Use standard subunit command for progress reporting.
[samba.git] / selftest / filter-subunit
1 #!/usr/bin/env python
2 # Filter a subunit stream
3 # Copyright (C) Jelmer Vernooij <jelmer@samba.org>
4 # Published under the GNU GPL, v3 or later
5
6 import optparse
7 import subunithelper
8 import sys
9 import signal
10
11 parser = optparse.OptionParser("filter-subunit [options] < instream > outstream")
12 parser.add_option("--expected-failures", type="string", 
13         help="File containing list of regexes matching tests to consider known "
14              "failures")
15 parser.add_option("--strip-passed-output", action="store_true", 
16     help="Whether to strip output from tests that passed")
17
18 parser.add_option("--prefix", type="string",
19         help="Add prefix to all test names")
20
21 opts, args = parser.parse_args()
22
23 if opts.expected_failures:
24         expected_failures = list(subunithelper.read_test_regexes(opts.expected_failures))
25 else:
26         expected_failures = []
27
28 statistics = {
29         'TESTS_UNEXPECTED_OK': 0,
30         'TESTS_EXPECTED_OK': 0,
31         'TESTS_UNEXPECTED_FAIL': 0,
32         'TESTS_EXPECTED_FAIL': 0,
33         'TESTS_ERROR': 0,
34         'TESTS_SKIP': 0,
35 }
36
37 def handle_sigint(sig, stack):
38         sys.exit(0)
39 signal.signal(signal.SIGINT, handle_sigint)
40
41 msg_ops = subunithelper.FilterOps(opts.prefix, expected_failures, 
42         opts.strip_passed_output)
43
44 sys.exit(subunithelper.parse_results(msg_ops, statistics, sys.stdin))