2018-12-12 03:43:21 +03:00
#!/usr/bin/env python3
2010-03-30 02:30:52 +04:00
# vim: expandtab
2009-06-03 19:16:56 +04:00
# Pretty-format subunit output
2010-03-30 00:25:25 +04:00
# Copyright (C) 2008-2010 Jelmer Vernooij <jelmer@samba.org>
2009-06-03 19:16:56 +04:00
# Published under the GNU GPL, v3 or later
2010-03-30 00:25:25 +04:00
import optparse
import os
2010-03-30 04:39:50 +04:00
import signal
2010-03-30 00:25:25 +04:00
import sys
2009-06-04 15:49:11 +04:00
2014-11-04 23:37:41 +03:00
sys.path.insert(0, "bin/python")
2010-03-31 06:51:05 +04:00
2010-03-31 06:52:13 +04:00
import subunithelper
2010-03-30 02:30:52 +04:00
2010-03-30 00:25:25 +04:00
parser = optparse.OptionParser("format-subunit [options]")
parser.add_option("--verbose", action="store_true",
2010-03-30 02:30:52 +04:00
help="Be verbose")
2014-12-14 22:38:48 +03:00
parser.add_option("--immediate", action="store_true",
2010-03-30 02:30:52 +04:00
help="Show failures immediately, don't wait until test run has finished")
2010-03-30 00:25:25 +04:00
parser.add_option("--prefix", type="string", default=".",
2010-03-30 02:30:52 +04:00
help="Prefix to write summary to")
2009-06-04 15:49:11 +04:00
2010-03-30 00:25:25 +04:00
opts, args = parser.parse_args()
2009-06-04 15:49:11 +04:00
2010-10-02 20:40:44 +04:00
def handle_sigint(sig, stack):
2014-11-01 18:38:31 +03:00
sys.exit(0)
2010-10-02 20:40:44 +04:00
signal.signal(signal.SIGINT, handle_sigint)
2010-03-30 00:25:25 +04:00
statistics = {
2010-03-30 02:30:52 +04:00
'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,
2010-03-30 00:25:25 +04:00
}
2009-06-04 15:49:11 +04:00
2010-10-02 20:40:44 +04:00
msg_ops = subunithelper.PlainFormatter(opts.verbose, opts.immediate, statistics)
2009-06-04 15:49:11 +04:00
2010-03-30 00:25:25 +04:00
expected_ret = subunithelper.parse_results(msg_ops, statistics, sys.stdin)
2009-06-04 15:49:11 +04:00
2010-10-02 20:40:44 +04:00
summaryfile = os.path.join(opts.prefix, "summary")
msg_ops.write_summary(summaryfile)
2022-11-18 02:45:12 +03:00
print("\nThere might be more detail in "
f"{os.path.join(opts.prefix, 'subunit')} or {summaryfile}.")
2009-06-04 15:49:11 +04:00
2010-03-30 00:25:25 +04:00
sys.exit(expected_ret)