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

Side by Side Diff: scripts/slave/recipe_modules/test_utils/test_api.py

Issue 2330133002: Updating the SwarmingIsolatedScriptTest to upload chartjson results to the (Closed)
Patch Set: Fixing presubmit issues Created 4 years, 2 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
« no previous file with comments | « scripts/slave/recipe_modules/chromium_tests/steps.py ('k') | scripts/slave/recipes/chromium.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 import json 1 import json
2 2
3 from recipe_engine import recipe_test_api 3 from recipe_engine import recipe_test_api
4 4
5 from .util import GTestResults, TestResults 5 from .util import GTestResults, TestResults
6 6
7 class TestUtilsTestApi(recipe_test_api.RecipeTestApi): 7 class TestUtilsTestApi(recipe_test_api.RecipeTestApi):
8 @recipe_test_api.placeholder_step_data 8 @recipe_test_api.placeholder_step_data
9 def test_results(self, test_results, retcode=None): 9 def test_results(self, test_results, retcode=None):
10 return self.m.json.output(test_results.as_jsonish(), retcode) 10 return self.m.json.output(test_results.as_jsonish(), retcode)
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 t = GTestResults(jsonish) 110 t = GTestResults(jsonish)
111 ret = self.gtest_results(t) 111 ret = self.gtest_results(t)
112 ret.retcode = retcode 112 ret.retcode = retcode
113 return ret 113 return ret
114 114
115 def canned_isolated_script_output(self, passing, is_win, swarming=False, 115 def canned_isolated_script_output(self, passing, is_win, swarming=False,
116 shards=1, swarming_internal_failure=False, 116 shards=1, swarming_internal_failure=False,
117 isolated_script_passing=True, valid=True, 117 isolated_script_passing=True, valid=True,
118 missing_shards=[], 118 missing_shards=[],
119 empty_shards=[], 119 empty_shards=[],
120 output_chartjson=False): 120 output_chartjson=False,
121 benchmark_enabled=True):
121 """Produces a test results' compatible json for isolated script tests. """ 122 """Produces a test results' compatible json for isolated script tests. """
122 per_shard_results = [] 123 per_shard_results = []
123 per_shard_chartjson_results = [] 124 per_shard_chartjson_results = []
124 for i in xrange(shards): 125 for i in xrange(shards):
125 jsonish_results = {} 126 jsonish_results = {}
126 chartjsonish_results = {} 127 chartjsonish_results = {}
127 jsonish_results['valid'] = valid 128 jsonish_results['valid'] = valid
128 # Keep shard 0's results equivalent to the old code to minimize 129 # Keep shard 0's results equivalent to the old code to minimize
129 # expectation diffs. 130 # expectation diffs.
130 idx = 1 + (2 * i) 131 idx = 1 + (2 * i)
131 tests_run = ['test%d.Test%d' % (idx, idx), 132 tests_run = ['test%d.Test%d' % (idx, idx),
132 'test%d.Test%d' % (idx + 1, idx + 1)] 133 'test%d.Test%d' % (idx + 1, idx + 1)]
133 if isolated_script_passing: 134 if isolated_script_passing:
134 jsonish_results['failures'] = [] 135 jsonish_results['failures'] = []
135 jsonish_results['successes'] = tests_run 136 jsonish_results['successes'] = tests_run
136 else: 137 else:
137 jsonish_results['failures'] = tests_run 138 jsonish_results['failures'] = tests_run
138 jsonish_results['successes'] = [] 139 jsonish_results['successes'] = []
139 jsonish_results['times'] = {t : 0.1 for t in tests_run} 140 jsonish_results['times'] = {t : 0.1 for t in tests_run}
140 chartjsonish_results['dummy'] = 'dummy%d' % i 141 chartjsonish_results['dummy'] = 'dummy%d' % i
142 chartjsonish_results['enabled'] = benchmark_enabled
141 chartjsonish_results['charts'] = {'entry%d' % idx: 'chart%d' % idx, 143 chartjsonish_results['charts'] = {'entry%d' % idx: 'chart%d' % idx,
142 'entry%d' % (idx + 1): 'chart%d' % (idx + 1)} 144 'entry%d' % (idx + 1): 'chart%d' % (idx + 1)}
143 per_shard_results.append(jsonish_results) 145 per_shard_results.append(jsonish_results)
144 per_shard_chartjson_results.append(chartjsonish_results) 146 per_shard_chartjson_results.append(chartjsonish_results)
145 if swarming: 147 if swarming:
146 jsonish_shards = [] 148 jsonish_shards = []
147 files_dict = {} 149 files_dict = {}
148 for i in xrange(shards): 150 for i in xrange(shards):
149 jsonish_shards.append({ 151 jsonish_shards.append({
150 'failure': not passing, 152 'failure': not passing,
(...skipping 20 matching lines...) Expand all
171 if not chartjson_output_missing and output_chartjson: 173 if not chartjson_output_missing and output_chartjson:
172 files_dict[chartjson_swarming_path] = \ 174 files_dict[chartjson_swarming_path] = \
173 '' if chartjson_output_empty \ 175 '' if chartjson_output_empty \
174 else json.dumps(per_shard_chartjson_results[i]) 176 else json.dumps(per_shard_chartjson_results[i])
175 177
176 jsonish_summary = {'shards': jsonish_shards} 178 jsonish_summary = {'shards': jsonish_shards}
177 files_dict['summary.json'] = json.dumps(jsonish_summary) 179 files_dict['summary.json'] = json.dumps(jsonish_summary)
178 return self.m.raw_io.output_dir(files_dict) 180 return self.m.raw_io.output_dir(files_dict)
179 else: 181 else:
180 return self.m.json.output(per_shard_results[0]) 182 return self.m.json.output(per_shard_results[0])
OLDNEW
« no previous file with comments | « scripts/slave/recipe_modules/chromium_tests/steps.py ('k') | scripts/slave/recipes/chromium.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698