Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / Tools / Scripts / print-test-ordering
blob0d3997d6214c282f94771b232ae08c329836479c
1 #!/usr/bin/python
3 # Copyright (C) 2012 Google Inc. All rights reserved.
5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions are
7 # met:
9 # * Redistributions of source code must retain the above copyright
10 # notice, this list of conditions and the following disclaimer.
11 # * Redistributions in binary form must reproduce the above
12 # copyright notice, this list of conditions and the following disclaimer
13 # in the documentation and/or other materials provided with the
14 # distribution.
15 # * Neither the name of Google Inc. nor the names of its
16 # contributors may be used to endorse or promote products derived from
17 # this software without specific prior written permission.
19 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
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.
31 import json
32 import optparse
33 import sys
35 from webkitpy.common.host import Host
37 def main(argv):
38 parser = optparse.OptionParser(usage='%prog [stats.json]')
39 parser.description = "Prints out lists of tests run on each worker as per the stats.json file."
40 options, args = parser.parse_args(argv)
42 if args and args[0]:
43 stats_path = args[0]
44 else:
45 host = Host()
46 stats_path = host.filesystem.join(host.port_factory.get().results_directory(), 'stats.json')
48 with open(stats_path, 'r') as fp:
49 stats_trie = json.load(fp)
51 stats = convert_trie_to_flat_paths(stats_trie)
52 stats_by_worker = {}
53 for test_name, data in stats.items():
54 worker = "worker/" + str(data["results"][0])
55 if worker not in stats_by_worker:
56 stats_by_worker[worker] = []
57 test_number = data["results"][1]
58 stats_by_worker[worker].append({
59 "name": test_name,
60 "number": test_number
63 for worker in sorted(stats_by_worker.keys()):
64 print worker + ':'
65 for test in sorted(stats_by_worker[worker], key=lambda test:test["number"]):
66 print test["name"]
67 print
69 def convert_trie_to_flat_paths(trie, prefix=None):
70 # Cloned from webkitpy.layout_tests.layout_package.json_results_generator
71 # so that this code can stand alone.
72 result = {}
73 for name, data in trie.iteritems():
74 if prefix:
75 name = prefix + "/" + name
76 if "results" in data:
77 result[name] = data
78 else:
79 result.update(convert_trie_to_flat_paths(data, name))
81 return result
84 if __name__ == '__main__':
85 sys.exit(main(sys.argv[1:]))