OLD | NEW |
---|---|
1 # Copyright 2015 The Chromium Authors. All rights reserved. | 1 # Copyright 2015 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 """API for the bisect recipe module. | 5 """API for the bisect recipe module. |
6 | 6 |
7 This API is meant to enable the bisect recipe to bisect any chromium-supported | 7 This API is meant to enable the bisect recipe to bisect any chromium-supported |
8 platform for any test that can be run via buildbot, perf or otherwise. | 8 platform for any test that can be run via buildbot, perf or otherwise. |
9 """ | 9 """ |
10 | 10 |
11 import contextlib | |
11 import os | 12 import os |
12 | 13 |
13 from recipe_engine import recipe_api | 14 from recipe_engine import recipe_api |
14 from . import bisector | 15 from . import bisector |
15 from . import depot_config | 16 from . import depot_config |
16 from . import revision_state | 17 from . import revision_state |
17 from . import local_bisect | 18 from . import local_bisect |
18 | 19 |
19 BISECT_CONFIG_FILE = 'tools/auto_bisect/bisect.cfg' | 20 BISECT_CONFIG_FILE = 'tools/auto_bisect/bisect.cfg' |
20 | 21 |
(...skipping 23 matching lines...) Expand all Loading... | |
44 # The variable below are set and used for the internal bisects. | 45 # The variable below are set and used for the internal bisects. |
45 self.buildurl_gs_prefix = None | 46 self.buildurl_gs_prefix = None |
46 self.internal_bisect = False | 47 self.internal_bisect = False |
47 self.builder_bot = None | 48 self.builder_bot = None |
48 self.full_deploy_script = None | 49 self.full_deploy_script = None |
49 | 50 |
50 # Keep track of working directory (which contains the checkout). | 51 # Keep track of working directory (which contains the checkout). |
51 # None means "default value". | 52 # None means "default value". |
52 self._working_dir = None | 53 self._working_dir = None |
53 | 54 |
55 @contextlib.contextmanager | |
56 def noop_context_manager(_api): | |
57 """This is a context manager that doesn't do anything. | |
58 | |
59 It is used for a placeholder for code that should be wrapped around ever | |
RobertoCN
2016/11/08 19:16:56
nit: every
| |
60 test execution of a bisect iteration or full build. Replace it with a | |
61 real context manager (one that accepts an api argument) to do something | |
62 useful. | |
63 """ | |
64 yield | |
65 | |
66 # test_context_mgr is run for each overall bisect run (i.e., once). | |
jbudorick
2016/11/08 00:18:31
build_context_mgr
| |
67 self.build_context_mgr = noop_context_manager | |
68 # test_context_mgr is run for each iteration of the bisect. | |
69 self.test_context_mgr = noop_context_manager | |
70 | |
54 @property | 71 @property |
55 def working_dir(self): | 72 def working_dir(self): |
56 if not self._working_dir: | 73 if not self._working_dir: |
57 self._working_dir = self.m.chromium_checkout.get_checkout_dir({}) | 74 self._working_dir = self.m.chromium_checkout.get_checkout_dir({}) |
58 return self._working_dir or self.m.path['slave_build'] | 75 return self._working_dir or self.m.path['slave_build'] |
59 | 76 |
60 def perform_bisect(self, **flags): | 77 def perform_bisect(self, **flags): |
61 return local_bisect.perform_bisect(self, **flags) | 78 return local_bisect.perform_bisect(self, **flags) |
62 | 79 |
63 def create_bisector(self, bisect_config_dict, dummy_mode=False, **flags): | 80 def create_bisector(self, bisect_config_dict, dummy_mode=False, **flags): |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
302 | 319 |
303 if not tests: # pragma: no cover | 320 if not tests: # pragma: no cover |
304 return | 321 return |
305 self.m.chromium_swarming.configure_swarming( | 322 self.m.chromium_swarming.configure_swarming( |
306 'chromium', precommit=False, mastername=mastername) | 323 'chromium', precommit=False, mastername=mastername) |
307 test_runner = self.m.chromium_tests.create_test_runner(self.m, tests) | 324 test_runner = self.m.chromium_tests.create_test_runner(self.m, tests) |
308 | 325 |
309 bot_config_object = self.m.chromium_tests.create_bot_config_object( | 326 bot_config_object = self.m.chromium_tests.create_bot_config_object( |
310 mastername, buildername) | 327 mastername, buildername) |
311 with self.m.chromium_tests.wrap_chromium_tests(bot_config_object, tests): | 328 with self.m.chromium_tests.wrap_chromium_tests(bot_config_object, tests): |
312 if self.m.chromium.c.TARGET_PLATFORM == 'android' and not skip_download: | 329 with self.test_context_mgr(self.m): |
313 deploy_apks = [] | 330 if self.m.chromium.c.TARGET_PLATFORM == 'android' and not skip_download: |
ghost stip (do not use)
2016/11/07 23:57:48
I would have added this part to the context manage
| |
314 deploy_args = [] | 331 deploy_apks = [] |
315 if self.internal_bisect: # pragma: no cover | 332 deploy_args = [] |
316 deploy_args = list(bot_config['deploy_args']) | 333 if self.internal_bisect: # pragma: no cover |
317 deploy_apks = bot_config.get('deploy_apks') | 334 deploy_args = list(bot_config['deploy_args']) |
318 if deploy_apks: | 335 deploy_apks = bot_config.get('deploy_apks') |
319 deploy_args.extend([ | 336 if deploy_apks: |
320 '--apks', | 337 deploy_args.extend([ |
321 ','.join(str(self.m.chromium_android.apk_path(apk)) | 338 '--apks', |
322 for apk in deploy_apks)]) | 339 ','.join(str(self.m.chromium_android.apk_path(apk)) |
323 else: | 340 for apk in deploy_apks)]) |
ghost stip (do not use)
2016/11/07 23:57:48
diff didn't like this indent for some reason
| |
324 if bot_config.get('webview'): | |
325 deploy_apks = ['SystemWebView.apk', 'SystemWebViewShell.apk'] | |
326 else: | 341 else: |
327 deploy_apks = ['ChromePublic.apk'] | 342 if bot_config.get('webview'): |
328 self.deploy_apk_on_device( | 343 deploy_apks = ['SystemWebView.apk', 'SystemWebViewShell.apk'] |
329 self.full_deploy_script, deploy_apks, deploy_args) | 344 else: |
330 test_runner() | 345 deploy_apks = ['ChromePublic.apk'] |
346 self.deploy_apk_on_device( | |
347 self.full_deploy_script, deploy_apks, deploy_args) | |
348 test_runner() | |
331 | 349 |
332 def deploy_apk_on_device(self, deploy_script, deploy_apks, deploy_args): | 350 def deploy_apk_on_device(self, deploy_script, deploy_apks, deploy_args): |
333 """Installs apk on the android device.""" | 351 """Installs apk on the android device.""" |
334 if deploy_script: # pragma: no cover | 352 if deploy_script: # pragma: no cover |
335 self.full_deploy_on_device(deploy_script, deploy_args) | 353 self.full_deploy_on_device(deploy_script, deploy_args) |
336 else: | 354 else: |
337 for apk in deploy_apks: | 355 for apk in deploy_apks: |
338 self.m.chromium_android.adb_install_apk(apk) | 356 self.m.chromium_android.adb_install_apk(apk) |
339 | 357 |
340 def full_deploy_on_device(self, deploy_script, args=None): # pragma: no cover | 358 def full_deploy_on_device(self, deploy_script, args=None): # pragma: no cover |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
382 '', None, None) | 400 '', None, None) |
383 else: | 401 else: |
384 self.bot_db = bot_db | 402 self.bot_db = bot_db |
385 | 403 |
386 context = {} | 404 context = {} |
387 if self.working_dir: | 405 if self.working_dir: |
388 context['cwd'] = self.working_dir | 406 context['cwd'] = self.working_dir |
389 | 407 |
390 with api.step.context(context): | 408 with api.step.context(context): |
391 affected_files = self.m.tryserver.get_files_affected_by_patch() | 409 affected_files = self.m.tryserver.get_files_affected_by_patch() |
392 # Skip device setup for internal bisect as it is taken care in | 410 with self.build_context_mgr(api): |
ghost stip (do not use)
2016/11/07 23:57:48
😎
| |
393 # internal recipes. | |
394 if (api.chromium.c.TARGET_PLATFORM == 'android' and | |
395 not self.internal_bisect): | |
396 api.chromium_android.common_tests_setup_steps( | |
397 perf_setup=True, remove_system_webview=True) | |
398 api.chromium.runhooks() | |
399 try: | |
400 # Run legacy bisect script if the patch contains bisect.cfg. | 411 # Run legacy bisect script if the patch contains bisect.cfg. |
401 if BISECT_CONFIG_FILE in affected_files: | 412 if BISECT_CONFIG_FILE in affected_files: |
402 api.step('***LEGACY BISECT (deprecated)***', []) | 413 api.step('***LEGACY BISECT (deprecated)***', []) |
403 self.run_bisect_script(**kwargs) | 414 self.run_bisect_script(**kwargs) |
404 elif api.properties.get('bisect_config'): | 415 elif api.properties.get('bisect_config'): |
405 # We can distinguish between a config for a full bisect vs a single | 416 # We can distinguish between a config for a full bisect vs a single |
406 # test by checking for the presence of the good_revision key. | 417 # test by checking for the presence of the good_revision key. |
407 if api.properties.get('bisect_config').get('good_revision'): | 418 if api.properties.get('bisect_config').get('good_revision'): |
408 api.step('***BISECT***', []) | 419 api.step('***BISECT***', []) |
409 local_bisect.perform_bisect(self, **flags) # pragma: no cover | 420 local_bisect.perform_bisect(self, **flags) # pragma: no cover |
410 else: | 421 else: |
411 api.step('***SINGLE TEST (deprecated)***', []) | 422 api.step('***SINGLE TEST (deprecated)***', []) |
412 self.start_test_run_for_bisect(update_step, self.bot_db, | 423 self.start_test_run_for_bisect(update_step, self.bot_db, |
413 api.properties) | 424 api.properties) |
414 else: | 425 else: |
415 api.step('***PERF TRYJOB***', []) | 426 api.step('***PERF TRYJOB***', []) |
416 self.m.perf_try.start_perf_try_job( | 427 self.m.perf_try.start_perf_try_job( |
417 api, affected_files, update_step, self.bot_db) | 428 api, affected_files, update_step, self.bot_db) |
418 finally: | |
419 if api.chromium.c.TARGET_PLATFORM == 'android': | |
420 if self.internal_bisect: # pragma: no cover | |
421 api.chromium_android.init_and_sync( | |
422 gclient_config=api.chromium_android.c.internal_dir_name, | |
423 use_bot_update=True) | |
424 else: | |
425 self.ensure_checkout() | |
426 api.chromium_android.common_tests_final_steps() | |
OLD | NEW |