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
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
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.
35 from webkitpy
.common
.host
import Host
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
)
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
)
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({
63 for worker
in sorted(stats_by_worker
.keys()):
65 for test
in sorted(stats_by_worker
[worker
], key
=lambda test
:test
["number"]):
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.
73 for name
, data
in trie
.iteritems():
75 name
= prefix
+ "/" + name
79 result
.update(convert_trie_to_flat_paths(data
, name
))
84 if __name__
== '__main__':
85 sys
.exit(main(sys
.argv
[1:]))