Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(123)

Unified Diff: scripts/slave/recipe_util.py

Issue 14988009: First cut of testing infrastructure for recipes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/build
Patch Set: Pylinting Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: scripts/slave/recipe_util.py
diff --git a/scripts/slave/recipe_util.py b/scripts/slave/recipe_util.py
index 3c9da0979eca3e61a6d03a9f317ed65a18558555..cb4557dcf382c7c7d312c701e4030d59a44b3fe5 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")
Isaac (away) 2013/05/14 21:34:27 did pylint really pass on this? Maybe use gpylint
+
+ 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

Powered by Google App Engine
This is Rietveld 408576698