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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 if self._filesystem.isdir(self._filesystem.join(self._results_direct ory_path, dir)): |
117 results_directories.append(self._filesystem.join(self._results_d irectory_path, dir)) | 118 results_directories.append(self._filesystem.join(self._results_d irectory_path, dir)) |
118 results_directories.sort(reverse=True, key=lambda x: self._filesystem.mt ime(x)) | 119 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: | 120 current_failing_results_json_file = self._filesystem.join(results_direct ories[0], 'failing_results.json') |
121 with self._filesystem.open_text_file_for_reading(current_failing_results _json_file) as file: | |
120 input_json_string = file.readline() | 122 input_json_string = file.readline() |
Dirk Pranke
2014/09/06 16:53:01
This seems like a bug. I don't know why we'd only
| |
121 input_json_string = input_json_string[12:-2] # Remove preceeding strin g ADD_RESULTS( and ); at the end | 123 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'] | 124 self._current_result_json_dict['tests'] = json.loads(input_json_string)[ 'tests'] |
123 results_directories = results_directories[1:] | 125 results_directories = results_directories[1:] |
124 | 126 |
125 # To add hyperlink to individual results.html | 127 # To add hyperlink to individual results.html |
126 self._add_individual_result_links(results_directories) | 128 self._add_individual_result_links(results_directories) |
127 | 129 |
128 # Load the remaining stale layout test results Json's to create the dash board | 130 # Load the remaining stale layout test results Json's to create the dash board |
129 for json_file in results_directories: | 131 for json_file in results_directories: |
130 with open(self._filesystem.join(json_file, 'failing_results.json'), "r") as file: | 132 failing_json_file_path = self._filesystem.join(json_file, 'failing_r esults.json') |
133 full_json_file_path = self._filesystem.join(json_file, 'full_results .json') | |
134 with self._filesystem.open_text_file_for_reading(failing_json_file_p ath) as file: | |
131 json_string = file.readline() | 135 json_string = file.readline() |
132 json_string = json_string[12:-2] # Remove preceeding string ADD_RE SULTS( and ); at the end | 136 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)) | 137 self._old_failing_results_list.append(json.loads(json_string)) |
134 | 138 |
135 with open(self._filesystem.join(json_file, 'full_results.json'), "r" ) as full_file: | 139 with self._filesystem.open_text_file_for_reading(full_json_file_path ) as full_file: |
Dirk Pranke
2014/09/06 16:53:01
same comments ...
| |
136 json_string_full_result = full_file.readline() | 140 json_string_full_result = full_file.readline() |
137 self._old_full_results_list.append(json.loads(json_string_full_resul t)) | 141 self._old_full_results_list.append(json.loads(json_string_full_resul t)) |
138 self._copy_dashboard_html() | 142 self._copy_dashboard_html() |
139 | 143 |
140 def generate(self): | 144 def generate(self): |
141 self._initialize() | 145 self._initialize() |
142 process_json_data = ProcessJsonData(self._current_result_json_dict, self ._old_failing_results_list, self._old_full_results_list) | 146 |
143 self._final_result = process_json_data.generate_archived_result() | 147 # There must be atleast one archived result to be processed |
144 final_json = json.dumps(self._final_result) | 148 if self._current_result_json_dict: |
145 final_json = 'ADD_RESULTS(' + final_json + ');' | 149 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: | 150 self._final_result = process_json_data.generate_archived_result() |
147 file.write(final_json) | 151 final_json = json.dumps(self._final_result) |
152 final_json = 'ADD_RESULTS(' + final_json + ');' | |
153 with self._filesystem.open_text_file_for_writing(self._filesystem.jo in(self._results_directory, 'archived_results.json')) as file: | |
154 file.write(final_json) | |
Dirk Pranke
2014/09/06 16:53:01
similar comment: I'm not sure why we would't just
| |
OLD | NEW |