OLD | NEW |
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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 | 49 |
50 file_path = api.path['tmp_base'].join('new_file') | 50 file_path = api.path['tmp_base'].join('new_file') |
51 abspath = api.path.abspath(file_path) | 51 abspath = api.path.abspath(file_path) |
52 api.path.assert_absolute(abspath) | 52 api.path.assert_absolute(abspath) |
53 | 53 |
54 api.step('touch me', ['touch', api.path.abspath(file_path)]) | 54 api.step('touch me', ['touch', api.path.abspath(file_path)]) |
55 # Assert for testing that a file exists. | 55 # Assert for testing that a file exists. |
56 api.path.mock_add_paths(file_path) | 56 api.path.mock_add_paths(file_path) |
57 assert api.path.exists(file_path) | 57 assert api.path.exists(file_path) |
58 | 58 |
| 59 # Assert that we can mock filesystem paths. |
| 60 root_path = ('C:\\Windows' if api.platform.is_win else '/bin') |
| 61 api.path.mock_add_paths(root_path) |
| 62 assert api.path.exists(root_path) |
| 63 |
59 realpath = api.path.realpath(file_path) | 64 realpath = api.path.realpath(file_path) |
60 assert api.path.exists(realpath) | 65 assert api.path.exists(realpath) |
61 | 66 |
62 home_path = api.path.join(api.path.expanduser('~'), 'file') | 67 home_path = api.path.join(api.path.expanduser('~'), 'file') |
63 api.step('touch my home', ['touch', home_path]) | 68 api.step('touch my home', ['touch', home_path]) |
64 api.path.mock_add_paths(home_path) | 69 api.path.mock_add_paths(home_path) |
65 assert api.path.exists(home_path) | 70 assert api.path.exists(home_path) |
66 | 71 |
67 # can mock copy paths. See the file module to do this for real. | 72 # can mock copy paths. See the file module to do this for real. |
68 copy1 = api.path['start_dir'].join('copy1') | 73 copy1 = api.path['start_dir'].join('copy1') |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 yield (api.test('%s_luci' % platform) + | 149 yield (api.test('%s_luci' % platform) + |
145 api.platform.name(platform) + | 150 api.platform.name(platform) + |
146 api.properties(**{ | 151 api.properties(**{ |
147 '$recipe_engine/path': { | 152 '$recipe_engine/path': { |
148 'cache_dir': '/c', | 153 'cache_dir': '/c', |
149 'temp_dir': '/t', | 154 'temp_dir': '/t', |
150 'cleanup_dir': '/build.dead', | 155 'cleanup_dir': '/build.dead', |
151 }, | 156 }, |
152 }) + | 157 }) + |
153 api.path.exists(api.path['tmp_base'])) | 158 api.path.exists(api.path['tmp_base'])) |
OLD | NEW |