format-subunit 1.31 KB
Newer Older
1
#!/usr/bin/env python
2
# vim: expandtab
3
# Pretty-format subunit output
4
# Copyright (C) 2008-2010 Jelmer Vernooij <jelmer@samba.org>
5 6
# Published under the GNU GPL, v3 or later

7 8
import optparse
import os
9
import signal
10
import sys
11

12
sys.path.insert(0, "bin/python")
13

14
import subunithelper
15

16 17
parser = optparse.OptionParser("format-subunit [options]")
parser.add_option("--verbose", action="store_true",
18
    help="Be verbose")
19
parser.add_option("--immediate", action="store_true",
20
    help="Show failures immediately, don't wait until test run has finished")
21
parser.add_option("--prefix", type="string", default=".",
22
    help="Prefix to write summary to")
23

24
opts, args = parser.parse_args()
25

26
def handle_sigint(sig, stack):
27 28
    sys.exit(0)

29 30
signal.signal(signal.SIGINT, handle_sigint)

31
statistics = {
32 33 34 35 36 37 38
    'SUITES_FAIL': 0,
    'TESTS_UNEXPECTED_OK': 0,
    'TESTS_EXPECTED_OK': 0,
    'TESTS_UNEXPECTED_FAIL': 0,
    'TESTS_EXPECTED_FAIL': 0,
    'TESTS_ERROR': 0,
    'TESTS_SKIP': 0,
39
}
40

41
msg_ops = subunithelper.PlainFormatter(opts.verbose, opts.immediate, statistics)
42

43
expected_ret = subunithelper.parse_results(msg_ops, statistics, sys.stdin)
44

45 46 47 48 49 50
summaryfile = os.path.join(opts.prefix, "summary")

msg_ops.write_summary(summaryfile)

print "\nA summary with detailed information can be found in:"
print "  %s" % summaryfile
51

52
sys.exit(expected_ret)