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

Unified Diff: recipe_modules/file/examples/copy.py

Issue 2918463002: [recipe_modules/file] add real file module to engine. (Closed)
Patch Set: fix stuff 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
Index: recipe_modules/file/examples/copy.py
diff --git a/recipe_modules/file/examples/copy.py b/recipe_modules/file/examples/copy.py
new file mode 100644
index 0000000000000000000000000000000000000000..ec6d9d05e215c69c248437c9f38690f390ff3860
--- /dev/null
+++ b/recipe_modules/file/examples/copy.py
@@ -0,0 +1,32 @@
+# Copyright 2017 The LUCI Authors. All rights reserved.
+# Use of this source code is governed under the Apache License, Version 2.0
+# that can be found in the LICENSE file.
+
+DEPS = [
+ "file",
+ "path",
+]
+
+
+def RunSteps(api):
+ dest = api.path['start_dir'].join('some file')
+ data = 'Here is some text data'
+
+ api.file.write_text('write a file', dest, data)
+ api.file.copy('copy it', dest, api.path['start_dir'].join('new path'))
+ read_data = api.file.read_text(
+ 'read it', api.path['start_dir'].join('new path'), test_data=data)
+
+ assert read_data == data, (read_data, data)
+
+ api.file.move('move it', api.path['start_dir'].join('new path'),
+ api.path['start_dir'].join('new new path'))
+
+ read_data = api.file.read_text(
+ 'read it', api.path['start_dir'].join('new new path'), test_data=data)
+
+ assert read_data == data, (read_data, data)
+
+
+def GenTests(api):
+ yield api.test('basic')

Powered by Google App Engine
This is Rietveld 408576698