OLD | NEW |
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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 | 110 |
111 | 111 |
112 def code_search(test, cs_base_url): | 112 def code_search(test, cs_base_url): |
113 """Returns URL for test on codesearch.""" | 113 """Returns URL for test on codesearch.""" |
114 search = test.replace('#', '.') | 114 search = test.replace('#', '.') |
115 return '%s/?q=%s&type=cs' % (cs_base_url, search) | 115 return '%s/?q=%s&type=cs' % (cs_base_url, search) |
116 | 116 |
117 | 117 |
118 def status_class(status): | 118 def status_class(status): |
119 """Returns HTML class for test status.""" | 119 """Returns HTML class for test status.""" |
| 120 if not status: |
| 121 return 'failure unknwon' |
120 status = status.lower() | 122 status = status.lower() |
121 if status not in ('success', 'skipped'): | 123 if status not in ('success', 'skipped'): |
122 return 'failure %s' % status | 124 return 'failure %s' % status |
123 return status | 125 return status |
124 | 126 |
125 | 127 |
126 def create_test_table(results_dict, cs_base_url): | 128 def create_test_table(results_dict, cs_base_url): |
127 """Format test data for injecting into HTML table.""" | 129 """Format test data for injecting into HTML table.""" |
128 | 130 |
129 header_row = [ | 131 header_row = [ |
(...skipping 14 matching lines...) Expand all Loading... |
144 link(href=code_search(test_name, cs_base_url), | 146 link(href=code_search(test_name, cs_base_url), |
145 target=LinkTarget.NEW_TAB, | 147 target=LinkTarget.NEW_TAB, |
146 data=test_name)], | 148 data=test_name)], |
147 rowspan=len(test_results), | 149 rowspan=len(test_results), |
148 html_class='left %s' % test_name | 150 html_class='left %s' % test_name |
149 )] # test_name | 151 )] # test_name |
150 else: | 152 else: |
151 test_run = [] | 153 test_run = [] |
152 | 154 |
153 test_run.extend([ | 155 test_run.extend([ |
154 cell(data=result['status'], # status | 156 cell(data=result['status'] or 'UNKNOWN', |
| 157 # status |
155 html_class=('center %s' % | 158 html_class=('center %s' % |
156 status_class(result['status']))), | 159 status_class(result['status']))), |
157 cell(data=result['elapsed_time_ms']), # elapsed_time_ms | 160 cell(data=result['elapsed_time_ms']), # elapsed_time_ms |
158 logs_cell(result), # logs | 161 logs_cell(result), # logs |
159 pre_cell(data=result['output_snippet'], # output_snippet | 162 pre_cell(data=result['output_snippet'], # output_snippet |
160 html_class='left'), | 163 html_class='left'), |
161 ]) | 164 ]) |
162 test_runs.append(test_run) | 165 test_runs.append(test_run) |
163 test_row_blocks.append(test_runs) | 166 test_row_blocks.append(test_runs) |
164 return header_row, test_row_blocks | 167 return header_row, test_row_blocks |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
397 with open(json_file) as original_json_file: | 400 with open(json_file) as original_json_file: |
398 json_object = json.load(original_json_file) | 401 json_object = json.load(original_json_file) |
399 json_object['links'] = {'result_details': result_details_link} | 402 json_object['links'] = {'result_details': result_details_link} |
400 with open(args.output_json, 'w') as f: | 403 with open(args.output_json, 'w') as f: |
401 json.dump(json_object, f) | 404 json.dump(json_object, f) |
402 else: | 405 else: |
403 print result_details_link | 406 print result_details_link |
404 | 407 |
405 if __name__ == '__main__': | 408 if __name__ == '__main__': |
406 sys.exit(main()) | 409 sys.exit(main()) |
OLD | NEW |