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
5 from __future__ import print_function
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."""
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=(',', ': '))
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")
43 json_formatter(sys.stdin, f)
46 print("A JSON file summarising these tests performance found in:")
50 def handle_sigint(sig, stack):
53 signal.signal(signal.SIGINT, handle_sigint)