blob: 38f650b61d08fec0cd1c226c388df85c5b5f0a3e [file] [log] [blame]
#!/usr/bin/env python
# A webkitpy import needs to go first for autoinstaller to work with subsequent imports.
import webkitpy
import json
import optparse
import os
import six
import sys
def main(argv):
parser = optparse.OptionParser(usage='%prog worker_number [path-to-stats.json]')
_, args = parser.parse_args(argv)
worker_number = int(args.pop(0))
if args:
if os.path.exists(args[0]):
with open(args[0], 'r') as fp:
trie = json.load(fp)
else:
six.print_("file not found: %s" % args[0], file=sys.stderr)
sys.exit(1)
else:
trie = json.load(sys.stdin)
results = convert_trie_to_flat_paths(trie)
tests_run = []
for (test, result) in six.iteritems(results):
# Each result is a dict containing
# { 'results': [worker #, test # in worker, driver pid,
# test time in msecs, test + compare time in msecs]}
if result['results'][0] == worker_number:
tests_run.append((test, result['results'][1]))
print("\n".join(t[0] for t in sorted(tests_run, key=lambda t: t[1])))
def convert_trie_to_flat_paths(trie, prefix=None):
# Cloned from webkitpy.layout_tests.layout_package.json_results_generator
# so that this code can stand alone.
result = {}
for name, data in six.iteritems(trie):
if prefix:
name = prefix + "/" + name
if len(data) and not "results" in data:
result.update(convert_trie_to_flat_paths(data, name))
else:
result[name] = data
return result
if __name__ == '__main__':
main(sys.argv[1:])