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 """Tests that step_data can accept multiple specs at once.""" | 5 """Tests that placeholders can't wreck the world by exhausting the step stack.""
" |
6 | 6 |
7 from recipe_engine.util import InputPlaceholder | 7 from recipe_engine.util import InputPlaceholder |
8 from recipe_engine.recipe_api import StepFailure | 8 from recipe_engine.recipe_api import StepFailure |
9 | 9 |
10 DEPS = [ | 10 DEPS = [ |
11 'step', | 11 'step', |
12 ] | 12 ] |
13 | 13 |
14 class BadPlaceholder(InputPlaceholder): | 14 class BadPlaceholder(InputPlaceholder): |
15 def render(self, test): | 15 def render(self, test): |
16 raise StepFailure("EXPLOSION") | 16 raise StepFailure("EXPLOSION") |
17 | 17 |
18 | 18 |
19 def RunSteps(api): | 19 def RunSteps(api): |
20 try: | 20 try: |
21 api.step('innocent step', ['echo', 'some', 'step']) | 21 api.step('innocent step', ['bash', '-c', "echo some step"]) |
22 | 22 |
23 ph = BadPlaceholder('name') | 23 ph = BadPlaceholder('name') |
24 ph.namespaces = ('fake', 'namespace') | 24 ph.namespaces = ('fake', 'namespace') |
25 | 25 |
26 api.step('bad step', ['echo', ph]) | 26 api.step('bad step', ['echo', ph]) |
27 finally: | 27 finally: |
28 api.step.active_result # this will raise a ValueError | 28 api.step.active_result # this will raise a ValueError |
29 | 29 |
30 def GenTests(api): | 30 def GenTests(api): |
31 yield ( | 31 yield ( |
32 api.test('basic') + | 32 api.test('basic') + |
33 api.expect_exception('ValueError') | 33 api.expect_exception('ValueError') |
34 ) | 34 ) |
35 | 35 |
OLD | NEW |