| OLD | NEW |
| (Empty) |
| 1 # Copyright 2013 The LUCI Authors. All rights reserved. | |
| 2 # Use of this source code is governed under the Apache License, Version 2.0 | |
| 3 # that can be found in the LICENSE file. | |
| 4 | |
| 5 from recipe_engine.recipe_api import Property | |
| 6 | |
| 7 DEPS = [ | |
| 8 'generator_script', | |
| 9 'json', | |
| 10 'path', | |
| 11 'properties', | |
| 12 'step', | |
| 13 ] | |
| 14 | |
| 15 PROPERTIES = { | |
| 16 'script_name': Property(kind=str), | |
| 17 'script_env': Property(default=None, kind=dict), | |
| 18 } | |
| 19 | |
| 20 def RunSteps(api, script_name, script_env): | |
| 21 api.path['checkout'] = api.path['tmp_base'] | |
| 22 script_name = api.properties['script_name'] | |
| 23 script_env = api.properties.get('script_env') | |
| 24 api.generator_script(script_name, env=script_env) | |
| 25 | |
| 26 def GenTests(api): | |
| 27 yield ( | |
| 28 api.test('basic') + | |
| 29 api.properties(script_name="bogus") + | |
| 30 api.generator_script( | |
| 31 'bogus', | |
| 32 {'name': 'mock.step.binary', 'cmd': ['echo', 'mock step binary']} | |
| 33 ) | |
| 34 ) | |
| 35 | |
| 36 yield ( | |
| 37 api.test('basic_python') + | |
| 38 api.properties(script_name="bogus.py", script_env={'FOO': 'bar'}) + | |
| 39 api.generator_script( | |
| 40 'bogus.py', | |
| 41 {'name': 'mock.step.python', 'cmd': ['echo', 'mock step python']}, | |
| 42 ) | |
| 43 ) | |
| 44 | |
| 45 yield ( | |
| 46 api.test('presentation') + | |
| 47 api.properties(script_name='presentation.py') + | |
| 48 api.generator_script( | |
| 49 'presentation.py', { | |
| 50 'name': 'mock.step.presentation', | |
| 51 'cmd': ['echo', 'mock step presentation'], | |
| 52 'outputs_presentation_json': True | |
| 53 } | |
| 54 ) + | |
| 55 api.step_data( | |
| 56 'mock.step.presentation', | |
| 57 api.json.output({'step_text': 'mock step text'}) | |
| 58 ) | |
| 59 ) | |
| 60 | |
| 61 yield ( | |
| 62 api.test('always_run') + | |
| 63 api.properties(script_name='always_run.py') + | |
| 64 api.generator_script( | |
| 65 'always_run.py', | |
| 66 {'name': 'runs', 'cmd': ['echo', 'runs succeeds']}, | |
| 67 {'name': 'fails', 'cmd': ['echo', 'fails fails!']}, | |
| 68 {'name': 'skipped', 'cmd': ['echo', 'absent']}, | |
| 69 {'name': 'always_runs', 'cmd': ['echo', 'runs anyway'], | |
| 70 'always_run': True}, | |
| 71 ) + | |
| 72 api.step_data('fails', retcode=1) | |
| 73 ) | |
| 74 | |
| 75 yield ( | |
| 76 api.test('nested') + | |
| 77 api.properties(script_name='nested.py') + | |
| 78 api.generator_script( | |
| 79 'nested.py', | |
| 80 {'name': 'grandparent', 'cmd': ['echo', 'grandparent']}, | |
| 81 {'name': 'parent', 'step_nest_level': 1, 'cmd': ['echo', 'parent']}, | |
| 82 {'name': 'child', 'step_nest_level': 2, 'cmd': ['echo', 'child']}, | |
| 83 {'name': 'sibling', 'step_nest_level': 2, 'cmd': ['echo', 'sibling']}, | |
| 84 {'name': 'uncle', 'step_nest_level': 1, 'cmd': ['echo', 'uncle']}, | |
| 85 {'name': 'cousin', 'step_nest_level': 2, 'cmd': ['echo', 'cousin']}, | |
| 86 ) | |
| 87 ) | |
| 88 | |
| 89 yield ( | |
| 90 api.test('malformed_command') + | |
| 91 api.properties(script_name='malformed.py') + | |
| 92 api.generator_script( | |
| 93 'malformed.py', | |
| 94 {'name': 'run', 'cmd': ['echo', 'there are', 4, 'cows']}) + | |
| 95 api.expect_exception('AssertionError') | |
| 96 ) | |
| OLD | NEW |