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

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: Added layout test Created 6 years, 4 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) 2014 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
31
32 class ProcessJsonData(object):
33
34 def __init__(self, current_result_json_dict, old_failing_results_list, old_f ull_results_list):
35 self._current_result_json_dict = current_result_json_dict
36 self._old_failing_results_list = old_failing_results_list
37 self._old_full_results_list = old_full_results_list
38 self._final_result = []
39
40 def _get_test_result(self, test_result_data):
41 actual = test_result_data['actual']
42 expected = test_result_data['expected']
43 if actual == 'SKIP':
44 return actual
45 if actual == expected:
46 return 'HASSTDERR' if test_result_data.get('has_stderr') == 'true' e lse 'PASS'
47 else:
48 return actual
49
50 def _recurse_json_object(self, json_object, key_list):
51 for key in key_list:
52 try:
53 json_object = json_object[key]
54 except KeyError:
55 return 'NOTFOUND'
56 return self._get_test_result(json_object)
57
58 def _process_previous_json_results(self, key_list):
59 row = []
60 length = len(self._old_failing_results_list)
61 for index in range(0, length):
62 result = self._recurse_json_object(self._old_failing_results_list[in dex]["tests"], key_list)
63 if result == 'NOTFOUND':
64 result = self._recurse_json_object(self._old_full_results_list[i ndex]["tests"], key_list)
65 row.append(result)
66 return row
67
68 def _add_archived_result(self, json_object, result):
69 json_object['archived_results'] = result
70
71 def _process_json_object(self, json_object, keyList):
72 for key, subdict in json_object.iteritems():
73 if type(subdict) == dict:
74 self._process_json_object(subdict, keyList + [key])
75 else:
76 row = [self._get_test_result(json_object)]
77 row += self._process_previous_json_results(keyList)
78 json_object.clear()
79 self._add_archived_result(json_object, row)
80 return
81
82 def generate_archived_result(self):
83 for key in self._current_result_json_dict["tests"]:
84 self._process_json_object(self._current_result_json_dict["tests"][ke y], [key])
85 return self._current_result_json_dict
86
87
88 class GenerateDashBoard(object):
89
90 def __init__(self, port):
91 self._port = port
92 self._filesystem = port.host.filesystem
93 self._results_directory = self._port.results_directory()
94 self._results_directory_path = self._filesystem.dirname(self._results_di rectory)
95 self._current_result_json_dict = {}
96 self._old_failing_results_list = []
97 self._old_full_results_list = []
98 self._final_result = []
99
100 def _add_individual_result_links(self, results_directories):
101 archived_results_file_list = [(file + '/results.html') for file in resul ts_directories]
102 self._current_result_json_dict['result_links'] = archived_results_file_l ist
103
104 def _copy_dashboard_html(self):
105 dashboard_file = self._filesystem.join(self._results_directory, 'dashboa rd.html')
106 dashboard_html_file_path = self._filesystem.join(self._port.layout_tests _dir(), 'fast/harness/archived-results-dashboard.html')
107 if not self._filesystem.exists(dashboard_file):
108 if self._filesystem.exists(dashboard_html_file_path):
109 self._filesystem.copyfile(dashboard_html_file_path, dashboard_fi le)
110
111 def _initialize(self):
112 file_list = self._filesystem.listdir(self._results_directory_path)
113 results_directories = []
114 for dir in file_list:
115 if self._filesystem.isdir(self._filesystem.join(self._results_direct ory_path, dir)):
116 results_directories.append(self._filesystem.join(self._results_d irectory_path, dir))
117 results_directories.sort(reverse=True, key=lambda x: self._filesystem.mt ime(x))
118 with open(self._filesystem.join(results_directories[0], 'failing_results .json'), "r") as file:
119 input_json_string = file.readline()
120 input_json_string = input_json_string[12:-2] # Remove preceeding strin g ADD_RESULTS( and ); at the end
121 self._current_result_json_dict['tests'] = json.loads(input_json_string)[ 'tests']
122
123 # To add hyperlink to individual results.html
124 self._add_individual_result_links(results_directories)
125 results_directories = results_directories[1:]
126
127 # Load the remaining stale layout test results Json's to create the dash board
128 for json_file in results_directories:
129 with open(self._filesystem.join(json_file, 'failing_results.json'), "r") as file:
130 json_string = file.readline()
131 json_string = json_string[12:-2] # Remove preceeding string ADD_RE SULTS( and ); at the end
132 self._old_failing_results_list.append(json.loads(json_string))
133
134 with open(self._filesystem.join(json_file, 'full_results.json'), "r" ) as full_file:
135 json_string_full_result = full_file.readline()
136 self._old_full_results_list.append(json.loads(json_string_full_resul t))
137 self._copy_dashboard_html()
138
139 def generate(self):
140 self._initialize()
141 process_json_data = ProcessJsonData(self._current_result_json_dict, self ._old_failing_results_list, self._old_full_results_list)
142 self._final_result = process_json_data.generate_archived_result()
143 final_json = json.dumps(self._final_result)
144 final_json = 'ADD_RESULTS(' + final_json + ');'
145 with open(self._filesystem.join(self._results_directory, 'archived_resul ts.json'), "w") as file:
146 file.write(final_json)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698