| OLD | NEW |
| 1 # Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2015 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 """Generate JSON results from given test results. | 5 """Generate JSON results from given test results. |
| 6 | 6 |
| 7 Forked from build/scripts/slave/gtest/json_results_generator.py and original | 7 Forked from build/scripts/slave/gtest/json_results_generator.py and original |
| 8 will be deleted as all tests are moved to swarming. | 8 will be deleted as all tests are moved to swarming. |
| 9 """ | 9 """ |
| 10 | 10 |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 | 196 |
| 197 if modifier == TestResult.NONE: | 197 if modifier == TestResult.NONE: |
| 198 return (self.PASS_LABEL, actual) | 198 return (self.PASS_LABEL, actual) |
| 199 if modifier == TestResult.FLAKY: | 199 if modifier == TestResult.FLAKY: |
| 200 return (self.FLAKY_LABEL, actual) | 200 return (self.FLAKY_LABEL, actual) |
| 201 if modifier == TestResult.FAILS: | 201 if modifier == TestResult.FAILS: |
| 202 return (self.FAIL_LABEL, actual) | 202 return (self.FAIL_LABEL, actual) |
| 203 | 203 |
| 204 def _write_json(self, json_object, file_path): | 204 def _write_json(self, json_object, file_path): |
| 205 # Specify separators in order to get compact encoding. | 205 # Specify separators in order to get compact encoding. |
| 206 json_data = json.dumps(json_object, separators=(',', ':')) | 206 json_data = json.dumps(json_object, separators=(',', ':'), indent=2) |
| 207 json_string = json_data | 207 json_string = json_data |
| 208 if self._file_writer: | 208 if self._file_writer: |
| 209 self._file_writer(file_path, json_string) | 209 self._file_writer(file_path, json_string) |
| 210 else: | 210 else: |
| 211 with codecs.open(file_path, 'w', 'utf8') as f: | 211 with codecs.open(file_path, 'w', 'utf8') as f: |
| 212 f.write(json_string) | 212 f.write(json_string) |
| OLD | NEW |