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

Unified Diff: recipe_modules/step/example.py

Issue 2875543002: [recipe_modules/step] do not set cwd if it is start_dir. (Closed)
Patch Set: fix take 2 Created 3 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
« no previous file with comments | « recipe_modules/step/api.py ('k') | recipe_modules/step/example.expected/basic.json » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: recipe_modules/step/example.py
diff --git a/recipe_modules/step/example.py b/recipe_modules/step/example.py
index 3f7c69d81bf445f7612828a685644d229808dca7..bd550c9f2f0fe6e5b1932cca6f94addb4ff877ba 100644
--- a/recipe_modules/step/example.py
+++ b/recipe_modules/step/example.py
@@ -18,14 +18,12 @@ RETURN_SCHEMA = config.ReturnSchema(
PROPERTIES = {
'bad_return': recipe_api.Property(default=False),
- 'raise_infra_failure': recipe_api.Property(default=False),
'access_invalid_data': recipe_api.Property(default=False),
'timeout': recipe_api.Property(default=0, kind=int),
}
-def RunSteps(
- api, bad_return, raise_infra_failure, access_invalid_data, timeout):
+def RunSteps(api, bad_return, access_invalid_data, timeout):
if bad_return:
return RETURN_SCHEMA.new(test_me='this should fail')
elif timeout:
@@ -45,6 +43,17 @@ def RunSteps(
api.step('hello', ['echo', 'Hello World'])
api.step('hello', ['echo', 'Why hello, there.'])
+ # You can change the current working directory as well
+ api.step('mk subdir', ['mkdir', 'something'])
+ with api.step.context({'cwd': api.path['start_dir'].join('something')}):
+ api.step('something', ['bash', '-c', 'echo Why hello, there, in a subdir.'])
nodir 2017/05/10 01:52:25 Did you mean "Well"?
iannucci 2017/05/10 01:56:51 Either one works :) https://english.stackexchange.
+
+ # By default, all steps run in 'start_dir', or the cwd of the recipe engine
+ # when the recipe begins. Because of this, setting cwd to start_dir doesn't
+ # show anything in particular in the expectations.
+ with api.step.context({'cwd': api.path['start_dir']}):
+ api.step('start_dir ignored', ['bash', '-c', 'echo what happen'])
+
# You can also manipulate various aspects of the step, such as env.
# These are passed straight through to subprocess.Popen.
# Also, abusing bash -c in this way is a TERRIBLE IDEA DON'T DO IT.
@@ -75,7 +84,7 @@ def RunSteps(
api.step('goodbye', ['echo', 'goodbye'])
# Modifying step_result now would raise an AssertionError.
except api.step.StepFailure:
- # Raising anything besides StepFailure or StepWarning causes the build to go
+ # Raising anything besides StepFailure or StepWarning causes the build to go
# purple.
raise ValueError('goodbye must exit 0!')
@@ -157,7 +166,6 @@ def GenTests(api):
yield (
api.test('infra_failure') +
- api.properties(raise_infra_failure=True) +
api.step_data('cleanup', retcode=1)
)
« no previous file with comments | « recipe_modules/step/api.py ('k') | recipe_modules/step/example.expected/basic.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698