| 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 itertools | 7 import itertools |
| 8 import json | 8 import json |
| 9 | 9 |
| 10 from recipe_engine.types import freeze | 10 from recipe_engine.types import freeze |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 # (3) 'HEAD' for forced builds with unspecified 'revision'. | 123 # (3) 'HEAD' for forced builds with unspecified 'revision'. |
| 124 # TODO(machenbach): Use parent_got_cr_revision on testers with component | 124 # TODO(machenbach): Use parent_got_cr_revision on testers with component |
| 125 # builds to match also the chromium revision from the builder. | 125 # builds to match also the chromium revision from the builder. |
| 126 component_rev = self.m.properties.get('revision') or 'HEAD' | 126 component_rev = self.m.properties.get('revision') or 'HEAD' |
| 127 if bot_type == 'tester': | 127 if bot_type == 'tester': |
| 128 component_rev = self.m.properties.get( | 128 component_rev = self.m.properties.get( |
| 129 'parent_got_revision', component_rev) | 129 'parent_got_revision', component_rev) |
| 130 dep = bot_config.get('set_component_rev') | 130 dep = bot_config.get('set_component_rev') |
| 131 self.m.gclient.c.revisions[dep['name']] = dep['rev_str'] % component_rev | 131 self.m.gclient.c.revisions[dep['name']] = dep['rev_str'] % component_rev |
| 132 | 132 |
| 133 def get_checkout_dir(self, bot_config): |
| 134 try: |
| 135 builder_cache = self.m.path['builder_cache'] |
| 136 except KeyError: # no-op if builder cache is not set up. |
| 137 return None |
| 138 else: |
| 139 sanitized_buildername = ''.join( |
| 140 c if c.isalnum() else '_' for c in self.m.properties['buildername']) |
| 141 checkout_dir = builder_cache.join( |
| 142 bot_config.get('checkout_dir', sanitized_buildername)) |
| 143 self.m.shutil.makedirs('checkout path', checkout_dir) |
| 144 return checkout_dir |
| 145 |
| 133 def ensure_checkout(self, bot_config, root_solution_revision=None, | 146 def ensure_checkout(self, bot_config, root_solution_revision=None, |
| 134 force=False): | 147 force=False): |
| 135 if self.m.platform.is_win: | 148 if self.m.platform.is_win: |
| 136 self.m.chromium.taskkill() | 149 self.m.chromium.taskkill() |
| 137 | 150 |
| 138 kwargs = {} | 151 kwargs = {} |
| 139 try: | 152 self._working_dir = self.get_checkout_dir(bot_config) |
| 140 builder_cache = self.m.path['builder_cache'] | 153 if self._working_dir: |
| 141 except KeyError: # no-op if builder cache is not set up. | 154 kwargs['cwd'] = self._working_dir |
| 142 pass | |
| 143 else: | |
| 144 sanitized_buildername = ''.join( | |
| 145 c if c.isalnum() else '_' for c in self.m.properties['buildername']) | |
| 146 checkout_path = builder_cache.join( | |
| 147 bot_config.get('checkout_dir', sanitized_buildername)) | |
| 148 self.m.shutil.makedirs('checkout path', checkout_path) | |
| 149 kwargs['cwd'] = checkout_path | |
| 150 self._working_dir = checkout_path | |
| 151 | 155 |
| 152 # Bot Update re-uses the gclient configs. | 156 # Bot Update re-uses the gclient configs. |
| 153 update_step = self.m.bot_update.ensure_checkout( | 157 update_step = self.m.bot_update.ensure_checkout( |
| 154 patch_root=bot_config.get('patch_root'), | 158 patch_root=bot_config.get('patch_root'), |
| 155 root_solution_revision=root_solution_revision, | 159 root_solution_revision=root_solution_revision, |
| 156 clobber=bot_config.get('clobber', False), | 160 clobber=bot_config.get('clobber', False), |
| 157 force=force, **kwargs) | 161 force=force, **kwargs) |
| 158 assert update_step.json.output['did_run'] | 162 assert update_step.json.output['did_run'] |
| 159 # HACK(dnj): Remove after 'crbug.com/398105' has landed | 163 # HACK(dnj): Remove after 'crbug.com/398105' has landed |
| 160 self.m.chromium.set_build_properties(update_step.json.output['properties']) | 164 self.m.chromium.set_build_properties(update_step.json.output['properties']) |
| (...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 808 | 812 |
| 809 if not tests: | 813 if not tests: |
| 810 return | 814 return |
| 811 | 815 |
| 812 api.chromium_swarming.configure_swarming( | 816 api.chromium_swarming.configure_swarming( |
| 813 'chromium', precommit=False, mastername=mastername) | 817 'chromium', precommit=False, mastername=mastername) |
| 814 test_runner = api.chromium_tests.create_test_runner( | 818 test_runner = api.chromium_tests.create_test_runner( |
| 815 api, tests, serialize_tests=bot_config.get('serialize_tests')) | 819 api, tests, serialize_tests=bot_config.get('serialize_tests')) |
| 816 with api.chromium_tests.wrap_chromium_tests(bot_config, tests): | 820 with api.chromium_tests.wrap_chromium_tests(bot_config, tests): |
| 817 test_runner() | 821 test_runner() |
| OLD | NEW |