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

Side by Side Diff: scripts/slave/recipes/blink_trybot.py

Issue 23889036: Refactor the way that TestApi works so that it is actually useful. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/build
Patch Set: License headers Created 7 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 | Annotate | Revision Log
OLDNEW
1 # Copyright 2013 The Chromium Authors. All rights reserved. 1 # Copyright 2013 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 DEPS = [ 5 DEPS = [
6 'chromium', 6 'chromium',
7 'gclient', 7 'gclient',
8 'json', 8 'json',
9 'path', 9 'path',
10 'platform',
10 'properties', 11 'properties',
11 'python', 12 'python',
12 'rietveld', 13 'rietveld',
13 'step', 14 'step',
14 'step_history', 15 'step_history',
15 ] 16 ]
16 17
17 18
18 def html_results(*name_vals): 19 def html_results(*name_vals):
19 ret = '' 20 ret = ''
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 results_dir = api.path.slave_build('layout-test-results') 74 results_dir = api.path.slave_build('layout-test-results')
74 75
75 76
76 def BlinkTestsStep(with_patch): 77 def BlinkTestsStep(with_patch):
77 name = 'webkit_tests (with%s patch)' % ('' if with_patch else 'out') 78 name = 'webkit_tests (with%s patch)' % ('' if with_patch else 'out')
78 test = api.path.build('scripts', 'slave', 'chromium', 79 test = api.path.build('scripts', 'slave', 'chromium',
79 'layout_test_wrapper.py') 80 'layout_test_wrapper.py')
80 args = ['--target', api.chromium.c.BUILD_CONFIG, 81 args = ['--target', api.chromium.c.BUILD_CONFIG,
81 '-o', results_dir, 82 '-o', results_dir,
82 '--build-dir', api.path.checkout(api.chromium.c.build_dir), 83 '--build-dir', api.path.checkout(api.chromium.c.build_dir),
83 api.json.test_results()] 84 '--json-test-results', api.json.test_results()]
84 return api.chromium.runtests(test, args, name=name, can_fail_build=False, 85 return api.chromium.runtests(test, args, name=name, can_fail_build=False,
85 followup_fn=followup_fn) 86 followup_fn=followup_fn)
86 87
87 yield ( 88 yield (
88 api.gclient.checkout(), 89 api.gclient.checkout(),
89 api.rietveld.apply_issue('third_party', 'WebKit'), 90 api.rietveld.apply_issue('third_party', 'WebKit'),
90 api.chromium.runhooks(), 91 api.chromium.runhooks(),
91 api.chromium.compile(), 92 api.chromium.compile(),
92 api.python('webkit_lint', webkit_lint, [ 93 api.python('webkit_lint', webkit_lint, [
93 '--build-dir', api.path.checkout('out'), 94 '--build-dir', api.path.checkout('out'),
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 args=[ 167 args=[
167 api.json.input({ 168 api.json.input({
168 'new': new_failures, 169 'new': new_failures,
169 'ignored': ignored_failures 170 'ignored': ignored_failures
170 }) 171 })
171 ], 172 ],
172 followup_fn=summarize_failures(ignored_failures, new_failures) 173 followup_fn=summarize_failures(ignored_failures, new_failures)
173 ) 174 )
174 175
175 176
176 ## Test Code 177 def GenTests(api):
177 # TODO(iannucci): Find some way that the json module can provide these methods 178 canned_test = api.json.canned_test_output
178 # in the test api, since they'll be useful for anyone who uses 179 with_patch = 'webkit_tests (with patch)'
179 # the 'json.test_results' object. 180 without_patch = 'webkit_tests (without patch)'
180 def add_result(r, name, expected, actual=None):
181 """Adds a test result to a 'json test results' compatible object.
182 Args:
183 r - The test result object to add to
184 name - A full test name delimited by '/'. ex. 'some/category/test.html'
185 expected - The string value for the 'expected' result of this test.
186 actual (optional) - If not None, this is the actual result of the test.
187 Otherwise this will be set equal to expected.
188 181
189 The test will also get an 'is_unexpected' key if actual != expected.
190 """
191 actual = actual or expected
192 entry = r.setdefault('tests', {})
193 for token in name.split('/'):
194 entry = entry.setdefault(token, {})
195 entry['expected'] = expected
196 entry['actual'] = actual
197 if expected != actual:
198 entry['is_unexpected'] = True
199
200
201 def canned_test_output(good, passes=9001):
202 """Produces a 'json test results' compatible object with some canned tests.
203 Args:
204 good - Determines if this test result is passing or not.
205 passes - The number of (theoretically) passing tests.
206 """
207 bad = lambda fail_val: None if good else fail_val
208 r = {"num_passes": passes}
209 add_result(r, 'good/totally-awesome.html', 'PASS')
210 add_result(r, 'flake/totally-flakey.html', 'PASS', bad('TIMEOUT PASS'))
211 add_result(r, 'tricky/totally-maybe-not-awesome.html', 'PASS', bad('FAIL'))
212 add_result(r, 'bad/totally-bad-probably.html', 'PASS', bad('FAIL'))
213 return r
214
215
216 def step_mock(suffix, good):
217 """Produces the step mock for a single webkit tests step.
218 Args:
219 good - Determines if the result of this step was good or bad.
220 suffix - The suffix of the step name.
221 """
222 return {
223 ('webkit_tests (%s)' % suffix): {
224 'json': {'test_results': canned_test_output(good) },
225 '$R': 0 if good else 1
226 }
227 }
228
229
230 def GenTests(api):
231 for result, good in [('success', True), ('fail', False)]: 182 for result, good in [('success', True), ('fail', False)]:
232 for build_config in ['Release', 'Debug']: 183 for build_config in ['Release', 'Debug']:
233 for plat in ('win', 'mac', 'linux'): 184 for plat in ('win', 'mac', 'linux'):
234 for git_mode in True, False: 185 for git_mode in True, False:
235 suffix = '_git' if git_mode else '' 186 suffix = '_git' if git_mode else ''
236 187 name = '%s_%s_%s%s' % (plat, result, build_config.lower(), suffix)
237 step_mocks = step_mock('with patch', good) 188 test = (
238 if not good: 189 api.test(name) +
239 step_mocks.update(step_mock('without patch', good)) 190 api.properties.tryserver(
240
241 yield ('%s_%s_%s%s' % (plat, result, build_config.lower(), suffix)), {
242 'properties': api.properties_tryserver(
243 build_config=build_config, 191 build_config=build_config,
244 config_name='blink', 192 config_name='blink',
245 root='src/third_party/WebKit', 193 root='src/third_party/WebKit',
246 GIT_MODE=git_mode, 194 GIT_MODE=git_mode,
247 ), 195 ) +
248 'step_mocks': step_mocks, 196 api.platform.name(plat) +
249 'mock': { 197 api.step_data(with_patch, canned_test(good))
250 'platform': { 198 )
251 'name': plat 199 if not good:
252 } 200 test += api.step_data(without_patch, canned_test(False))
253 } 201 yield test
254 }
255 202
256 warn_on_flakey_data = step_mock('with patch', False) 203 yield (
257 warn_on_flakey_data.update(step_mock('without patch', True)) 204 api.test('warn_on_flakey') +
258 yield 'warn_on_flakey', { 205 api.properties.tryserver(
259 'properties': api.properties_tryserver(
260 build_config='Release', 206 build_config='Release',
261 config_name='blink', 207 config_name='blink',
262 root='src/third_party/WebKit', 208 root='src/third_party/WebKit',
263 GIT_MODE=False, 209 GIT_MODE=False,
264 ), 210 ) +
265 'step_mocks': warn_on_flakey_data, 211 api.step_data(with_patch, canned_test(False)) +
266 'mock': { 212 api.step_data(without_patch, canned_test(True))
267 'platform': { 213 )
268 'name': 'linux'
269 }
270 }
271 }
OLDNEW
« no previous file with comments | « scripts/slave/recipes/android_webview_aosp.py ('k') | scripts/slave/recipes/blink_trybot.expected/linux_fail_debug.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698