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

Unified Diff: scripts/slave/recipe_modules/file/example.py

Issue 1101673005: Extract functions from path recipe module so that step can depend on it (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/build
Patch Set: Created 5 years, 8 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_modules/file/example.py
diff --git a/scripts/slave/recipe_modules/file/example.py b/scripts/slave/recipe_modules/file/example.py
index df7ba1a2f0bf9750ddf7da1f1b27814561030de0..ce3edf5d061936fe8882c66f030b52ffdfeb0e50 100644
--- a/scripts/slave/recipe_modules/file/example.py
+++ b/scripts/slave/recipe_modules/file/example.py
@@ -8,6 +8,7 @@ DEPS = [
'file',
'path',
'raw_io',
+ 'step',
]
@@ -23,6 +24,22 @@ efg
def GenSteps(api):
+ # listdir demo.
+ result = api.file.listdir('fake dir', '/fake/dir')
+ for element in result:
+ api.step('manipulate %s' % str(element), ['some', 'command'])
+
+ # mkdtemp demo.
+ for prefix in ('prefix_a', 'prefix_b'):
+ # Create temp dir.
+ temp_dir = api.path.mkdtemp(prefix)
+ assert api.path.exists(temp_dir)
+ # Make |temp_dir| surface in expectation files.
+ api.step('print %s' % prefix, ['echo', temp_dir])
+
+ # rmwildcard demo
+ api.file.rmwildcard('*.o', api.path['slave_build'])
+
for name, content in TEST_CONTENTS.iteritems():
api.file.write('write_%s' % name, 'tmp_file.txt', content)
actual_content = api.file.read(
@@ -36,7 +53,7 @@ def GenSteps(api):
# copytree
content = 'some file content'
tmp_dir = api.path['slave_build'].join('copytree_example_tmp')
- api.path.makedirs('makedirs', tmp_dir)
+ api.file.makedirs('makedirs', tmp_dir)
path = tmp_dir.join('dummy_file')
api.file.write('write %s' % path, path, content)
new_tmp = api.path['slave_build'].join('copytree_example_tmp2')
@@ -53,8 +70,8 @@ def GenSteps(api):
assert files == [str(tmp_dir.join('dummy_file'))], files
finally:
- api.path.rmtree('cleanup', tmp_dir)
- api.path.rmtree('cleanup2', new_tmp)
+ api.file.rmtree('cleanup', tmp_dir)
+ api.file.rmtree('cleanup2', new_tmp)
def GenTests(api):
« no previous file with comments | « scripts/slave/recipe_modules/file/api.py ('k') | scripts/slave/recipe_modules/file/example.expected/file_io.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698