| OLD | NEW |
| 1 # Copyright (C) 2014 Google Inc. All rights reserved. | 1 # Copyright (C) 2014 Google Inc. All rights reserved. |
| 2 # | 2 # |
| 3 # Redistribution and use in source and binary forms, with or without | 3 # Redistribution and use in source and binary forms, with or without |
| 4 # modification, are permitted provided that the following conditions are | 4 # modification, are permitted provided that the following conditions are |
| 5 # met: | 5 # met: |
| 6 # | 6 # |
| 7 # * Redistributions of source code must retain the above copyright | 7 # * Redistributions of source code must retain the above copyright |
| 8 # notice, this list of conditions and the following disclaimer. | 8 # notice, this list of conditions and the following disclaimer. |
| 9 # * Redistributions in binary form must reproduce the above | 9 # * Redistributions in binary form must reproduce the above |
| 10 # copyright notice, this list of conditions and the following disclaimer | 10 # copyright notice, this list of conditions and the following disclaimer |
| 11 # in the documentation and/or other materials provided with the | 11 # in the documentation and/or other materials provided with the |
| 12 # distribution. | 12 # distribution. |
| 13 # * Neither the name of Google Inc. nor the names of its | 13 # * Neither the name of Google Inc. nor the names of its |
| 14 # contributors may be used to endorse or promote products derived from | 14 # contributors may be used to endorse or promote products derived from |
| 15 # this software without specific prior written permission. | 15 # this software without specific prior written permission. |
| 16 # | 16 # |
| 17 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 17 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 18 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 18 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 19 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 19 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 20 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 20 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 21 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 21 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 22 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 22 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 23 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 23 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 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. | 27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 28 | 28 |
| 29 import json | 29 import json |
| 30 import logging |
| 30 | 31 |
| 31 | 32 |
| 32 class ProcessJsonData(object): | 33 class ProcessJsonData(object): |
| 33 | 34 |
| 34 def __init__(self, current_result_json_dict, old_failing_results_list, old_f
ull_results_list): | 35 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._current_result_json_dict = current_result_json_dict |
| 36 self._old_failing_results_list = old_failing_results_list | 37 self._old_failing_results_list = old_failing_results_list |
| 37 self._old_full_results_list = old_full_results_list | 38 self._old_full_results_list = old_full_results_list |
| 38 self._final_result = [] | 39 self._final_result = [] |
| 39 | 40 |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 dashboard_file = self._filesystem.join(self._results_directory, 'dashboa
rd.html') | 107 dashboard_file = self._filesystem.join(self._results_directory, 'dashboa
rd.html') |
| 107 dashboard_html_file_path = self._filesystem.join(self._port.layout_tests
_dir(), 'fast/harness/archived-results-dashboard.html') | 108 dashboard_html_file_path = self._filesystem.join(self._port.layout_tests
_dir(), 'fast/harness/archived-results-dashboard.html') |
| 108 if not self._filesystem.exists(dashboard_file): | 109 if not self._filesystem.exists(dashboard_file): |
| 109 if self._filesystem.exists(dashboard_html_file_path): | 110 if self._filesystem.exists(dashboard_html_file_path): |
| 110 self._filesystem.copyfile(dashboard_html_file_path, dashboard_fi
le) | 111 self._filesystem.copyfile(dashboard_html_file_path, dashboard_fi
le) |
| 111 | 112 |
| 112 def _initialize(self): | 113 def _initialize(self): |
| 113 file_list = self._filesystem.listdir(self._results_directory_path) | 114 file_list = self._filesystem.listdir(self._results_directory_path) |
| 114 results_directories = [] | 115 results_directories = [] |
| 115 for dir in file_list: | 116 for dir in file_list: |
| 116 if self._filesystem.isdir(self._filesystem.join(self._results_direct
ory_path, dir)): | 117 full_dir_path = self._filesystem.join(self._results_directory_path,
dir) |
| 117 results_directories.append(self._filesystem.join(self._results_d
irectory_path, dir)) | 118 if self._filesystem.isdir(full_dir_path): |
| 119 if self._results_directory in full_dir_path: |
| 120 results_directories.append(full_dir_path) |
| 118 results_directories.sort(reverse=True, key=lambda x: self._filesystem.mt
ime(x)) | 121 results_directories.sort(reverse=True, key=lambda x: self._filesystem.mt
ime(x)) |
| 119 with open(self._filesystem.join(results_directories[0], 'failing_results
.json'), "r") as file: | 122 current_failing_results_json_file = self._filesystem.join(results_direct
ories[0], 'failing_results.json') |
| 123 with self._filesystem.open_text_file_for_reading(current_failing_results
_json_file) as file: |
| 120 input_json_string = file.readline() | 124 input_json_string = file.readline() |
| 121 input_json_string = input_json_string[12:-2] # Remove preceeding strin
g ADD_RESULTS( and ); at the end | 125 input_json_string = input_json_string[12:-2] # Remove preceeding strin
g ADD_RESULTS( and ); at the end |
| 122 self._current_result_json_dict['tests'] = json.loads(input_json_string)[
'tests'] | 126 self._current_result_json_dict['tests'] = json.loads(input_json_string)[
'tests'] |
| 123 results_directories = results_directories[1:] | 127 results_directories = results_directories[1:] |
| 124 | 128 |
| 125 # To add hyperlink to individual results.html | 129 # To add hyperlink to individual results.html |
| 126 self._add_individual_result_links(results_directories) | 130 self._add_individual_result_links(results_directories) |
| 127 | 131 |
| 128 # Load the remaining stale layout test results Json's to create the dash
board | 132 # Load the remaining stale layout test results Json's to create the dash
board |
| 129 for json_file in results_directories: | 133 for json_file in results_directories: |
| 130 with open(self._filesystem.join(json_file, 'failing_results.json'),
"r") as file: | 134 failing_json_file_path = self._filesystem.join(json_file, 'failing_r
esults.json') |
| 135 full_json_file_path = self._filesystem.join(json_file, 'full_results
.json') |
| 136 with self._filesystem.open_text_file_for_reading(failing_json_file_p
ath) as file: |
| 131 json_string = file.readline() | 137 json_string = file.readline() |
| 132 json_string = json_string[12:-2] # Remove preceeding string ADD_RE
SULTS( and ); at the end | 138 json_string = json_string[12:-2] # Remove preceeding string ADD_RE
SULTS( and ); at the end |
| 133 self._old_failing_results_list.append(json.loads(json_string)) | 139 self._old_failing_results_list.append(json.loads(json_string)) |
| 134 | 140 |
| 135 with open(self._filesystem.join(json_file, 'full_results.json'), "r"
) as full_file: | 141 with self._filesystem.open_text_file_for_reading(full_json_file_path
) as full_file: |
| 136 json_string_full_result = full_file.readline() | 142 json_string_full_result = full_file.readline() |
| 137 self._old_full_results_list.append(json.loads(json_string_full_resul
t)) | 143 self._old_full_results_list.append(json.loads(json_string_full_resul
t)) |
| 138 self._copy_dashboard_html() | 144 self._copy_dashboard_html() |
| 139 | 145 |
| 140 def generate(self): | 146 def generate(self): |
| 141 self._initialize() | 147 self._initialize() |
| 142 process_json_data = ProcessJsonData(self._current_result_json_dict, self
._old_failing_results_list, self._old_full_results_list) | 148 |
| 143 self._final_result = process_json_data.generate_archived_result() | 149 # There must be atleast one archived result to be processed |
| 144 final_json = json.dumps(self._final_result) | 150 if self._current_result_json_dict: |
| 145 final_json = 'ADD_RESULTS(' + final_json + ');' | 151 process_json_data = ProcessJsonData(self._current_result_json_dict,
self._old_failing_results_list, self._old_full_results_list) |
| 146 with open(self._filesystem.join(self._results_directory, 'archived_resul
ts.json'), "w") as file: | 152 self._final_result = process_json_data.generate_archived_result() |
| 147 file.write(final_json) | 153 final_json = json.dumps(self._final_result) |
| 154 final_json = 'ADD_RESULTS(' + final_json + ');' |
| 155 with self._filesystem.open_text_file_for_writing(self._filesystem.jo
in(self._results_directory, 'archived_results.json')) as file: |
| 156 file.write(final_json) |
| OLD | NEW |