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

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 unittest Created 6 years, 5 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 from webkitpy.layout_tests.process_json_data import ProcessJsonData
32
33
34 class GenerateDashBoard(object):
35
36 def __init__(self, port):
37 self._port = port
38 self._filesystem = port.host.filesystem
39 self._results_directory = self._port.results_directory()
40 self._release_directory = self._filesystem.dirname(self._results_directo ry)
41 self._current_result_json_dict = {}
42 self._old_failing_results_list = []
43 self._old_full_results_list = []
44 self._final_result = []
45
46 def _add_individual_result_links(self, results_directories):
47 archived_results_file_list = [(file + '/results.html') for file in resul ts_directories]
48 self._current_result_json_dict['result_links'] = archived_results_file_l ist
49
50 def _copy_dashboard_html(self):
51 dashboard_file = self._filesystem.join(self._results_directory, 'dashboa rd.html')
52 dashboard_html_file_path = self._filesystem.join(self._port.layout_tests _dir(), 'fast/harness/dashboard.html')
53 if not self._filesystem.exists(dashboard_file):
54 if self._filesystem.exists(dashboard_html_file_path):
55 self._filesystem.copyfile(dashboard_html_file_path, dashboard_fi le)
56
57 def _initialize(self):
58 file_list = self._filesystem.listdir(self._release_directory)
59 results_directories = []
60 for dir in file_list:
61 if self._filesystem.isdir(self._filesystem.join(self._release_direct ory, dir)):
62 results_directories.append(self._filesystem.join(self._release_d irectory, dir))
63 results_directories.sort(reverse=True, key=lambda x: self._filesystem.mt ime(x))
64 with open(self._filesystem.join(results_directories[0], 'failing_results .json'), "r") as file:
65 input_json_string = file.readline()
66 input_json_string = input_json_string[12:-2] # Remove preceeding strin g ADD_RESULTS( and ); at the end
67 self._current_result_json_dict['tests'] = json.loads(input_json_string)[ 'tests']
68
69 # To add hyperlink to individual results.html
70 self._add_individual_result_links(results_directories)
71 results_directories = results_directories[1:]
72
73 # Load the remaining stale layout test results Json's to create the dash board
74 for json_file in results_directories:
75 with open(self._filesystem.join(json_file, 'failing_results.json'), "r") as file:
76 json_string = file.readline()
77 json_string = json_string[12:-2] # Remove preceeding string ADD_RE SULTS( and ); at the end
78 self._old_failing_results_list.append(json.loads(json_string))
79
80 with open(self._filesystem.join(json_file, 'full_results.json'), "r" ) as full_file:
81 json_string_full_result = full_file.readline()
82 self._old_full_results_list.append(json.loads(json_string_full_resul t))
83 self._copy_dashboard_html()
84
85 def generate(self):
86 self._initialize()
87 process_json_data = ProcessJsonData(self._current_result_json_dict, self ._old_failing_results_list, self._old_full_results_list)
88 self._final_result = process_json_data.generate_archived_result()
89 final_json = json.dumps(self._final_result)
90 final_json = 'ADD_RESULTS(' + final_json + ');'
91 with open(self._filesystem.join(self._results_directory, 'archived_resul ts.json'), "w") as file:
92 file.write(final_json)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698