Chromium Code Reviews| Index: scripts/slave/recipe_util.py |
| diff --git a/scripts/slave/recipe_util.py b/scripts/slave/recipe_util.py |
| index dd9cff57512fee0c9653a67334082ba9fb07f585..b450805bbe386ac11801e03753a08b9513f08e57 100644 |
| --- a/scripts/slave/recipe_util.py |
| +++ b/scripts/slave/recipe_util.py |
| @@ -63,9 +63,11 @@ functionality provided by annotated_run. |
| """ # pylint: disable=W0105 |
| checkout_path = _path_method('checkout_path', '%(CheckoutRootPlaceholder)s') |
| +def path_exists(path): |
| + return _os.path.exists(path) |
| @_contextlib.contextmanager |
| -def mock_paths(): |
| +def mock_paths(mock_path_exists=None): |
|
agable
2013/05/22 17:21:23
Thanks for adding this functionality. I find mock_
mkosiba (inactive)
2013/05/23 13:13:38
I struggled quite a bit with a good name for this
|
| """Used by unittest/recipes_test.py to temporarily override the paths |
| generated by the various path functions in this module. |
| @@ -78,6 +80,7 @@ def mock_paths(): |
| g = globals() |
| tokens = {} |
| path_funcs = {} |
| + mock_path_exists = frozenset(mock_path_exists or []) |
| try: |
| for name in path_base_names: |
| token_name = (name + '_root').upper() |
| @@ -91,6 +94,10 @@ def mock_paths(): |
| if path_func_name in g: |
| path_funcs[path_func_name] = g[path_func_name] |
| g[path_func_name] = _path_method(path_func_name, token_val) |
| + |
| + path_funcs['path_exists'] = g['path_exists'] |
| + g['path_exists'] = lambda path: path in mock_path_exists |
| + |
| yield |
| finally: |
| g.update(tokens) |
| @@ -366,10 +373,18 @@ class Steps(object): |
| self.git('submodule', 'update', '--init', '--recursive'), |
| ] |
| - def gclient_checkout(self, common_repo_name, git_mode=False): |
| + def gclient_checkout(self, common_repo_name_or_spec, git_mode=False, |
| + spec_name=None): |
| """Returns a step generator function for gclient checkouts.""" |
| - spec = GCLIENT_COMMON_SPECS[common_repo_name](self) |
| + if isinstance(common_repo_name_or_spec, basestring): |
| + spec = GCLIENT_COMMON_SPECS[common_repo_name_or_spec](self) |
| + else: |
| + spec = common_repo_name_or_spec |
| spec_string = '' |
| + if not spec_name: |
| + step_name = lambda n: 'gclient ' + n |
| + else: |
| + step_name = lambda n: '[spec: %s] gclient %s' % (spec_name, n) |
|
agable
2013/05/22 17:21:23
I'd rather have the spec_name emitted as a @@@STEP
mkosiba (inactive)
2013/05/23 13:13:38
The reason for this is not to differentiate in the
agable
2013/05/23 17:20:12
D'oh. SGTM, then.
|
| for key in spec: |
| # We should be using json.dumps here, but gclient directly execs the dict |
| # that it receives as the argument to --spec, so we have to have True, |
| @@ -378,8 +393,9 @@ class Steps(object): |
| gclient = depot_tools_path('gclient') + ('.bat' if IsWindows() else '') |
| if not git_mode: |
| - clean_step = self.step('gclient clean', [gclient, 'revert', '--nohooks']) |
| - sync_step = self.step('gclient sync', [gclient, 'sync', '--nohooks']) |
| + clean_step = self.step(step_name('clean'), |
| + [gclient, 'revert', '--nohooks']) |
| + sync_step = self.step(step_name('sync'), [gclient, 'sync', '--nohooks']) |
| else: |
| # clean() isn't used because the gclient sync flags passed in checkout() |
| # do much the same thing, and they're more correct than doing a separate |
| @@ -395,12 +411,12 @@ class Steps(object): |
| # git-based builds (e.g. maybe some combination of 'git reset/clean -fx' |
| # and removing the 'out' directory). |
| clean_step = None |
| - sync_step = self.step('gclient sync', [ |
| + sync_step = self.step(step_name('sync'), [ |
| gclient, 'sync', '--verbose', '--with_branch_heads', '--nohooks', |
| '--reset', '--delete_unversioned_trees', '--force']) |
| steps = [ |
| self.step( |
| - 'gclient setup', |
| + step_name('setup'), |
| [gclient, 'config', '--spec', spec_string], |
| static_json_data={ |
| 'CheckoutRoot': slave_build_path(spec['solutions'][0]['name']), |