Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2521)

Side by Side Diff: third_party/WebKit/Tools/Scripts/print-test-ordering

Issue 2014063002: Run format-webkit on webkitpy code (without string conversion). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2 2
3 # Copyright (C) 2012 Google Inc. All rights reserved. 3 # Copyright (C) 2012 Google Inc. All rights reserved.
4 # 4 #
5 # Redistribution and use in source and binary forms, with or without 5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions are 6 # modification, are permitted provided that the following conditions are
7 # met: 7 # met:
8 # 8 #
9 # * Redistributions of source code must retain the above copyright 9 # * Redistributions of source code must retain the above copyright
10 # notice, this list of conditions and the following disclaimer. 10 # notice, this list of conditions and the following disclaimer.
(...skipping 16 matching lines...) Expand all
27 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 30
31 import json 31 import json
32 import optparse 32 import optparse
33 import sys 33 import sys
34 34
35 from webkitpy.common.host import Host 35 from webkitpy.common.host import Host
36 36
37
37 def main(argv): 38 def main(argv):
38 parser = optparse.OptionParser(usage='%prog [stats.json]') 39 parser = optparse.OptionParser(usage='%prog [stats.json]')
39 parser.description = "Prints out lists of tests run on each worker as per th e stats.json file." 40 parser.description = "Prints out lists of tests run on each worker as per th e stats.json file."
40 options, args = parser.parse_args(argv) 41 options, args = parser.parse_args(argv)
41 42
42 if args and args[0]: 43 if args and args[0]:
43 stats_path = args[0] 44 stats_path = args[0]
44 else: 45 else:
45 host = Host() 46 host = Host()
46 stats_path = host.filesystem.join(host.port_factory.get().results_direct ory(), 'stats.json') 47 stats_path = host.filesystem.join(host.port_factory.get().results_direct ory(), 'stats.json')
47 48
48 with open(stats_path, 'r') as fp: 49 with open(stats_path, 'r') as fp:
49 stats_trie = json.load(fp) 50 stats_trie = json.load(fp)
50 51
51 stats = convert_trie_to_flat_paths(stats_trie) 52 stats = convert_trie_to_flat_paths(stats_trie)
52 stats_by_worker = {} 53 stats_by_worker = {}
53 for test_name, data in stats.items(): 54 for test_name, data in stats.items():
54 worker = "worker/" + str(data["results"][0]) 55 worker = "worker/" + str(data["results"][0])
55 if worker not in stats_by_worker: 56 if worker not in stats_by_worker:
56 stats_by_worker[worker] = [] 57 stats_by_worker[worker] = []
57 test_number = data["results"][1] 58 test_number = data["results"][1]
58 stats_by_worker[worker].append({ 59 stats_by_worker[worker].append({
59 "name": test_name, 60 "name": test_name,
60 "number": test_number 61 "number": test_number
61 }) 62 })
62 63
63 for worker in sorted(stats_by_worker.keys()): 64 for worker in sorted(stats_by_worker.keys()):
64 print worker + ':' 65 print worker + ':'
65 for test in sorted(stats_by_worker[worker], key=lambda test:test["number "]): 66 for test in sorted(stats_by_worker[worker], key=lambda test: test["numbe r"]):
66 print test["name"] 67 print test["name"]
67 print 68 print
68 69
70
69 def convert_trie_to_flat_paths(trie, prefix=None): 71 def convert_trie_to_flat_paths(trie, prefix=None):
70 # Cloned from webkitpy.layout_tests.layout_package.json_results_generator 72 # Cloned from webkitpy.layout_tests.layout_package.json_results_generator
71 # so that this code can stand alone. 73 # so that this code can stand alone.
72 result = {} 74 result = {}
73 for name, data in trie.iteritems(): 75 for name, data in trie.iteritems():
74 if prefix: 76 if prefix:
75 name = prefix + "/" + name 77 name = prefix + "/" + name
76 if "results" in data: 78 if "results" in data:
77 result[name] = data 79 result[name] = data
78 else: 80 else:
79 result.update(convert_trie_to_flat_paths(data, name)) 81 result.update(convert_trie_to_flat_paths(data, name))
80 82
81 return result 83 return result
82 84
83 85
84 if __name__ == '__main__': 86 if __name__ == '__main__':
85 sys.exit(main(sys.argv[1:])) 87 sys.exit(main(sys.argv[1:]))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698