Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(74)

Side by Side Diff: build/android/pylib/results/json_results.py

Issue 1987763002: [Android] Expose each try result in test results JSON. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
6 import itertools
5 import json 7 import json
6 8
7 from pylib.base import base_test_result 9 from pylib.base import base_test_result
8 10
9 11
10 def GenerateResultsDict(test_run_results): 12 def GenerateResultsDict(test_run_results):
11 """Create a results dict from |test_run_results| suitable for writing to JSON. 13 """Create a results dict from |test_run_results| suitable for writing to JSON.
12 Args: 14 Args:
13 test_run_results: a list of base_test_result.TestRunResults objects. 15 test_run_results: a list of base_test_result.TestRunResults objects.
14 Returns: 16 Returns:
(...skipping 11 matching lines...) Expand all
26 # "per_iteration_data": [ 28 # "per_iteration_data": [
27 # { 29 # {
28 # "test1": [ 30 # "test1": [
29 # { 31 # {
30 # "status": "SUCCESS", 32 # "status": "SUCCESS",
31 # "elapsed_time_ms": 1, 33 # "elapsed_time_ms": 1,
32 # "output_snippet": "", 34 # "output_snippet": "",
33 # "output_snippet_base64": "", 35 # "output_snippet_base64": "",
34 # "losless_snippet": "", 36 # "losless_snippet": "",
35 # }, 37 # },
38 # ...
36 # ], 39 # ],
37 # "test2": [ 40 # "test2": [
38 # { 41 # {
39 # "status": "FAILURE", 42 # "status": "FAILURE",
40 # "elapsed_time_ms": 12, 43 # "elapsed_time_ms": 12,
41 # "output_snippet": "", 44 # "output_snippet": "",
42 # "output_snippet_base64": "", 45 # "output_snippet_base64": "",
43 # "losless_snippet": "", 46 # "losless_snippet": "",
44 # }, 47 # },
48 # ...
45 # ], 49 # ],
46 # }, 50 # },
47 # { 51 # {
48 # "test1": [ 52 # "test1": [
49 # { 53 # {
50 # "status": "SUCCESS", 54 # "status": "SUCCESS",
51 # "elapsed_time_ms": 1, 55 # "elapsed_time_ms": 1,
52 # "output_snippet": "", 56 # "output_snippet": "",
53 # "output_snippet_base64": "", 57 # "output_snippet_base64": "",
54 # "losless_snippet": "", 58 # "losless_snippet": "",
(...skipping 23 matching lines...) Expand all
78 elif s == base_test_result.ResultType.CRASH: 82 elif s == base_test_result.ResultType.CRASH:
79 return 'CRASH' 83 return 'CRASH'
80 elif s == base_test_result.ResultType.TIMEOUT: 84 elif s == base_test_result.ResultType.TIMEOUT:
81 return 'TIMEOUT' 85 return 'TIMEOUT'
82 elif s == base_test_result.ResultType.UNKNOWN: 86 elif s == base_test_result.ResultType.UNKNOWN:
83 return 'UNKNOWN' 87 return 'UNKNOWN'
84 88
85 all_tests = set() 89 all_tests = set()
86 per_iteration_data = [] 90 per_iteration_data = []
87 for test_run_result in test_run_results: 91 for test_run_result in test_run_results:
88 iteration_data = { 92 iteration_data = collections.defaultdict(list)
89 t.GetName(): [{ 93 if isinstance(test_run_result, list):
90 'status': status_as_string(t.GetType()), 94 results_iterable = itertools.chain(*(t.GetAll() for t in test_run_result))
91 'elapsed_time_ms': t.GetDuration(), 95 else:
92 'output_snippet': '', 96 results_iterable = test_run_result.GetAll()
93 'losless_snippet': '', 97
94 'output_snippet_base64:': '', 98 for r in results_iterable:
95 }] 99 iteration_data[r.GetName()].append({
96 for t in test_run_result.GetAll() 100 'status': status_as_string(r.GetType()),
97 } 101 'elapsed_time_ms': r.GetDuration(),
102 'output_snippet': '',
103 'losless_snippet': '',
104 'output_snippet_base64:': '',
105 })
106
98 all_tests = all_tests.union(set(iteration_data.iterkeys())) 107 all_tests = all_tests.union(set(iteration_data.iterkeys()))
99 per_iteration_data.append(iteration_data) 108 per_iteration_data.append(iteration_data)
100 109
101 return { 110 return {
102 'global_tags': [], 111 'global_tags': [],
103 'all_tests': sorted(list(all_tests)), 112 'all_tests': sorted(list(all_tests)),
104 # TODO(jbudorick): Add support for disabled tests within base_test_result. 113 # TODO(jbudorick): Add support for disabled tests within base_test_result.
105 'disabled_tests': [], 114 'disabled_tests': [],
106 'per_iteration_data': per_iteration_data, 115 'per_iteration_data': per_iteration_data,
107 } 116 }
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 testsuite_runs = json_results['per_iteration_data'] 156 testsuite_runs = json_results['per_iteration_data']
148 for testsuite_run in testsuite_runs: 157 for testsuite_run in testsuite_runs:
149 for test, test_runs in testsuite_run.iteritems(): 158 for test, test_runs in testsuite_run.iteritems():
150 results_list.extend( 159 results_list.extend(
151 [base_test_result.BaseTestResult(test, 160 [base_test_result.BaseTestResult(test,
152 string_as_status(tr['status']), 161 string_as_status(tr['status']),
153 duration=tr['elapsed_time_ms']) 162 duration=tr['elapsed_time_ms'])
154 for tr in test_runs]) 163 for tr in test_runs])
155 return results_list 164 return results_list
156 165
OLDNEW
« no previous file with comments | « build/android/pylib/remote/device/remote_device_test_run.py ('k') | build/android/pylib/results/json_results_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698