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 """Tests that step_data can accept multiple specs at once.""" | 5 """Tests that step_data can accept multiple specs at once.""" |
6 | 6 |
| 7 from recipe_engine.recipe_api import Property |
| 8 from recipe_engine.post_process import Filter, DoesNotRun, MustRun |
| 9 |
7 DEPS = [ | 10 DEPS = [ |
8 'step', | 11 'step', |
| 12 'properties', |
9 ] | 13 ] |
10 | 14 |
11 def RunSteps(api): | 15 PROPERTIES = { |
| 16 'fakeit': Property(kind=bool, default=True), |
| 17 } |
| 18 |
| 19 def RunSteps(api, fakeit): |
12 api.step('something unimportant', ['echo', 'sup doc']) | 20 api.step('something unimportant', ['echo', 'sup doc']) |
13 api.step('something important', ['echo', 'crazy!'], env={'FLEEM': 'VERY YES'}) | 21 api.step('something important', ['echo', 'crazy!'], env={'FLEEM': 'VERY YES'}) |
14 api.step('another important', ['echo', 'INSANITY']) | 22 api.step('another important', ['echo', 'INSANITY']) |
| 23 if fakeit: |
| 24 api.step('fakestep', ['echo', 'FAAAAKE']) |
| 25 |
15 | 26 |
16 def GenTests(api): | 27 def GenTests(api): |
17 yield api.test('all_steps') | 28 yield api.test('all_steps') + api.post_process(MustRun, 'fakestep') |
18 | 29 |
19 yield (api.test('single_step') | 30 yield (api.test('single_step') |
20 + api.whitelist('something important') | 31 + api.post_process(Filter('something important')) |
21 ) | 32 ) |
22 | 33 |
23 yield (api.test('two_steps') | 34 yield (api.test('two_steps') |
24 + api.whitelist('something important') | 35 + api.post_process(Filter('something important', 'another important')) |
25 + api.whitelist('another important') | |
26 ) | 36 ) |
27 | 37 |
| 38 f = Filter() |
| 39 f = f.include('another important', ['cmd']) |
| 40 f = f.include('something important', ['env']) |
28 yield (api.test('selection') | 41 yield (api.test('selection') |
29 + api.whitelist('something important', 'env') | 42 + api.properties(fakeit=False) |
30 + api.whitelist('another important', 'cmd') | 43 + api.post_process(DoesNotRun, 'fakestep') |
| 44 + api.post_process(f) |
31 ) | 45 ) |
32 | 46 |
33 yield (api.test('result') | 47 yield api.test('result') + api.post_process(Filter('$result')) |
34 + api.whitelist('$result') | |
35 ) | |
OLD | NEW |