packaging: Remove SWAT references from RHEL-CTDB
[Samba.git] / selftest / format-subunit-json
blobd44918c75241b6e5accbc047585d1aa8fc3850da
1 #!/usr/bin/env python
2 # Copyright (C) 2008-2010 Jelmer Vernooij <jelmer@samba.org>
3 # Copyright (C) 2016 Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
4 # Published under the GNU GPL, v3 or later
6 import optparse
7 import os
8 import signal
9 import sys
10 import json
12 sys.path.insert(0, "bin/python")
15 def json_formatter(src_f, dest_f):
16 """We're not even pretending to be a TestResult subclass; just read
17 from stdin and look for elapsed-time tags."""
18 results = {}
20 for line in src_f:
21 line = line.strip()
22 print >>sys.stderr, line
23 if line[:14] == 'elapsed-time: ':
24 name, time = line[14:].rsplit(':', 1)
25 results[name] = float(time)
27 json.dump(results, dest_f,
28 sort_keys=True, indent=2, separators=(',', ': '))
31 def main():
32 parser = optparse.OptionParser("format-subunit-json [options]")
33 parser.add_option("--verbose", action="store_true",
34 help="ignored, for compatibility")
35 parser.add_option("--immediate", action="store_true",
36 help="ignored, for compatibility")
37 parser.add_option("--prefix", type="string", default=".",
38 help="Prefix to write summary.json to")
39 opts, args = parser.parse_args()
41 fn = os.path.join(opts.prefix, "summary.json")
42 f = open(fn, 'w')
43 json_formatter(sys.stdin, f)
44 f.close()
45 print
46 print "A JSON file summarising these tests performance found in:"
47 print " ", fn
50 def handle_sigint(sig, stack):
51 sys.exit(0)
53 signal.signal(signal.SIGINT, handle_sigint)
54 main()