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
11 sys.path.insert(0, "bin/python")
14 def json_formatter(src_f, dest_f):
15 """We're not even pretending to be a TestResult subclass; just read
16 from stdin and look for elapsed-time tags."""
21 if line[:14] == 'elapsed-time: ':
22 name, time = line[14:].rsplit(':', 1)
23 results[name] = float(time)
25 json.dump(results, dest_f,
26 sort_keys=True, indent=2, separators=(',', ': '))
30 parser = optparse.OptionParser("format-subunit-json [options]")
31 parser.add_option("--verbose", action="store_true",
32 help="ignored, for compatibility")
33 parser.add_option("--immediate", action="store_true",
34 help="ignored, for compatibility")
35 parser.add_option("--prefix", type="string", default=".",
36 help="Prefix to write summary.json to")
37 opts, args = parser.parse_args()
39 fn = os.path.join(opts.prefix, "summary.json")
41 json_formatter(sys.stdin, f)
44 print("A JSON file summarising these tests performance found in:")
48 def handle_sigint(sig, stack):
51 signal.signal(signal.SIGINT, handle_sigint)