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

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

Issue 2918463002: [recipe_modules/file] add real file module to engine. (Closed)
Patch Set: fix rmtree 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 names = api.file.listdir('list new dir', dest2, file_names)
24 assert names == file_names, names
25
26 paths = api.file.glob_paths('glob *a', dest2.join('*a'),
27 [dest2.join(x) for x in ('a', 'aa')])
28 assert paths == [dest2.join('a'), dest2.join('aa')], paths
29
30 for pth in paths:
31 assert api.file.read_text('read %s' % pth, pth, api.path.basename(pth))
32
33 api.file.remove('rm a', dest2.join('a'))
34 paths = api.file.glob_paths('glob *a', dest2.join('*a'), [dest2.join('aa')])
35 assert paths == [dest2.join('aa')], paths
36
37 api.file.rmglob('rm b*', dest2, 'b*')
38 new_names = ['aa', 'c', 'cc']
39 names = api.file.listdir('list new dir', dest2, new_names)
40 assert names == new_names, names
41
42 api.file.rmcontents('remove "some other dir/*"', dest2)
43 assert api.path.exists(dest2), dest2
44
45
46
47 def GenTests(api):
48 yield api.test('basic')
49
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698