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

Side by Side Diff: recipe_modules/context/tests/env.py

Issue 2925453002: [context] Add path prefix/suffix manipulation. (Closed)
Patch Set: comments 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 2017 The LUCI Authors. All rights reserved. 1 # Copyright 2017 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 "context", 6 "context",
7 "path", 7 "path",
8 "step", 8 "step",
9 ] 9 ]
10 10
11 11
12 def RunSteps(api): 12 def RunSteps(api):
13 api.step('no env', ['echo', 'hello']) 13 api.step('no env', ['echo', 'hello'])
14 14
15 with api.context(env={"SOMETHING": "1"}): 15 with api.context(env={"SOMETHING": "1"}):
16 api.step('with env', ['echo', 'hello']) 16 api.step('with env', ['echo', 'hello'])
17 17
18 with api.context(env={"SOMETHING_ELSE": "0"}): 18 with api.context(env={"SOMETHING_ELSE": "0"}):
19 api.step('with 2 envs', ['echo', 'hello']) 19 api.step('with 2 envs', ['echo', 'hello'])
20 20
21 with api.context(env={'FOO': 'bar'}):
22 api.step('env step', ['bash', '-c', 'echo $FOO'])
23
24 base_path = 'foo%s%%(FOO)s%sbaz' % (api.path.pathsep, api.path.pathsep)
25 with api.context(env={'FOO': base_path}):
26 api.step('env step augmented', ['bash', '-c', 'echo $FOO'])
27
28 pants = api.path['start_dir'].join('pants')
29 shirt = api.path['start_dir'].join('shirt')
30 with api.context(env={'FOO': api.context.Prefix(pants, shirt)}):
31 api.step('env step with prefix', ['bash', '-c', 'echo $FOO'])
32
33 # Can set the path of default environment variables.
34 with api.context(env={'FOO': api.context.Prefix(shirt)}):
35 api.step('env with default value',
36 ['bash', '-c', 'echo $FOO'])
37
38
21 def GenTests(api): 39 def GenTests(api):
22 yield api.test('basic') 40 yield api.test('basic')
23 41
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698