| 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 | 5 |
| 6 # pylint: disable=W0201 | 6 # pylint: disable=W0201 |
| 7 | 7 |
| 8 | 8 |
| 9 import json | 9 import json |
| 10 import os | 10 import os |
| 11 import re | 11 import re |
| 12 import sys | 12 import sys |
| 13 | 13 |
| 14 from recipe_engine import recipe_api | 14 from recipe_engine import recipe_api |
| 15 from recipe_engine import config_types | 15 from recipe_engine import config_types |
| 16 | 16 |
| 17 from . import fake_specs | |
| 18 | |
| 19 | 17 |
| 20 class SkiaApi(recipe_api.RecipeApi): | 18 class SkiaApi(recipe_api.RecipeApi): |
| 21 | 19 |
| 22 def get_builder_spec(self, skia_dir, builder_name): | |
| 23 """Obtain the buildbot spec for the given builder.""" | |
| 24 fake_spec = None | |
| 25 if self._test_data.enabled: | |
| 26 fake_spec = fake_specs.FAKE_SPECS[builder_name] | |
| 27 builder_spec = self.m.run.json_from_file( | |
| 28 skia_dir.join('tools', 'buildbot_spec.py'), | |
| 29 skia_dir, | |
| 30 builder_name, | |
| 31 fake_spec) | |
| 32 return builder_spec | |
| 33 | |
| 34 def setup(self): | 20 def setup(self): |
| 35 """Prepare the bot to run.""" | 21 """Prepare the bot to run.""" |
| 36 # Setup dependencies. | 22 # Setup dependencies. |
| 37 self.m.vars.setup() | 23 self.m.vars.setup() |
| 38 | 24 |
| 39 # Check out the Skia code. | 25 # Check out the Skia code. |
| 40 self.checkout_steps() | 26 self.checkout_steps() |
| 41 | 27 |
| 42 # Obtain the spec for this builder from the Skia repo. Use it to set more | 28 # Obtain the spec for this builder from the Skia repo. Use it to set more |
| 43 # properties. | 29 # properties. |
| 44 builder_spec = self.get_builder_spec(self.m.vars.skia_dir, | 30 builder_spec = self.m.vars.get_builder_spec(self.m.vars.builder_name) |
| 45 self.m.vars.builder_name) | |
| 46 | 31 |
| 47 # Continue setting up vars with the builder_spec. | 32 # Continue setting up vars with the builder_spec. |
| 48 self.m.vars.update_with_builder_spec(builder_spec) | 33 self.m.vars.update_with_builder_spec(builder_spec) |
| 49 | 34 |
| 50 | |
| 51 if not self.m.path.exists(self.m.vars.tmp_dir): | 35 if not self.m.path.exists(self.m.vars.tmp_dir): |
| 52 self.m.run.run_once(self.m.file.makedirs, | 36 self.m.run.run_once(self.m.file.makedirs, |
| 53 'tmp_dir', | 37 'tmp_dir', |
| 54 self.m.vars.tmp_dir, | 38 self.m.vars.tmp_dir, |
| 55 infra_step=True) | 39 infra_step=True) |
| 56 | 40 |
| 57 self.m.flavor.setup() | 41 self.m.flavor.setup() |
| 58 | 42 |
| 59 def update_repo(self, parent_dir, repo): | 43 def update_repo(self, parent_dir, repo): |
| 60 """Update an existing repo. This is safe to call without gen_steps.""" | 44 """Update an existing repo. This is safe to call without gen_steps.""" |
| 61 repo_path = parent_dir.join(repo.name) | 45 repo_path = parent_dir.join(repo.name) |
| 62 if self.m.path.exists(repo_path): # pragma: nocover | 46 if self.m.path.exists(repo_path): # pragma: nocover |
| 63 if self.m.platform.is_win: | 47 if self.m.platform.is_win: |
| 64 git = 'git.bat' | 48 git = 'git.bat' |
| 65 else: | 49 else: |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 revert=False, | 144 revert=False, |
| 161 **checkout_kwargs) | 145 **checkout_kwargs) |
| 162 | 146 |
| 163 self.m.vars.got_revision = ( | 147 self.m.vars.got_revision = ( |
| 164 update_step.presentation.properties['got_revision']) | 148 update_step.presentation.properties['got_revision']) |
| 165 self.m.tryserver.maybe_apply_issue() | 149 self.m.tryserver.maybe_apply_issue() |
| 166 | 150 |
| 167 if self.m.vars.need_chromium_checkout: | 151 if self.m.vars.need_chromium_checkout: |
| 168 self.m.gclient.runhooks(cwd=self.m.vars.checkout_root, | 152 self.m.gclient.runhooks(cwd=self.m.vars.checkout_root, |
| 169 env=self.m.vars.gclient_env) | 153 env=self.m.vars.gclient_env) |
| OLD | NEW |