| 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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 return 'FAILURE' | 80 return 'FAILURE' |
| 81 elif s == base_test_result.ResultType.CRASH: | 81 elif s == base_test_result.ResultType.CRASH: |
| 82 return 'CRASH' | 82 return 'CRASH' |
| 83 elif s == base_test_result.ResultType.TIMEOUT: | 83 elif s == base_test_result.ResultType.TIMEOUT: |
| 84 return 'TIMEOUT' | 84 return 'TIMEOUT' |
| 85 elif s == base_test_result.ResultType.UNKNOWN: | 85 elif s == base_test_result.ResultType.UNKNOWN: |
| 86 return 'UNKNOWN' | 86 return 'UNKNOWN' |
| 87 | 87 |
| 88 all_tests = set() | 88 all_tests = set() |
| 89 per_iteration_data = [] | 89 per_iteration_data = [] |
| 90 test_run_links = {} |
| 91 |
| 90 for test_run_result in test_run_results: | 92 for test_run_result in test_run_results: |
| 91 iteration_data = collections.defaultdict(list) | 93 iteration_data = collections.defaultdict(list) |
| 92 if isinstance(test_run_result, list): | 94 if isinstance(test_run_result, list): |
| 93 results_iterable = itertools.chain(*(t.GetAll() for t in test_run_result)) | 95 results_iterable = itertools.chain(*(t.GetAll() for t in test_run_result)) |
| 96 for tr in test_run_result: |
| 97 test_run_links.update(tr.GetLinks()) |
| 98 |
| 94 else: | 99 else: |
| 95 results_iterable = test_run_result.GetAll() | 100 results_iterable = test_run_result.GetAll() |
| 101 test_run_links.update(test_run_result.GetLinks()) |
| 96 | 102 |
| 97 for r in results_iterable: | 103 for r in results_iterable: |
| 98 result_dict = { | 104 result_dict = { |
| 99 'status': status_as_string(r.GetType()), | 105 'status': status_as_string(r.GetType()), |
| 100 'elapsed_time_ms': r.GetDuration(), | 106 'elapsed_time_ms': r.GetDuration(), |
| 101 'output_snippet': r.GetLog(), | 107 'output_snippet': r.GetLog(), |
| 102 'losless_snippet': '', | 108 'losless_snippet': '', |
| 103 'output_snippet_base64': '', | 109 'output_snippet_base64': '', |
| 104 'tombstones': r.GetTombstonesUrl() or '', | 110 'links': r.GetLinks(), |
| 105 'logcat_url': r.GetLogcatUrl() or '', | |
| 106 } | 111 } |
| 107 iteration_data[r.GetName()].append(result_dict) | 112 iteration_data[r.GetName()].append(result_dict) |
| 108 | 113 |
| 109 all_tests = all_tests.union(set(iteration_data.iterkeys())) | 114 all_tests = all_tests.union(set(iteration_data.iterkeys())) |
| 110 per_iteration_data.append(iteration_data) | 115 per_iteration_data.append(iteration_data) |
| 111 | 116 |
| 112 return { | 117 return { |
| 113 'global_tags': [], | 118 'global_tags': [], |
| 114 'all_tests': sorted(list(all_tests)), | 119 'all_tests': sorted(list(all_tests)), |
| 115 # TODO(jbudorick): Add support for disabled tests within base_test_result. | 120 # TODO(jbudorick): Add support for disabled tests within base_test_result. |
| 116 'disabled_tests': [], | 121 'disabled_tests': [], |
| 117 'per_iteration_data': per_iteration_data, | 122 'per_iteration_data': per_iteration_data, |
| 123 'links': test_run_links, |
| 118 } | 124 } |
| 119 | 125 |
| 120 | 126 |
| 121 def GenerateJsonResultsFile(test_run_result, file_path): | 127 def GenerateJsonResultsFile(test_run_result, file_path): |
| 122 """Write |test_run_result| to JSON. | 128 """Write |test_run_result| to JSON. |
| 123 | 129 |
| 124 This emulates the format of the JSON emitted by | 130 This emulates the format of the JSON emitted by |
| 125 base/test/launcher/test_results_tracker.cc:SaveSummaryAsJSON. | 131 base/test/launcher/test_results_tracker.cc:SaveSummaryAsJSON. |
| 126 | 132 |
| 127 Args: | 133 Args: |
| (...skipping 30 matching lines...) Expand all Loading... |
| 158 testsuite_runs = json_results['per_iteration_data'] | 164 testsuite_runs = json_results['per_iteration_data'] |
| 159 for testsuite_run in testsuite_runs: | 165 for testsuite_run in testsuite_runs: |
| 160 for test, test_runs in testsuite_run.iteritems(): | 166 for test, test_runs in testsuite_run.iteritems(): |
| 161 results_list.extend( | 167 results_list.extend( |
| 162 [base_test_result.BaseTestResult(test, | 168 [base_test_result.BaseTestResult(test, |
| 163 string_as_status(tr['status']), | 169 string_as_status(tr['status']), |
| 164 duration=tr['elapsed_time_ms']) | 170 duration=tr['elapsed_time_ms']) |
| 165 for tr in test_runs]) | 171 for tr in test_runs]) |
| 166 return results_list | 172 return results_list |
| 167 | 173 |
| OLD | NEW |