| 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 |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 self._filesystem = port.host.filesystem | 92 self._filesystem = port.host.filesystem |
| 93 self._results_directory = self._port.results_directory() | 93 self._results_directory = self._port.results_directory() |
| 94 self._results_directory_path = self._filesystem.dirname(self._results_di
rectory) | 94 self._results_directory_path = self._filesystem.dirname(self._results_di
rectory) |
| 95 self._current_result_json_dict = {} | 95 self._current_result_json_dict = {} |
| 96 self._old_failing_results_list = [] | 96 self._old_failing_results_list = [] |
| 97 self._old_full_results_list = [] | 97 self._old_full_results_list = [] |
| 98 self._final_result = [] | 98 self._final_result = [] |
| 99 | 99 |
| 100 def _add_individual_result_links(self, results_directories): | 100 def _add_individual_result_links(self, results_directories): |
| 101 archived_results_file_list = [(file + '/results.html') for file in resul
ts_directories] | 101 archived_results_file_list = [(file + '/results.html') for file in resul
ts_directories] |
| 102 archived_results_file_list.insert(0, 'results.html') |
| 102 self._current_result_json_dict['result_links'] = archived_results_file_l
ist | 103 self._current_result_json_dict['result_links'] = archived_results_file_l
ist |
| 103 | 104 |
| 104 def _copy_dashboard_html(self): | 105 def _copy_dashboard_html(self): |
| 105 dashboard_file = self._filesystem.join(self._results_directory, 'dashboa
rd.html') | 106 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 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 not self._filesystem.exists(dashboard_file): |
| 108 if self._filesystem.exists(dashboard_html_file_path): | 109 if self._filesystem.exists(dashboard_html_file_path): |
| 109 self._filesystem.copyfile(dashboard_html_file_path, dashboard_fi
le) | 110 self._filesystem.copyfile(dashboard_html_file_path, dashboard_fi
le) |
| 110 | 111 |
| 111 def _initialize(self): | 112 def _initialize(self): |
| 112 file_list = self._filesystem.listdir(self._results_directory_path) | 113 file_list = self._filesystem.listdir(self._results_directory_path) |
| 113 results_directories = [] | 114 results_directories = [] |
| 114 for dir in file_list: | 115 for dir in file_list: |
| 115 if self._filesystem.isdir(self._filesystem.join(self._results_direct
ory_path, dir)): | 116 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.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 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 with open(self._filesystem.join(results_directories[0], 'failing_results
.json'), "r") as file: |
| 119 input_json_string = file.readline() | 120 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 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 self._current_result_json_dict['tests'] = json.loads(input_json_string)[
'tests'] |
| 123 results_directories = results_directories[1:] |
| 122 | 124 |
| 123 # To add hyperlink to individual results.html | 125 # To add hyperlink to individual results.html |
| 124 self._add_individual_result_links(results_directories) | 126 self._add_individual_result_links(results_directories) |
| 125 results_directories = results_directories[1:] | |
| 126 | 127 |
| 127 # Load the remaining stale layout test results Json's to create the dash
board | 128 # Load the remaining stale layout test results Json's to create the dash
board |
| 128 for json_file in results_directories: | 129 for json_file in results_directories: |
| 129 with open(self._filesystem.join(json_file, 'failing_results.json'),
"r") as file: | 130 with open(self._filesystem.join(json_file, 'failing_results.json'),
"r") as file: |
| 130 json_string = file.readline() | 131 json_string = file.readline() |
| 131 json_string = json_string[12:-2] # Remove preceeding string ADD_RE
SULTS( and ); at the end | 132 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 self._old_failing_results_list.append(json.loads(json_string)) |
| 133 | 134 |
| 134 with open(self._filesystem.join(json_file, 'full_results.json'), "r"
) as full_file: | 135 with open(self._filesystem.join(json_file, 'full_results.json'), "r"
) as full_file: |
| 135 json_string_full_result = full_file.readline() | 136 json_string_full_result = full_file.readline() |
| 136 self._old_full_results_list.append(json.loads(json_string_full_resul
t)) | 137 self._old_full_results_list.append(json.loads(json_string_full_resul
t)) |
| 137 self._copy_dashboard_html() | 138 self._copy_dashboard_html() |
| 138 | 139 |
| 139 def generate(self): | 140 def generate(self): |
| 140 self._initialize() | 141 self._initialize() |
| 141 process_json_data = ProcessJsonData(self._current_result_json_dict, self
._old_failing_results_list, self._old_full_results_list) | 142 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 self._final_result = process_json_data.generate_archived_result() |
| 143 final_json = json.dumps(self._final_result) | 144 final_json = json.dumps(self._final_result) |
| 144 final_json = 'ADD_RESULTS(' + final_json + ');' | 145 final_json = 'ADD_RESULTS(' + final_json + ');' |
| 145 with open(self._filesystem.join(self._results_directory, 'archived_resul
ts.json'), "w") as file: | 146 with open(self._filesystem.join(self._results_directory, 'archived_resul
ts.json'), "w") as file: |
| 146 file.write(final_json) | 147 file.write(final_json) |
| OLD | NEW |