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

Side by Side Diff: recipe_modules/file/examples/copytree.py

Issue 2918463002: [recipe_modules/file] add real file module to engine. (Closed)
Patch Set: rebase 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 unified diff | Download patch
OLDNEW
(Empty)
1 # Copyright 2017 The LUCI Authors. All rights reserved.
2 # Use of this source code is governed under the Apache License, Version 2.0
3 # that can be found in the LICENSE file.
4
5 DEPS = [
6 "file",
7 "path",
8 ]
9
10
11 def RunSteps(api):
12 file_names = ['a', 'aa', 'b', 'bb', 'c', 'cc']
13
14 dest = api.path['start_dir'].join('some dir')
15 api.file.ensure_directory('ensure "some dir"', dest)
16 for fname in file_names:
17 api.file.write_text('write %s' % fname, dest.join(fname), fname)
18
19 dest2 = api.path['start_dir'].join('some other dir')
20 api.file.rmtree('make sure dest is gone', dest2)
21 api.file.copytree('copy it', dest, dest2)
22
23 paths = api.file.listdir('list new dir', dest2, file_names)
24 assert paths == [dest2.join(n) for n in file_names], paths
25
26 paths = api.file.glob_paths('glob *a', dest2, '*a', ['a', 'aa'])
27 assert paths == [dest2.join('a'), dest2.join('aa')], paths
28
29 for pth in paths:
30 assert api.file.read_text('read %s' % pth, pth, api.path.basename(pth))
31
32 api.file.remove('rm a', dest2.join('a'))
33 paths = api.file.glob_paths('glob *a', dest2, '*a', ['aa'])
34 assert paths == [dest2.join('aa')], paths
35
36 api.file.rmglob('rm b*', dest2, 'b*')
37 paths = api.file.listdir('list new dir', dest2, ['aa', 'c', 'cc'])
38 assert paths == [dest2.join(p) for p in ['aa', 'c', 'cc']], paths
39
40 api.file.rmcontents('remove "some other dir/*"', dest2)
41 assert api.path.exists(dest2), dest2
42
43
44
45 def GenTests(api):
46 yield api.test('basic')
47
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698