OLD | NEW |
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 'properties', | 10 'properties', |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 args=[ | 166 args=[ |
167 api.json.input({ | 167 api.json.input({ |
168 'new': new_failures, | 168 'new': new_failures, |
169 'ignored': ignored_failures | 169 'ignored': ignored_failures |
170 }) | 170 }) |
171 ], | 171 ], |
172 followup_fn=summarize_failures(ignored_failures, new_failures) | 172 followup_fn=summarize_failures(ignored_failures, new_failures) |
173 ) | 173 ) |
174 | 174 |
175 | 175 |
176 ## Test Code | 176 def GenTests(api): |
177 # TODO(iannucci): Find some way that the json module can provide these methods | 177 def step_mock(suffix, good): |
178 # in the test api, since they'll be useful for anyone who uses | 178 """Produces the step mock for a single webkit tests step. |
179 # the 'json.test_results' object. | 179 Args: |
180 def add_result(r, name, expected, actual=None): | 180 good - Determines if the result of this step was good or bad. |
181 """Adds a test result to a 'json test results' compatible object. | 181 suffix - The suffix of the step name. |
182 Args: | 182 """ |
183 r - The test result object to add to | 183 mock = api.json.canned_test_output(good) |
184 name - A full test name delimited by '/'. ex. 'some/category/test.html' | 184 mock['$R'] = 0 if good else 1 |
185 expected - The string value for the 'expected' result of this test. | 185 return { |
186 actual (optional) - If not None, this is the actual result of the test. | 186 ('webkit_tests (%s)' % suffix): mock |
187 Otherwise this will be set equal to expected. | 187 } |
188 | |
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 | 188 |
200 | 189 |
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)]: | 190 for result, good in [('success', True), ('fail', False)]: |
232 for build_config in ['Release', 'Debug']: | 191 for build_config in ['Release', 'Debug']: |
233 for plat in ('win', 'mac', 'linux'): | 192 for plat in ('win', 'mac', 'linux'): |
234 for git_mode in True, False: | 193 for git_mode in True, False: |
235 suffix = '_git' if git_mode else '' | 194 suffix = '_git' if git_mode else '' |
236 | 195 |
237 step_mocks = step_mock('with patch', good) | 196 step_mocks = step_mock('with patch', good) |
238 if not good: | 197 if not good: |
239 step_mocks.update(step_mock('without patch', good)) | 198 step_mocks.update(step_mock('without patch', good)) |
240 | 199 |
241 yield ('%s_%s_%s%s' % (plat, result, build_config.lower(), suffix)), { | 200 yield ('%s_%s_%s%s' % (plat, result, build_config.lower(), suffix)), { |
242 'properties': api.properties_tryserver( | 201 'properties': api.properties.tryserver( |
243 build_config=build_config, | 202 build_config=build_config, |
244 config_name='blink', | 203 config_name='blink', |
245 root='src/third_party/WebKit', | 204 root='src/third_party/WebKit', |
246 GIT_MODE=git_mode, | 205 GIT_MODE=git_mode, |
247 ), | 206 ), |
248 'step_mocks': step_mocks, | 207 'step_mocks': step_mocks, |
249 'mock': { | 208 'mock': { |
250 'platform': { | 209 'platform': { |
251 'name': plat | 210 'name': plat |
252 } | 211 } |
253 } | 212 } |
254 } | 213 } |
255 | 214 |
256 warn_on_flakey_data = step_mock('with patch', False) | 215 warn_on_flakey_data = step_mock('with patch', False) |
257 warn_on_flakey_data.update(step_mock('without patch', True)) | 216 warn_on_flakey_data.update(step_mock('without patch', True)) |
258 yield 'warn_on_flakey', { | 217 yield 'warn_on_flakey', { |
259 'properties': api.properties_tryserver( | 218 'properties': api.properties.tryserver( |
260 build_config='Release', | 219 build_config='Release', |
261 config_name='blink', | 220 config_name='blink', |
262 root='src/third_party/WebKit', | 221 root='src/third_party/WebKit', |
263 GIT_MODE=False, | 222 GIT_MODE=False, |
264 ), | 223 ), |
265 'step_mocks': warn_on_flakey_data, | 224 'step_mocks': warn_on_flakey_data, |
266 'mock': { | 225 'mock': { |
267 'platform': { | 226 'platform': { |
268 'name': 'linux' | 227 'name': 'linux' |
269 } | 228 } |
270 } | 229 } |
271 } | 230 } |
OLD | NEW |