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 if line[:14] == 'elapsed-time: ':
23 name, time = line[14:].rsplit(':', 1)
24 results[name] = float(time)
26 json.dump(results, dest_f,
27 sort_keys=True, indent=2, separators=(',', ': '))
31 parser = optparse.OptionParser("format-subunit-json [options]")
32 parser.add_option("--verbose", action="store_true",
33 help="ignored, for compatibility")
34 parser.add_option("--immediate", action="store_true",
35 help="ignored, for compatibility")
36 parser.add_option("--prefix", type="string", default=".",
37 help="Prefix to write summary.json to")
38 opts, args = parser.parse_args()
40 fn = os.path.join(opts.prefix, "summary.json")
42 json_formatter(sys.stdin, f)
45 print("A JSON file summarising these tests performance found in:")
49 def handle_sigint(sig, stack):
52 signal.signal(signal.SIGINT, handle_sigint)