| 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 from recipe_engine import recipe_api, config | 5 from recipe_engine import recipe_api, config |
| 6 | 6 |
| 7 DEPS = [ | 7 DEPS = [ |
| 8 'context', | 8 'context', |
| 9 'path', | 9 'path', |
| 10 'raw_io', | 10 'raw_io', |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 | 59 |
| 60 # can increment nest level... note that this is a low level api, prefer | 60 # can increment nest level... note that this is a low level api, prefer |
| 61 # api.step.nest instead: | 61 # api.step.nest instead: |
| 62 # YES: | 62 # YES: |
| 63 with api.step.nest('nested'): | 63 with api.step.nest('nested'): |
| 64 api.step('properly indented', ['bash', '-c', 'echo yay!']) | 64 api.step('properly indented', ['bash', '-c', 'echo yay!']) |
| 65 # AVOID: | 65 # AVOID: |
| 66 with api.context(increment_nest_level=True): | 66 with api.context(increment_nest_level=True): |
| 67 api.step('indented with wrong name', ['bash', '-c', 'echo indent?']) | 67 api.step('indented with wrong name', ['bash', '-c', 'echo indent?']) |
| 68 | 68 |
| 69 # Can read initial LUCI_CONTEXT value. |
| 70 val = api.context.luci_context['INITIAL']['k'] |
| 71 api.step('value in the context', ['echo', val]) |
| 72 |
| 73 # Can modify it. |
| 74 with api.context(luci_context={'INITIAL': None, 'OTHER': {'k': 'zzz'}}): |
| 75 val = api.context.luci_context['OTHER']['k'] |
| 76 api.step('value in the context', ['echo', val]) |
| 77 |
| 69 | 78 |
| 70 def GenTests(api): | 79 def GenTests(api): |
| 71 yield api.test('basic') | 80 yield api.test('basic') + api.context.luci_context({'INITIAL': {'k': 'val'}}) |
| OLD | NEW |