| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2014 The Chromium Authors. All rights reserved. | 2 # Copyright 2014 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 import json | 6 import json |
| 7 import optparse | 7 import optparse |
| 8 import os | 8 import os |
| 9 import shutil | 9 import shutil |
| 10 import subprocess | 10 import subprocess |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 path = os.path.join(output_dir, str(index), 'output.json') | 105 path = os.path.join(output_dir, str(index), 'output.json') |
| 106 try: | 106 try: |
| 107 filesize = os.stat(path).st_size | 107 filesize = os.stat(path).st_size |
| 108 if filesize > OUTPUT_JSON_SIZE_LIMIT: | 108 if filesize > OUTPUT_JSON_SIZE_LIMIT: |
| 109 print >> sys.stderr, 'output.json is %d bytes. Max size is %d' % ( | 109 print >> sys.stderr, 'output.json is %d bytes. Max size is %d' % ( |
| 110 filesize, OUTPUT_JSON_SIZE_LIMIT) | 110 filesize, OUTPUT_JSON_SIZE_LIMIT) |
| 111 return None | 111 return None |
| 112 | 112 |
| 113 with open(path) as f: | 113 with open(path) as f: |
| 114 return json.load(f) | 114 return json.load(f) |
| 115 except (IOError, ValueError, OSError): | 115 except (IOError, ValueError, OSError) as e: |
| 116 print >> sys.stderr, 'Missing or invalid gtest JSON file: %s' % path | 116 print >> sys.stderr, 'Missing or invalid gtest JSON file: %s' % path |
| 117 print >> sys.stderr, '%s: %s' % (type(e).__name__, e) |
| 117 return None | 118 return None |
| 118 | 119 |
| 119 | 120 |
| 120 def merge_list_of_dicts(left, right): | 121 def merge_list_of_dicts(left, right): |
| 121 """Merges dicts left[0] with right[0], left[1] with right[1], etc.""" | 122 """Merges dicts left[0] with right[0], left[1] with right[1], etc.""" |
| 122 output = [] | 123 output = [] |
| 123 for i in xrange(max(len(left), len(right))): | 124 for i in xrange(max(len(left), len(right))): |
| 124 left_dict = left[i] if i < len(left) else {} | 125 left_dict = left[i] if i < len(left) else {} |
| 125 right_dict = right[i] if i < len(right) else {} | 126 right_dict = right[i] if i < len(right) else {} |
| 126 merged_dict = left_dict.copy() | 127 merged_dict = left_dict.copy() |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 'failed to process gtest output JSON', traceback.format_exc()) | 201 'failed to process gtest output JSON', traceback.format_exc()) |
| 201 | 202 |
| 202 finally: | 203 finally: |
| 203 shutil.rmtree(task_output_dir, ignore_errors=True) | 204 shutil.rmtree(task_output_dir, ignore_errors=True) |
| 204 | 205 |
| 205 return exit_code | 206 return exit_code |
| 206 | 207 |
| 207 | 208 |
| 208 if __name__ == '__main__': | 209 if __name__ == '__main__': |
| 209 sys.exit(main(sys.argv[1:])) | 210 sys.exit(main(sys.argv[1:])) |
| OLD | NEW |