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

Unified Diff: recipe_modules/context/examples/full.py

Issue 2925453002: [context] Add path prefix/suffix manipulation. (Closed)
Patch Set: comments, use sentinels Created 3 years, 6 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: recipe_modules/context/examples/full.py
diff --git a/recipe_modules/context/examples/full.py b/recipe_modules/context/examples/full.py
index 960ef0ee6a63bb2fc7943b1416be1dcb57080eef..3f876960cfca14a924048f44613e000450c02914 100644
--- a/recipe_modules/context/examples/full.py
+++ b/recipe_modules/context/examples/full.py
@@ -21,14 +21,20 @@ def RunSteps(api):
api.step('default step', ['bash', '-c', 'echo default!'])
# can change cwd
- api.step('mk subdir', ['mkdir', 'subdir'])
+ api.step('mk subdir', ['mkdir', '-p', 'subdir'])
with api.context(cwd=api.path['start_dir'].join('subdir')):
api.step('subdir step', ['bash', '-c', 'pwd'])
api.step('other subdir step', ['bash', '-c', 'echo hi again!'])
- # can set envvars
- with api.context(env={'HELLO': 'WORLD', 'HOME': None}):
- api.step('env step', ['bash', '-c', 'echo $HELLO; echo $HOME'])
+ # can set envvars, and path prefix.
+ with api.context(env={'FOO': 'bar'}):
+ api.step('env step', ['bash', '-c', 'echo $FOO'])
+
+ pants = api.path['start_dir'].join('pants')
+ shirt = api.path['start_dir'].join('shirt')
+ with api.context(env={'FOO': api.context.Prefix(pants, shirt)}):
+ api.step('env step with prefix',
+ ['bash', '-c', 'echo $FOO'])
# %-formats are errors (for now). Double-% escape them.
bad_examples = ['%format', '%s']

Powered by Google App Engine
This is Rietveld 408576698