s3:winbindd: Update non cache entries keys (non_centry_keys)
[Samba.git] / selftest / format-subunit-json
blobd9d912cd29428c7a6766e2d2c0052ef5afa4e3d9
1 #!/usr/bin/env python3
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 import optparse
6 import os
7 import signal
8 import sys
9 import json
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."""
17     results = {}
19     for line in src_f:
20         line = line.strip()
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=(',', ': '))
29 def main():
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")
40     f = open(fn, 'w')
41     json_formatter(sys.stdin, f)
42     f.close()
43     print()
44     print("A JSON file summarising these tests performance found in:")
45     print(" ", fn)
48 def handle_sigint(sig, stack):
49     sys.exit(0)
51 signal.signal(signal.SIGINT, handle_sigint)
52 main()