OLD | NEW |
---|---|
1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 import collections | 5 import collections |
6 import itertools | 6 import itertools |
7 import json | 7 import json |
8 | 8 |
9 from pylib.base import base_test_result | 9 from pylib.base import base_test_result |
10 | 10 |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
130 This emulates the format of the JSON emitted by | 130 This emulates the format of the JSON emitted by |
131 base/test/launcher/test_results_tracker.cc:SaveSummaryAsJSON. | 131 base/test/launcher/test_results_tracker.cc:SaveSummaryAsJSON. |
132 | 132 |
133 Args: | 133 Args: |
134 test_run_result: a base_test_result.TestRunResults object. | 134 test_run_result: a base_test_result.TestRunResults object. |
135 file_path: The path to the JSON file to write. | 135 file_path: The path to the JSON file to write. |
136 """ | 136 """ |
137 with open(file_path, 'w') as json_result_file: | 137 with open(file_path, 'w') as json_result_file: |
138 json_result_file.write(json.dumps( | 138 json_result_file.write(json.dumps( |
139 GenerateResultsDict(test_run_result, global_tags=global_tags))) | 139 GenerateResultsDict(test_run_result, global_tags=global_tags))) |
140 json_result_file.flush() | |
jbudorick
2017/08/10 16:27:38
Exiting the context manager here should flush the
| |
140 | 141 |
141 | 142 |
142 def ParseResultsFromJson(json_results): | 143 def ParseResultsFromJson(json_results): |
143 """Creates a list of BaseTestResult objects from JSON. | 144 """Creates a list of BaseTestResult objects from JSON. |
144 | 145 |
145 Args: | 146 Args: |
146 json_results: A JSON dict in the format created by | 147 json_results: A JSON dict in the format created by |
147 GenerateJsonResultsFile. | 148 GenerateJsonResultsFile. |
148 """ | 149 """ |
149 | 150 |
(...skipping 15 matching lines...) Expand all Loading... | |
165 testsuite_runs = json_results['per_iteration_data'] | 166 testsuite_runs = json_results['per_iteration_data'] |
166 for testsuite_run in testsuite_runs: | 167 for testsuite_run in testsuite_runs: |
167 for test, test_runs in testsuite_run.iteritems(): | 168 for test, test_runs in testsuite_run.iteritems(): |
168 results_list.extend( | 169 results_list.extend( |
169 [base_test_result.BaseTestResult(test, | 170 [base_test_result.BaseTestResult(test, |
170 string_as_status(tr['status']), | 171 string_as_status(tr['status']), |
171 duration=tr['elapsed_time_ms']) | 172 duration=tr['elapsed_time_ms']) |
172 for tr in test_runs]) | 173 for tr in test_runs]) |
173 return results_list | 174 return results_list |
174 | 175 |
OLD | NEW |