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

Side by Side Diff: build/android/pylib/results/presentation/test_results_presentation.py

Issue 2814903002: Revert of Add back buttons and load new 'pages' by calling javascript. (Closed)
Patch Set: Created 3 years, 8 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
« no previous file with comments | « build/android/pylib/results/presentation/template/table.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #! /usr/bin/env python 1 #! /usr/bin/env python
2 # 2 #
3 # Copyright 2017 The Chromium Authors. All rights reserved. 3 # Copyright 2017 The Chromium Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be 4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file. 5 # found in the LICENSE file.
6 6
7 import argparse 7 import argparse
8 import collections 8 import collections
9 import json 9 import json
10 import tempfile 10 import tempfile
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 rowspan: Rowspan HTML attribute. 71 rowspan: Rowspan HTML attribute.
72 """ 72 """
73 return { 73 return {
74 'cell_type': 'links', 74 'cell_type': 'links',
75 'class': html_class, 75 'class': html_class,
76 'links': links, 76 'links': links,
77 'rowspan': rowspan, 77 'rowspan': rowspan,
78 } 78 }
79 79
80 80
81 def action_cell(action, data, html_class):
82 """Formats table cell with javascript actions.
83
84 Args:
85 action: Javscript action.
86 data: Data in cell.
87 class: Class for table cell.
88 """
89 return {
90 'cell_type': 'action',
91 'action': action,
92 'data': data,
93 'class': html_class,
94 }
95
96
97 def logs_cell(result): 81 def logs_cell(result):
98 """Formats result logs data for processing in jinja template.""" 82 """Formats result logs data for processing in jinja template."""
99 link_list = [] 83 link_list = []
100 for name, href in result.get('links', {}).iteritems(): 84 for name, href in result.get('links', {}).iteritems():
101 link_list.append(link( 85 link_list.append(link(
102 data=name, 86 data=name,
103 href=href, 87 href=href,
104 target=LinkTarget.NEW_TAB)) 88 target=LinkTarget.NEW_TAB))
105 89
106 if link_list: 90 if link_list:
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 158
175 header_row = [ 159 header_row = [
176 cell(data='suite_name', html_class='text'), 160 cell(data='suite_name', html_class='text'),
177 cell(data='number_success_tests', html_class='number'), 161 cell(data='number_success_tests', html_class='number'),
178 cell(data='number_fail_tests', html_class='number'), 162 cell(data='number_fail_tests', html_class='number'),
179 cell(data='all_tests', html_class='number'), 163 cell(data='all_tests', html_class='number'),
180 cell(data='elapsed_time_ms', html_class='number'), 164 cell(data='elapsed_time_ms', html_class='number'),
181 ] 165 ]
182 166
183 footer_row = [ 167 footer_row = [
184 action_cell( 168 links_cell(
185 'showTestsOfOneSuiteOnlyWithNewState("TOTAL")', 169 links=[
186 'TOTAL', 170 link(href=('?suite=%s' % 'TOTAL'),
187 'center' 171 target=LinkTarget.CURRENT_TAB,
188 ), # TOTAL 172 data='TOTAL')
173 ],
174 ), # suite_name
189 cell(data=0), # number_success_tests 175 cell(data=0), # number_success_tests
190 cell(data=0), # number_fail_tests 176 cell(data=0), # number_fail_tests
191 cell(data=0), # all_tests 177 cell(data=0), # all_tests
192 cell(data=0), # elapsed_time_ms 178 cell(data=0), # elapsed_time_ms
193 ] 179 ]
194 180
195 suite_row_dict = {} 181 suite_row_dict = {}
196 for test_name, test_results in results_dict.iteritems(): 182 for test_name, test_results in results_dict.iteritems():
197 # TODO(mikecase): This logic doesn't work if there are multiple test runs. 183 # TODO(mikecase): This logic doesn't work if there are multiple test runs.
198 # That is, if 'per_iteration_data' has multiple entries. 184 # That is, if 'per_iteration_data' has multiple entries.
199 # Since we only care about the result of the last test run. 185 # Since we only care about the result of the last test run.
200 result = test_results[-1] 186 result = test_results[-1]
201 187
202 suite_name = (test_name.split('#')[0] if '#' in test_name 188 suite_name = (test_name.split('#')[0] if '#' in test_name
203 else test_name.split('.')[0]) 189 else test_name.split('.')[0])
204 if suite_name in suite_row_dict: 190 if suite_name in suite_row_dict:
205 suite_row = suite_row_dict[suite_name] 191 suite_row = suite_row_dict[suite_name]
206 else: 192 else:
207 suite_row = [ 193 suite_row = [
208 action_cell( 194 links_cell(
209 'showTestsOfOneSuiteOnlyWithNewState("%s")' % suite_name, 195 links=[
210 suite_name, 196 link(href=('?suite=%s' % suite_name),
211 'left' 197 target=LinkTarget.CURRENT_TAB,
198 data=suite_name)],
199 html_class='left'
212 ), # suite_name 200 ), # suite_name
213 cell(data=0), # number_success_tests 201 cell(data=0), # number_success_tests
214 cell(data=0), # number_fail_tests 202 cell(data=0), # number_fail_tests
215 cell(data=0), # all_tests 203 cell(data=0), # all_tests
216 cell(data=0), # elapsed_time_ms 204 cell(data=0), # elapsed_time_ms
217 ] 205 ]
218 206
219 suite_row_dict[suite_name] = suite_row 207 suite_row_dict[suite_name] = suite_row
220 208
221 suite_row[ALL_COUNT_INDEX]['data'] += 1 209 suite_row[ALL_COUNT_INDEX]['data'] += 1
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 sys.executable, gsutil_path, '-h', "Content-Type:%s" % content_type, 292 sys.executable, gsutil_path, '-h', "Content-Type:%s" % content_type,
305 'cp', temp_file.name, 'gs://%s/%s' % (bucket, dest)]) 293 'cp', temp_file.name, 'gs://%s/%s' % (bucket, dest)])
306 294
307 return '%s/%s/%s' % (server_url, bucket, dest) 295 return '%s/%s/%s' % (server_url, bucket, dest)
308 296
309 def main(): 297 def main():
310 parser = argparse.ArgumentParser() 298 parser = argparse.ArgumentParser()
311 parser.add_argument('--json-file', help='Path of json file.', required=True) 299 parser.add_argument('--json-file', help='Path of json file.', required=True)
312 parser.add_argument('--cs-base-url', help='Base url for code search.', 300 parser.add_argument('--cs-base-url', help='Base url for code search.',
313 default='http://cs.chromium.org') 301 default='http://cs.chromium.org')
314 parser.add_argument('--bucket', help='Google storage bucket.', required=True) 302 parser.add_argument('--bucket', default='chromium-result-details')
315 parser.add_argument('--builder-name', help='Builder name.', required=True) 303 parser.add_argument('--builder-name', help='Builder name.', required=True)
316 parser.add_argument('--build-number', help='Build number.', required=True) 304 parser.add_argument('--build-number', help='Build number.', required=True)
317 parser.add_argument('--test-name', help='The name of the test.', 305 parser.add_argument('--test-name', help='The name of the test.',
318 required=True) 306 required=True)
319 parser.add_argument('--server-url', help='The url of the server.', 307 parser.add_argument('--server-url', help='The url of the server.',
320 default='https://storage.cloud.google.com') 308 default='https://storage.googleapis.com')
321 parser.add_argument( 309 parser.add_argument(
322 '--content-type', 310 '--content-type',
323 help=('Content type, which is used to determine ' 311 help=('Content type, which is used to determine '
324 'whether to download the file, or view in browser.'), 312 'whether to download the file, or view in browser.'),
325 default='text/html', 313 default='text/html',
326 choices=['text/html', 'application/octet-stream']) 314 choices=['text/html', 'application/octet-stream'])
327 315
328 args = parser.parse_args() 316 args = parser.parse_args()
329 if os.path.exists(args.json_file): 317 if os.path.exists(args.json_file):
330 result_html_string = result_details(args.json_file, args.cs_base_url, 318 result_html_string = result_details(args.json_file, args.cs_base_url,
331 args.bucket, args.server_url) 319 args.bucket, args.server_url)
332 print upload_to_google_bucket(result_html_string.encode('UTF-8'), 320 print upload_to_google_bucket(result_html_string.encode('UTF-8'),
333 args.test_name, args.builder_name, 321 args.test_name, args.builder_name,
334 args.build_number, args.bucket, 322 args.build_number, args.bucket,
335 args.server_url, args.content_type) 323 args.server_url, args.content_type)
336 else: 324 else:
337 raise IOError('--json-file %s not found.' % args.json_file) 325 raise IOError('--json-file %s not found.' % args.json_file)
338 326
339 327
340 if __name__ == '__main__': 328 if __name__ == '__main__':
341 sys.exit(main()) 329 sys.exit(main())
OLDNEW
« no previous file with comments | « build/android/pylib/results/presentation/template/table.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698