| OLD | NEW |
| 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.path_prefix('FOO', pants, shirt, pants, shirt): |
| 31 with api.context.path_suffix('FOO', pants, shirt, pants, shirt): |
| 32 api.step('env step with prefix and suffix', |
| 33 ['bash', '-c', 'echo $FOO']) |
| 34 |
| 35 with api.context.path_remove('FOO', shirt): |
| 36 api.step('env with path removal', |
| 37 ['bash', '-c', 'echo $FOO']) |
| 38 |
| 39 with api.context.path_remove('FOO', pants): |
| 40 api.step('env with full path removal', |
| 41 ['bash', '-c', 'echo $FOO']) |
| 42 |
| 43 with api.context(path_prefix={}): |
| 44 api.step('env with empty prefix', |
| 45 ['bash', '-c', 'echo $FOO']) |
| 46 |
| 47 # Can set the path of default environment variables. |
| 48 with api.context.path_prefix('FOO', shirt): |
| 49 api.step('env with default value', |
| 50 ['bash', '-c', 'echo $FOO']) |
| 51 |
| 52 |
| 21 def GenTests(api): | 53 def GenTests(api): |
| 22 yield api.test('basic') | 54 yield api.test('basic') |
| 23 | 55 |
| OLD | NEW |