| OLD | NEW |
| 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 contextlib | 5 import contextlib |
| 6 import copy | 6 import copy |
| 7 import json | 7 import json |
| 8 | 8 |
| 9 from infra.libs.infra_types import freeze, thaw | 9 from infra.libs.infra_types import freeze, thaw |
| 10 from slave import recipe_api | 10 from slave import recipe_api |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 self.m.chromium.runhooks(name='runhooks (with patch)') | 263 self.m.chromium.runhooks(name='runhooks (with patch)') |
| 264 except self.m.step.StepFailure: | 264 except self.m.step.StepFailure: |
| 265 # As part of deapplying patch we call runhooks without the patch. | 265 # As part of deapplying patch we call runhooks without the patch. |
| 266 self.deapply_patch(update_step) | 266 self.deapply_patch(update_step) |
| 267 raise | 267 raise |
| 268 else: | 268 else: |
| 269 self.m.chromium.runhooks() | 269 self.m.chromium.runhooks() |
| 270 | 270 |
| 271 test_spec_file = bot_config.get('testing', {}).get('test_spec_file', | 271 test_spec_file = bot_config.get('testing', {}).get('test_spec_file', |
| 272 '%s.json' % mastername) | 272 '%s.json' % mastername) |
| 273 test_spec_path = self.m.path['checkout'].join('testing', 'buildbot', | 273 |
| 274 test_spec_file) | |
| 275 # TODO(phajdan.jr): Bots should have no generators instead. | 274 # TODO(phajdan.jr): Bots should have no generators instead. |
| 276 if bot_config.get('disable_tests'): | 275 if bot_config.get('disable_tests'): |
| 277 test_spec = {} | 276 test_spec = {} |
| 278 scripts_compile_targets = {} | 277 scripts_compile_targets = {} |
| 279 else: | 278 else: |
| 280 test_spec_result = self.m.json.read( | 279 test_spec = self.read_test_spec(self.m, test_spec_file) |
| 281 'read test spec', | 280 test_spec_path = self.m.path['checkout'].join('testing', 'buildbot', |
| 282 test_spec_path, | 281 test_spec_file) |
| 283 step_test_data=lambda: self.m.json.test_api.output({})) | |
| 284 test_spec_result.presentation.step_text = 'path: %s' % test_spec_path | |
| 285 test_spec = test_spec_result.json.output | |
| 286 | 282 |
| 287 scripts_compile_targets = \ | 283 scripts_compile_targets = \ |
| 288 self.m.chromium.get_compile_targets_for_scripts().json.output | 284 self.m.chromium.get_compile_targets_for_scripts().json.output |
| 289 | 285 |
| 290 for loop_buildername, builder_dict in master_dict.get( | 286 for loop_buildername, builder_dict in master_dict.get( |
| 291 'builders', {}).iteritems(): | 287 'builders', {}).iteritems(): |
| 292 builder_dict.setdefault('tests', []) | 288 builder_dict['tests'] = self.generate_tests_from_test_spec( |
| 293 # TODO(phajdan.jr): Switch everything to scripts generators and simplify. | 289 self.m, test_spec, builder_dict, |
| 294 for generator in builder_dict.get('test_generators', []): | 290 loop_buildername, mastername, enable_swarming, |
| 295 builder_dict['tests'] = ( | 291 scripts_compile_targets, builder_dict.get('test_generators', [])) |
| 296 list(generator(self.m, mastername, loop_buildername, test_spec, | |
| 297 enable_swarming=enable_swarming, | |
| 298 scripts_compile_targets=scripts_compile_targets)) + | |
| 299 builder_dict['tests']) | |
| 300 | 292 |
| 301 return update_step, freeze(master_dict), test_spec | 293 return update_step, freeze(master_dict), test_spec |
| 302 | 294 |
| 295 def generate_tests_from_test_spec(self, api, test_spec, builder_dict, |
| 296 buildername, mastername, enable_swarming, scripts_compile_targets, |
| 297 generators): |
| 298 tests = builder_dict.get('tests', []) |
| 299 # TODO(phajdan.jr): Switch everything to scripts generators and simplify. |
| 300 for generator in generators: |
| 301 tests = ( |
| 302 list(generator(api, mastername, buildername, test_spec, |
| 303 enable_swarming=enable_swarming, |
| 304 scripts_compile_targets=scripts_compile_targets)) + |
| 305 tests) |
| 306 return tests |
| 307 |
| 308 def read_test_spec(self, api, test_spec_file): |
| 309 test_spec_path = api.path['checkout'].join('testing', 'buildbot', |
| 310 test_spec_file) |
| 311 test_spec_result = api.json.read( |
| 312 'read test spec', |
| 313 test_spec_path, |
| 314 step_test_data=lambda: api.json.test_api.output({})) |
| 315 test_spec_result.presentation.step_text = 'path: %s' % test_spec_path |
| 316 test_spec = test_spec_result.json.output |
| 317 |
| 318 return test_spec |
| 319 |
| 303 def create_test_runner(self, api, tests, suffix=''): | 320 def create_test_runner(self, api, tests, suffix=''): |
| 304 """Creates a test runner to run a set of tests. | 321 """Creates a test runner to run a set of tests. |
| 305 | 322 |
| 306 Args: | 323 Args: |
| 307 api: API of the calling recipe. | 324 api: API of the calling recipe. |
| 308 tests: List of step.Test objects to be run. | 325 tests: List of step.Test objects to be run. |
| 309 suffix: Suffix to be passed when running the tests. | 326 suffix: Suffix to be passed when running the tests. |
| 310 | 327 |
| 311 Returns: | 328 Returns: |
| 312 A function that can be passed to setup_chromium_tests or run directly. | 329 A function that can be passed to setup_chromium_tests or run directly. |
| (...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 692 master_config.get('build_gs_bucket'), | 709 master_config.get('build_gs_bucket'), |
| 693 extra_url_components=None) | 710 extra_url_components=None) |
| 694 elif (mastername == 'tryserver.chromium.perf' or | 711 elif (mastername == 'tryserver.chromium.perf' or |
| 695 (mastername == 'tryserver.chromium.linux' and | 712 (mastername == 'tryserver.chromium.linux' and |
| 696 buildername == 'linux_full_bisect_builder')): | 713 buildername == 'linux_full_bisect_builder')): |
| 697 return None | 714 return None |
| 698 else: | 715 else: |
| 699 return self.m.archive.legacy_upload_url( | 716 return self.m.archive.legacy_upload_url( |
| 700 master_config.get('build_gs_bucket'), | 717 master_config.get('build_gs_bucket'), |
| 701 extra_url_components=self.m.properties['mastername']) | 718 extra_url_components=self.m.properties['mastername']) |
| OLD | NEW |