Chromium Code Reviews| Index: scripts/slave/recipe_modules/auto_bisect/api.py |
| diff --git a/scripts/slave/recipe_modules/auto_bisect/api.py b/scripts/slave/recipe_modules/auto_bisect/api.py |
| index ecbb988467a491943be3e97773c94a61a1ff0052..dfeb685c157739dcd1603e8d1b085f80e543ec2e 100644 |
| --- a/scripts/slave/recipe_modules/auto_bisect/api.py |
| +++ b/scripts/slave/recipe_modules/auto_bisect/api.py |
| @@ -8,6 +8,7 @@ This API is meant to enable the bisect recipe to bisect any chromium-supported |
| platform for any test that can be run via buildbot, perf or otherwise. |
| """ |
| +import contextlib |
| import os |
| from recipe_engine import recipe_api |
| @@ -51,6 +52,22 @@ class AutoBisectApi(recipe_api.RecipeApi): |
| # None means "default value". |
| self._working_dir = None |
| + @contextlib.contextmanager |
| + def noop_context_manager(_api): |
| + """This is a context manager that doesn't do anything. |
| + |
| + It is used for a placeholder for code that should be wrapped around ever |
|
RobertoCN
2016/11/08 19:16:56
nit: every
|
| + test execution of a bisect iteration or full build. Replace it with a |
| + real context manager (one that accepts an api argument) to do something |
| + useful. |
| + """ |
| + yield |
| + |
| + # test_context_mgr is run for each overall bisect run (i.e., once). |
|
jbudorick
2016/11/08 00:18:31
build_context_mgr
|
| + self.build_context_mgr = noop_context_manager |
| + # test_context_mgr is run for each iteration of the bisect. |
| + self.test_context_mgr = noop_context_manager |
| + |
| @property |
| def working_dir(self): |
| if not self._working_dir: |
| @@ -309,25 +326,26 @@ class AutoBisectApi(recipe_api.RecipeApi): |
| bot_config_object = self.m.chromium_tests.create_bot_config_object( |
| mastername, buildername) |
| with self.m.chromium_tests.wrap_chromium_tests(bot_config_object, tests): |
| - if self.m.chromium.c.TARGET_PLATFORM == 'android' and not skip_download: |
| - deploy_apks = [] |
| - deploy_args = [] |
| - if self.internal_bisect: # pragma: no cover |
| - deploy_args = list(bot_config['deploy_args']) |
| - deploy_apks = bot_config.get('deploy_apks') |
| - if deploy_apks: |
| - deploy_args.extend([ |
| - '--apks', |
| - ','.join(str(self.m.chromium_android.apk_path(apk)) |
| - for apk in deploy_apks)]) |
| - else: |
|
ghost stip (do not use)
2016/11/07 23:57:48
diff didn't like this indent for some reason
|
| - if bot_config.get('webview'): |
| - deploy_apks = ['SystemWebView.apk', 'SystemWebViewShell.apk'] |
| + with self.test_context_mgr(self.m): |
| + 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
|
| + deploy_apks = [] |
| + deploy_args = [] |
| + if self.internal_bisect: # pragma: no cover |
| + deploy_args = list(bot_config['deploy_args']) |
| + deploy_apks = bot_config.get('deploy_apks') |
| + if deploy_apks: |
| + deploy_args.extend([ |
| + '--apks', |
| + ','.join(str(self.m.chromium_android.apk_path(apk)) |
| + for apk in deploy_apks)]) |
| else: |
| - deploy_apks = ['ChromePublic.apk'] |
| - self.deploy_apk_on_device( |
| - self.full_deploy_script, deploy_apks, deploy_args) |
| - test_runner() |
| + if bot_config.get('webview'): |
| + deploy_apks = ['SystemWebView.apk', 'SystemWebViewShell.apk'] |
| + else: |
| + deploy_apks = ['ChromePublic.apk'] |
| + self.deploy_apk_on_device( |
| + self.full_deploy_script, deploy_apks, deploy_args) |
| + test_runner() |
| def deploy_apk_on_device(self, deploy_script, deploy_apks, deploy_args): |
| """Installs apk on the android device.""" |
| @@ -389,14 +407,7 @@ class AutoBisectApi(recipe_api.RecipeApi): |
| with api.step.context(context): |
| affected_files = self.m.tryserver.get_files_affected_by_patch() |
| - # Skip device setup for internal bisect as it is taken care in |
| - # internal recipes. |
| - if (api.chromium.c.TARGET_PLATFORM == 'android' and |
| - not self.internal_bisect): |
| - api.chromium_android.common_tests_setup_steps( |
| - perf_setup=True, remove_system_webview=True) |
| - api.chromium.runhooks() |
| - try: |
| + with self.build_context_mgr(api): |
|
ghost stip (do not use)
2016/11/07 23:57:48
😎
|
| # Run legacy bisect script if the patch contains bisect.cfg. |
| if BISECT_CONFIG_FILE in affected_files: |
| api.step('***LEGACY BISECT (deprecated)***', []) |
| @@ -415,12 +426,3 @@ class AutoBisectApi(recipe_api.RecipeApi): |
| api.step('***PERF TRYJOB***', []) |
| self.m.perf_try.start_perf_try_job( |
| api, affected_files, update_step, self.bot_db) |
| - finally: |
| - if api.chromium.c.TARGET_PLATFORM == 'android': |
| - if self.internal_bisect: # pragma: no cover |
| - api.chromium_android.init_and_sync( |
| - gclient_config=api.chromium_android.c.internal_dir_name, |
| - use_bot_update=True) |
| - else: |
| - self.ensure_checkout() |
| - api.chromium_android.common_tests_final_steps() |