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