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

Side by Side Diff: recipe_modules/path/example.py

Issue 1906323003: recipe engine: extract infra-specific paths out of the engine (Closed) Base URL: https://github.com/luci/recipes-py.git@master
Patch Set: tmp Created 4 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 unified diff | Download patch
« no previous file with comments | « recipe_modules/path/config.py ('k') | recipe_modules/path/example.expected/linux.json » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # 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 ]
11 11
12 from recipe_engine.config_types import Path 12 from recipe_engine.config_types import Path
13 13
14 def RunSteps(api): 14 def RunSteps(api):
15 api.step('step1', ['/bin/echo', str(api.path['slave_build'].join('foo'))]) 15 api.step('step1', ['/bin/echo', str(api.path['tmp'].join('foo'))])
16 16
17 # module.resource(...) demo. 17 # module.resource(...) demo.
18 api.step('print resource', 18 api.step('print resource',
19 ['echo', api.path.resource('dir', 'file.py')]) 19 ['echo', api.path.resource('dir', 'file.py')])
20 20
21 # module.package_repo_resource() demo. 21 # module.package_repo_resource() demo.
22 api.step('print package dir', 22 api.step('print package dir',
23 ['echo', api.path.package_repo_resource('dir', 'file.py')]) 23 ['echo', api.path.package_repo_resource('dir', 'file.py')])
24 24
25 # Global dynamic paths (see config.py example for declaration): 25 # Global dynamic paths (see config.py example for declaration):
26 dynamic_path = Path('[CHECKOUT]', 'jerky') 26 dynamic_path = Path('[CHECKOUT]', 'jerky')
27 27
28 assert 'checkout' not in api.path 28 assert 'checkout' not in api.path
29 api.path['checkout'] = api.path['slave_build'].join('checkout') 29 api.path['checkout'] = api.path['tmp'].join('checkout')
30 assert 'checkout' in api.path 30 assert 'checkout' in api.path
31 31
32 api.step('checkout path', ['/bin/echo', dynamic_path]) 32 api.step('checkout path', ['/bin/echo', dynamic_path])
33 33
34 # Methods from python os.path are available via api.path. 34 # Methods from python os.path are available via api.path.
35 # For testing, we asserted that this file existed in the test description 35 # For testing, we asserted that this file existed in the test description
36 # below. 36 # below.
37 assert api.path.exists(api.path['slave_build']) 37 assert api.path.exists(api.path['tmp'])
38 38
39 temp_dir = api.path.mkdtemp('kawaab') 39 temp_dir = api.path.mkdtemp('kawaab')
40 assert api.path.exists(temp_dir) 40 assert api.path.exists(temp_dir)
41 41
42 file_path = api.path['slave_build'].join('new_file') 42 file_path = api.path['tmp'].join('new_file')
43 abspath = api.path.abspath(file_path) 43 abspath = api.path.abspath(file_path)
44 api.path.assert_absolute(abspath) 44 api.path.assert_absolute(abspath)
45 45
46 api.step('touch me', ['touch', api.path.abspath(file_path)]) 46 api.step('touch me', ['touch', api.path.abspath(file_path)])
47 # Assert for testing that a file exists. 47 # Assert for testing that a file exists.
48 api.path.mock_add_paths(file_path) 48 api.path.mock_add_paths(file_path)
49 assert api.path.exists(file_path) 49 assert api.path.exists(file_path)
50 50
51 51
52 def GenTests(api): 52 def GenTests(api):
53 for platform in ('linux', 'win', 'mac'): 53 for platform in ('linux', 'win', 'mac'):
54 yield (api.test(platform) + api.platform.name(platform) + 54 yield (api.test(platform) + api.platform.name(platform) +
55 # Test when a file already exists 55 # Test when a file already exists
56 api.path.exists(api.path['slave_build'])) 56 api.path.exists(api.path['tmp']))
57
58 # We have support for chromium swarming built in to the engine for some
59 # reason. TODO(phajdan.jr) remove it.
60 yield (api.test('%s_swarming' % platform) +
61 api.platform.name(platform) +
62 api.properties(path_config='swarming') +
63 api.path.exists(api.path['slave_build']))
64
65 yield (api.test('%s_kitchen' % platform) +
66 api.platform.name(platform) +
67 api.properties(path_config='kitchen') +
68 api.path.exists(api.path['slave_build']))
OLDNEW
« no previous file with comments | « recipe_modules/path/config.py ('k') | recipe_modules/path/example.expected/linux.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698