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

Side by Side Diff: recipe_modules/path/examples/full.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
1 # Copyright 2014 The LUCI Authors. All rights reserved. 1 # Copyright 2014 The LUCI Authors. All rights reserved.
2 # Use of this source code is governed under the Apache License, Version 2.0 2 # Use of this source code is governed under the Apache License, Version 2.0
3 # that can be found in the LICENSE file. 3 # that can be found in the LICENSE file.
4 4
5 DEPS = [ 5 DEPS = [
6 'path', 6 'path',
7 'platform', 7 'platform',
8 'properties', 8 'properties',
9 'step', 9 'step',
10 ] 10 ]
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 assert api.path.exists(file_path) 48 assert api.path.exists(file_path)
49 49
50 realpath = api.path.realpath(file_path) 50 realpath = api.path.realpath(file_path)
51 assert api.path.exists(realpath) 51 assert api.path.exists(realpath)
52 52
53 home_path = api.path.join(api.path.expanduser('~'), 'file') 53 home_path = api.path.join(api.path.expanduser('~'), 'file')
54 api.step('touch my home', ['touch', home_path]) 54 api.step('touch my home', ['touch', home_path])
55 api.path.mock_add_paths(home_path) 55 api.path.mock_add_paths(home_path)
56 assert api.path.exists(home_path) 56 assert api.path.exists(home_path)
57 57
58 # can mock copy paths. See the file module to do this for real.
59 copy1 = api.path['start_dir'].join('copy1')
60 copy2 = api.path['start_dir'].join('copy2')
61 api.step('rm copy2 (initial)', ['rm', '-rf', copy2])
62
63 api.step('mkdirs', ['mkdir', '-p', copy1.join('foo', 'bar')])
64 api.path.mock_add_paths(copy1.join('foo', 'bar'))
65 api.step('cp copy1 copy2', ['cp', '-a', copy1, copy2])
66 api.path.mock_copy_paths(copy1, copy2)
67 assert api.path.exists(copy2.join('foo', 'bar'))
68
69 # can mock remove paths. See the file module to do this for real.
70 api.step('rm copy2/foo', ['rm', '-rf', copy2.join('foo')])
71 api.path.mock_remove_paths(str(copy2)+api.path.sep)
72 assert not api.path.exists(copy2.join('foo', 'bar'))
73 assert not api.path.exists(copy2.join('foo'))
74 assert api.path.exists(copy2)
75
76 api.step('rm copy2', ['rm', '-rf', copy2])
77 api.path.mock_remove_paths(copy2)
78 assert not api.path.exists(copy2)
79
58 # Convert strings to Paths 80 # Convert strings to Paths
59 paths_to_convert = [ 81 paths_to_convert = [
60 api.path['start_dir'].join('some', 'thing'), 82 api.path['start_dir'].join('some', 'thing'),
61 api.path['start_dir'], 83 api.path['start_dir'],
62 api.path.resource("module_resource.py"), 84 api.path.resource("module_resource.py"),
63 api.path.resource(), 85 api.path.resource(),
64 api.resource("recipe_resource.py"), 86 api.resource("recipe_resource.py"),
65 api.resource(), 87 api.resource(),
66 ] 88 ]
67 for p in paths_to_convert: 89 for p in paths_to_convert:
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 127
106 yield (api.test('%s_luci' % platform) + 128 yield (api.test('%s_luci' % platform) +
107 api.platform.name(platform) + 129 api.platform.name(platform) +
108 api.properties(**{ 130 api.properties(**{
109 '$recipe_engine/path': { 131 '$recipe_engine/path': {
110 'cache_dir': '/c', 132 'cache_dir': '/c',
111 'temp_dir': '/t' 133 'temp_dir': '/t'
112 }, 134 },
113 }) + 135 }) +
114 api.path.exists(api.path['tmp_base'])) 136 api.path.exists(api.path['tmp_base']))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698