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

Side by Side Diff: Tools/Scripts/webkitpy/layout_tests/generate_results_dashboard.py

Issue 339623002: Added support for versioning of layout test results of run-webkit-tests runs (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 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
(Empty)
1 # Copyright (C) 2010 Google Inc. All rights reserved.
2 #
3 # Redistribution and use in source and binary forms, with or without
4 # modification, are permitted provided that the following conditions are
5 # met:
6 #
7 # * Redistributions of source code must retain the above copyright
8 # notice, this list of conditions and the following disclaimer.
9 # * Redistributions in binary form must reproduce the above
10 # copyright notice, this list of conditions and the following disclaimer
11 # in the documentation and/or other materials provided with the
12 # distribution.
13 # * Neither the name of Google Inc. nor the names of its
14 # contributors may be used to endorse or promote products derived from
15 # this software without specific prior written permission.
16 #
17 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
29 import json
30 import logging
31 import string
32
33 from webkitpy.common.system.filesystem import FileSystem
Dirk Pranke 2014/06/17 17:58:58 there's no need to import FileSystem directly.
patro 2014/07/15 10:36:57 Done.
34 from webkitpy.layout_tests.port import configuration_options, platform_options
35
36 _log = logging.getLogger(__name__)
37
38
39 class GenerateDashBoard:
Dirk Pranke 2014/06/17 17:58:58 nit: this should inherit from (object).
patro 2014/07/15 10:36:57 Done.
40
41 "A class for generating the Dashboard from the list of archived results"
42
43 def __init__(self, port):
44 self._port = port
45 self._filesystem = port.host.filesystem
46 self._results_directory = self._port.results_directory()
47 self._release_directory = self._filesystem.join(self._filesystem.dirname (self._results_directory), '')
48 self._input_json_data = ""
49 self._old_failing_results_list = []
50 self._old_full_results_list = []
51 self._final_result = []
52
53 def _add_individual_result_links(self, file_list):
54 file_list = [(file + '/results.html') for file in file_list]
55 self._input_json_data['result_links'] = file_list
56
57 def _copy_dashboard_html(self):
58 dashboard_file = self._filesystem.join(self._release_directory, 'dashboa rd.html')
59 dashboard_html_file_path = self._filesystem.join(self._port.layout_tests _dir(), 'fast/harness/dashboard.html')
60 if ~(self._filesystem.exists(dashboard_file)):
61 if self._filesystem.exists(dashboard_html_file_path):
62 self._filesystem.copyfile(dashboard_html_file_path, dashboard_fi le)
63
64 def _initialize(self):
65 file_list = self._filesystem.listdir(self._release_directory)
66 json_file_list = []
67 for dir in file_list:
68 if self._filesystem.isdir(self._filesystem.join(self._release_direct ory, dir)):
69 json_file_list.append(self._filesystem.join(self._release_direct ory, dir))
70 json_file_list.sort(reverse=True)
71 #Read the current Layout Test Results
72 with open(self._filesystem.join(json_file_list[0], 'failing_results.json '), "r") as file:
73 input_json_string = file.readline()
74 input_json_string = input_json_string[12:-2] # Remove preceeding strin g ADD_RESULTS( and ); at the end
75 self._input_json_data = json.loads(input_json_string)
76 #To add hyperlink to individual results.html
77 self._add_individual_result_links(json_file_list)
78 json_file_list = json_file_list[1:]
79 #Load the remaining stale layout test results Json's to create the dashb oard
80 for json_file in json_file_list:
81 with open(self._filesystem.join(json_file, 'failing_results.json'), "r") as file:
82 json_string = file.readline()
83 json_string = json_string[12:-2] # Remove preceeding string ADD_RE SULTS( and ); at the end
84 self._old_failing_results_list.append(json.loads(json_string))
85
86 with open(self._filesystem.join(json_file, 'full_results.json'), "r" ) as full_file:
87 json_string_full_result = full_file.readline()
88 self._old_full_results_list.append(json.loads(json_string_full_resul t))
89 self._copy_dashboard_html()
90
91 #To safely get the value if key doesn't exit then it is a syntax error
92 def _get_value(self, json_object, key):
93 try:
94 value = json_object[key]
95 return value
96 except KeyError, e:
97 print("Syntax error: Could not find the key ", key)
98 exit()
99
100 #To process the final dict
101 def _process_json_result(self, json_object):
102 actual = self._get_value(json_object, "actual")
103 expected = self._get_value(json_object, "expected")
104 if actual == 'SKIP':
105 return actual
106 if actual == expected:
107 hasStderr = 'false'
108 try:
109 hasStderr = json_object["has_stderr"]
110 except KeyError, e:
111 pass
112 if hasStderr == 'true':
113 return 'HASSTDERR'
114 return 'PASS'
115 else:
116 return actual
117
118 def _recurse_json_object(self, json_object, key_list):
119 for key in key_list:
120 try:
121 json_object = json_object[key]
122 except KeyError:
123 return 'NOTFOUND'
124 return self._process_json_result(json_object)
125
126 def _process_previous_json_results(self, key_list):
127 row = []
128 length = len(self._old_failing_results_list)
129 for index in range(0, length - 1):
130 result = self._recurse_json_object(self._old_failing_results_list[in dex]["tests"], key_list)
131 if result == 'NOTFOUND':
132 result = self._recurse_json_object(self._old_full_results_list[i ndex]["tests"], key_list)
133 row.append(result)
134 return row
135
136 def _add_archived_results(self, json_object, result):
137 json_object['archived_results'] = result
138
139 def _process_json_object(self, json_object, keyList):
140 flag = 0
141 for key, subdict in json_object.iteritems():
142 if type(subdict) == dict:
143 self._process_json_object(subdict, keyList + [key])
144 else:
145 flag = 1
146 break
147 if flag == 1:
148 row = [self._process_json_result(json_object)]
149 row += self._process_previous_json_results(keyList)
150 self._add_archived_results(json_object, row)
151
152 def _process_json_data(self):
153 for key in self._input_json_data["tests"]:
154 self._process_json_object(self._input_json_data["tests"][key], [key] )
155
156 def generate(self):
157 self._initialize()
158 self._process_json_data()
159 final_json = json.dumps(self._input_json_data)
160 final_json = 'ADD_RESULTS(' + final_json + ');'
161 with open(self._filesystem.join(self._release_directory, 'archived_resul ts.json'), "w") as file:
162 file.write(final_json)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698