| Index: scripts/slave/recipe_util.py
|
| diff --git a/scripts/slave/recipe_util.py b/scripts/slave/recipe_util.py
|
| index a67cd054e54e282c524e3693c82009247c347810..e3823e68266d1dc271d53790b98aee03bf4f1072 100644
|
| --- a/scripts/slave/recipe_util.py
|
| +++ b/scripts/slave/recipe_util.py
|
| @@ -4,6 +4,7 @@
|
|
|
| """This module holds utilities which make writing recipes easier."""
|
|
|
| +import contextlib as _contextlib
|
| import os as _os
|
|
|
| # e.g. /b/build/slave/<slave-name>/build
|
| @@ -57,6 +58,32 @@ functionality provided by annotated_run.
|
| checkout_path = _path_method('checkout_path', "%(CheckoutRootPlaceholder)s")
|
|
|
|
|
| +@_contextlib.contextmanager
|
| +def mock_paths():
|
| + path_base_names = ['depot_tools', 'build_internal', 'build', 'slave_build',
|
| + 'root']
|
| + g = globals()
|
| + tokens = {}
|
| + path_funcs = {}
|
| + try:
|
| + for name in path_base_names:
|
| + token_name = (name+"_root").upper()
|
| + token_val = '[%s]' % token_name
|
| + path_func_name = (name+"_path")
|
| +
|
| + if token_name in g:
|
| + tokens[token_name] = g[token_name]
|
| + g[token_name] = token_val
|
| +
|
| + 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)
|
| + yield
|
| + finally:
|
| + g.update(tokens)
|
| + g.update(path_funcs)
|
| +
|
| +
|
| def deep_set(obj, key_vals):
|
| """Take an object (a dict or list), and a list of key/value pairs to set,
|
| and transform it by replacing items in obj at the key locations with the
|
|
|