OLD | NEW |
1 # Copyright 2015 The LUCI Authors. All rights reserved. | 1 # Copyright 2015 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 | 5 |
6 DEPS = [ | 6 DEPS = [ |
7 'step', | 7 'step', |
8 ] | 8 ] |
9 | 9 |
10 | 10 |
11 def RunSteps(api): | 11 def RunSteps(api): |
12 # Nest all steps below this. | 12 # Nest all steps below this. |
13 with api.step.nest('complicated thing'): | 13 with api.step.nest('complicated thing'): |
14 with api.step.nest('first part'): | 14 with api.step.nest('first part'): |
15 api.step('wait a bit', ['sleep', '10']) | 15 api.step('wait a bit', ['sleep', '1']) |
16 | 16 |
17 # Prefix the name without indenting. | 17 # Prefix the name without indenting. |
18 with api.step.context({'name': 'attempt number'}): | 18 with api.step.context({'name': 'attempt number'}): |
19 step_result = api.step('one', ['echo', 'herpy']) | 19 step_result = api.step('one', ['echo', 'herpy']) |
20 assert step_result.step['name'] == 'complicated thing.attempt number.one' | 20 assert step_result.step['name'] == 'complicated thing.attempt number.one' |
21 api.step('two', ['echo', 'derpy']) | 21 api.step('two', ['echo', 'derpy']) |
22 | 22 |
23 api.step('simple thing', ['sleep', '10']) | 23 # Outer nested step's status should not inherit from inner. |
| 24 with api.step.nest('inherit status') as nest_step: |
| 25 with api.step.nest('inner step') as other_nest_step: |
| 26 other_nest_step.presentation.status = api.step.EXCEPTION |
| 27 assert nest_step.presentation.status == api.step.SUCCESS |
| 28 |
| 29 # Change outer status after nesting is complete. |
| 30 with api.step.nest('versatile status') as nest_step: |
| 31 with api.step.nest('inner step'): |
| 32 with api.step.nest('even deeper'): |
| 33 pass |
| 34 nest_step.presentation.status = api.step.FAILURE |
| 35 assert nest_step.presentation.status == api.step.FAILURE |
| 36 |
| 37 api.step('simple thing', ['sleep', '1']) |
24 | 38 |
25 | 39 |
26 def GenTests(api): | 40 def GenTests(api): |
27 yield api.test('basic') | 41 yield api.test('basic') |
OLD | NEW |