| 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 import collections | |
| 6 | |
| 7 from recipe_engine.config import (config_item_context, ConfigGroup, ConfigList, | |
| 8 Dict, Single, Set, List) | |
| 9 from recipe_engine.config_types import Path | |
| 10 from recipe_engine.util import Placeholder | |
| 11 | |
| 12 | |
| 13 def BaseConfig(**_kwargs): | |
| 14 def render_cmd(lst): | |
| 15 return [(x if isinstance(x, Placeholder) else str(x)) for x in lst] | |
| 16 | |
| 17 return ConfigGroup( | |
| 18 # For compatibility with buildbot, the step name must be ascii, which is why | |
| 19 # this is a 'str' and not a 'basestring'. | |
| 20 name = Single(str), | |
| 21 base_name = Single(str, required=False), | |
| 22 cmd = List(inner_type=(int,long,basestring,Path,Placeholder), | |
| 23 jsonish_fn=render_cmd), | |
| 24 timeout = Single(int, required=False), | |
| 25 | |
| 26 # optional | |
| 27 env = Dict(item_fn=lambda (k, v): (k, v if v is None else str(v)), | |
| 28 value_type=(basestring,int,Path,type(None))), | |
| 29 cwd = Single(Path, jsonish_fn=str, required=True), | |
| 30 | |
| 31 stdout = Single(Placeholder, required=False), | |
| 32 stderr = Single(Placeholder, required=False), | |
| 33 stdin = Single(Placeholder, required=False), | |
| 34 | |
| 35 allow_subannotations = Single(bool, required=False), | |
| 36 | |
| 37 trigger_specs = ConfigList( | |
| 38 lambda: ConfigGroup( | |
| 39 bucket=Single(basestring), | |
| 40 builder_name=Single(basestring), | |
| 41 properties=Dict(value_type=object), | |
| 42 buildbot_changes=List(dict), | |
| 43 tags=List(basestring), | |
| 44 ), | |
| 45 ), | |
| 46 | |
| 47 step_test_data = Single(collections.Callable, required=False), | |
| 48 | |
| 49 ok_ret = Set(int), | |
| 50 infra_step = Single(bool, required=False), | |
| 51 step_nest_level = Single(int, required=False), | |
| 52 ) | |
| 53 | |
| 54 | |
| 55 config_ctx = config_item_context(BaseConfig) | |
| 56 | |
| 57 @config_ctx() | |
| 58 def test(c): # pragma: no cover | |
| 59 c.name = 'test' | |
| 60 c.cmd = [Path('[CHECKOUT]', 'build', 'tools', 'cool_script.py')] | |
| OLD | NEW |