| 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(env={ |
| 31 'FOO': api.context.Prefix(pants, shirt, pants, shirt)}): |
| 32 with api.context(env={ |
| 33 'FOO': api.context.Suffix(pants, shirt, pants, shirt)}): |
| 34 api.step('env step with prefix and suffix', |
| 35 ['bash', '-c', 'echo $FOO']) |
| 36 |
| 37 # Can set the path of default environment variables. |
| 38 with api.context(env={'FOO': api.context.Prefix(shirt)}): |
| 39 api.step('env with default value', |
| 40 ['bash', '-c', 'echo $FOO']) |
| 41 |
| 42 |
| 21 def GenTests(api): | 43 def GenTests(api): |
| 22 yield api.test('basic') | 44 yield api.test('basic') |
| 23 | 45 |
| OLD | NEW |