| 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 '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 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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.StepData(with_patch, canned_test(good)) |
| 250 'platform': { | 198 ) |
| 251 'name': plat | 199 if not good: |
| 252 } | 200 test += api.StepData(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.StepData(with_patch, canned_test(False)) + |
| 266 'mock': { | 212 api.StepData(without_patch, canned_test(True)) |
| 267 'platform': { | 213 ) |
| 268 'name': 'linux' | |
| 269 } | |
| 270 } | |
| 271 } | |
| OLD | NEW |