dump-webkit-tests-run 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #!/usr/bin/python
  2. import json
  3. import optparse
  4. import os
  5. import sys
  6. def main(argv):
  7. parser = optparse.OptionParser(usage='%prog worker_number [path-to-stats.json]')
  8. _, args = parser.parse_args(argv)
  9. worker_number = int(args.pop(0))
  10. if args:
  11. if os.path.exists(args[0]):
  12. with open(args[0], 'r') as fp:
  13. trie = json.load(fp)
  14. else:
  15. print >> sys.stderr, "file not found: %s" % args[0]
  16. sys.exit(1)
  17. else:
  18. trie = json.load(sys.stdin)
  19. results = convert_trie_to_flat_paths(trie)
  20. tests_run = []
  21. for (test, result) in results.iteritems():
  22. # Each result is a dict containing
  23. # { 'results': [worker #, test # in worker, driver pid,
  24. # test time in msecs, test + compare time in msecs]}
  25. if result['results'][0] == worker_number:
  26. tests_run.append((test, result['results'][1]))
  27. print "\n".join(t[0] for t in sorted(tests_run, key=lambda t: t[1]))
  28. def convert_trie_to_flat_paths(trie, prefix=None):
  29. # Cloned from webkitpy.layout_tests.layout_package.json_results_generator
  30. # so that this code can stand alone.
  31. result = {}
  32. for name, data in trie.iteritems():
  33. if prefix:
  34. name = prefix + "/" + name
  35. if len(data) and not "results" in data:
  36. result.update(convert_trie_to_flat_paths(data, name))
  37. else:
  38. result[name] = data
  39. return result
  40. if __name__ == '__main__':
  41. main(sys.argv[1:])