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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 try: | 52 try: |
53 json_object = json_object[key] | 53 json_object = json_object[key] |
54 except KeyError: | 54 except KeyError: |
55 return 'NOTFOUND' | 55 return 'NOTFOUND' |
56 return self._get_test_result(json_object) | 56 return self._get_test_result(json_object) |
57 | 57 |
58 def _process_previous_json_results(self, key_list): | 58 def _process_previous_json_results(self, key_list): |
59 row = [] | 59 row = [] |
60 length = len(self._old_failing_results_list) | 60 length = len(self._old_failing_results_list) |
61 for index in range(0, length): | 61 for index in range(0, length): |
62 result = self._recurse_json_object(self._old_failing_results_list[in
dex]["tests"], key_list) | 62 result = self._recurse_json_object(self._old_failing_results_list[in
dex]['tests'], key_list) |
63 if result == 'NOTFOUND': | 63 if result == 'NOTFOUND': |
64 result = self._recurse_json_object(self._old_full_results_list[i
ndex]["tests"], key_list) | 64 result = self._recurse_json_object(self._old_full_results_list[i
ndex]['tests'], key_list) |
65 row.append(result) | 65 row.append(result) |
66 return row | 66 return row |
67 | 67 |
68 def _add_archived_result(self, json_object, result): | 68 def _add_archived_result(self, json_object, result): |
69 json_object['archived_results'] = result | 69 json_object['archived_results'] = result |
70 | 70 |
71 def _process_json_object(self, json_object, keyList): | 71 def _process_json_object(self, json_object, keyList): |
72 for key, subdict in json_object.iteritems(): | 72 for key, subdict in json_object.iteritems(): |
73 if type(subdict) == dict: | 73 if isinstance(subdict, dict): |
74 self._process_json_object(subdict, keyList + [key]) | 74 self._process_json_object(subdict, keyList + [key]) |
75 else: | 75 else: |
76 row = [self._get_test_result(json_object)] | 76 row = [self._get_test_result(json_object)] |
77 row += self._process_previous_json_results(keyList) | 77 row += self._process_previous_json_results(keyList) |
78 json_object.clear() | 78 json_object.clear() |
79 self._add_archived_result(json_object, row) | 79 self._add_archived_result(json_object, row) |
80 return | 80 return |
81 | 81 |
82 def generate_archived_result(self): | 82 def generate_archived_result(self): |
83 for key in self._current_result_json_dict["tests"]: | 83 for key in self._current_result_json_dict['tests']: |
84 self._process_json_object(self._current_result_json_dict["tests"][ke
y], [key]) | 84 self._process_json_object(self._current_result_json_dict['tests'][ke
y], [key]) |
85 return self._current_result_json_dict | 85 return self._current_result_json_dict |
86 | 86 |
87 | 87 |
88 class GenerateDashBoard(object): | 88 class GenerateDashBoard(object): |
89 | 89 |
90 def __init__(self, port): | 90 def __init__(self, port): |
91 self._port = port | 91 self._port = port |
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 archived_results_file_list.insert(0, 'results.html') |
103 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 |
104 | 104 |
105 def _copy_dashboard_html(self): | 105 def _copy_dashboard_html(self): |
106 dashboard_file = self._filesystem.join(self._results_directory, 'dashboa
rd.html') | 106 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') | 107 dashboard_html_file_path = self._filesystem.join( |
| 108 self._port.layout_tests_dir(), |
| 109 'fast/harness/archived-results-dashboard.html') |
108 if not self._filesystem.exists(dashboard_file): | 110 if not self._filesystem.exists(dashboard_file): |
109 if self._filesystem.exists(dashboard_html_file_path): | 111 if self._filesystem.exists(dashboard_html_file_path): |
110 self._filesystem.copyfile(dashboard_html_file_path, dashboard_fi
le) | 112 self._filesystem.copyfile(dashboard_html_file_path, dashboard_fi
le) |
111 | 113 |
112 def _initialize(self): | 114 def _initialize(self): |
113 file_list = self._filesystem.listdir(self._results_directory_path) | 115 file_list = self._filesystem.listdir(self._results_directory_path) |
114 results_directories = [] | 116 results_directories = [] |
115 for dir in file_list: | 117 for dir in file_list: |
116 if self._filesystem.isdir(self._filesystem.join(self._results_direct
ory_path, dir)): | 118 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)) | 119 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)) | 120 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: | 121 with open(self._filesystem.join(results_directories[0], 'failing_results
.json'), 'r') as file: |
120 input_json_string = file.readline() | 122 input_json_string = file.readline() |
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 with open(self._filesystem.join(json_file, 'failing_results.json'),
'r') as file: |
131 json_string = file.readline() | 133 json_string = file.readline() |
132 json_string = json_string[12:-2] # Remove preceeding string ADD_RE
SULTS( and ); at the end | 134 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)) | 135 self._old_failing_results_list.append(json.loads(json_string)) |
134 | 136 |
135 with open(self._filesystem.join(json_file, 'full_results.json'), "r"
) as full_file: | 137 with open(self._filesystem.join(json_file, 'full_results.json'), 'r'
) as full_file: |
136 json_string_full_result = full_file.readline() | 138 json_string_full_result = full_file.readline() |
137 self._old_full_results_list.append(json.loads(json_string_full_resul
t)) | 139 self._old_full_results_list.append(json.loads(json_string_full_resul
t)) |
138 self._copy_dashboard_html() | 140 self._copy_dashboard_html() |
139 | 141 |
140 def generate(self): | 142 def generate(self): |
141 self._initialize() | 143 self._initialize() |
142 process_json_data = ProcessJsonData(self._current_result_json_dict, self
._old_failing_results_list, self._old_full_results_list) | 144 process_json_data = ProcessJsonData( |
| 145 self._current_result_json_dict, |
| 146 self._old_failing_results_list, |
| 147 self._old_full_results_list) |
143 self._final_result = process_json_data.generate_archived_result() | 148 self._final_result = process_json_data.generate_archived_result() |
144 final_json = json.dumps(self._final_result) | 149 final_json = json.dumps(self._final_result) |
145 final_json = 'ADD_RESULTS(' + final_json + ');' | 150 final_json = 'ADD_RESULTS(' + final_json + ');' |
146 with open(self._filesystem.join(self._results_directory, 'archived_resul
ts.json'), "w") as file: | 151 with open(self._filesystem.join(self._results_directory, 'archived_resul
ts.json'), 'w') as file: |
147 file.write(final_json) | 152 file.write(final_json) |
OLD | NEW |