Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(270)

Side by Side Diff: recipe_modules/step/config.py

Issue 2933473002: [context] Split "env" values and prefixes. (Closed)
Patch Set: plumb pathsep through so we don't assume OS Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 # Copyright 2013 The LUCI Authors. All rights reserved. 1 # Copyright 2013 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 import collections 5 import collections
6 6
7 from recipe_engine.config import (config_item_context, ConfigGroup, ConfigList, 7 from recipe_engine.config import (config_item_context, ConfigGroup, ConfigList,
8 Dict, Single, Set, List) 8 Dict, Single, Set, List)
9 from recipe_engine.config_types import Path 9 from recipe_engine.config_types import Path
10 from recipe_engine.util import Placeholder 10 from recipe_engine.util import Placeholder
11 11
12 12
13 def BaseConfig(**_kwargs): 13 def BaseConfig(**_kwargs):
14 def render_cmd(lst): 14 def render_cmd(lst):
15 return [(x if isinstance(x, Placeholder) else str(x)) for x in lst] 15 return [(x if isinstance(x, Placeholder) else str(x)) for x in lst]
16 16
17 return ConfigGroup( 17 return ConfigGroup(
18 # For compatibility with buildbot, the step name must be ascii, which is why 18 # For compatibility with buildbot, the step name must be ascii, which is why
19 # this is a 'str' and not a 'basestring'. 19 # this is a 'str' and not a 'basestring'.
20 name = Single(str), 20 name = Single(str),
21 base_name = Single(str, required=False), 21 base_name = Single(str, required=False),
22 cmd = List(inner_type=(int,long,basestring,Path,Placeholder), 22 cmd = List(inner_type=(int,long,basestring,Path,Placeholder),
23 jsonish_fn=render_cmd), 23 jsonish_fn=render_cmd),
24 timeout = Single(int, required=False), 24 timeout = Single(int, required=False),
25 25
26 # optional 26 # optional
27 env_prefixes = Dict(value_type=List((basestring,int,Path,type(None))),
28 item_fn=lambda (k, v): (k, [str(e) for e in (v or ())] or None)),
27 env = Dict(item_fn=lambda (k, v): (k, v if v is None else str(v)), 29 env = Dict(item_fn=lambda (k, v): (k, v if v is None else str(v)),
28 value_type=(basestring,int,Path,type(None))), 30 value_type=(basestring,int,Path,type(None))),
31 pathsep = Single(str, required=True),
29 cwd = Single(Path, jsonish_fn=str, required=True), 32 cwd = Single(Path, jsonish_fn=str, required=True),
30 33
31 stdout = Single(Placeholder, required=False), 34 stdout = Single(Placeholder, required=False),
32 stderr = Single(Placeholder, required=False), 35 stderr = Single(Placeholder, required=False),
33 stdin = Single(Placeholder, required=False), 36 stdin = Single(Placeholder, required=False),
34 37
35 allow_subannotations = Single(bool, required=False), 38 allow_subannotations = Single(bool, required=False),
36 39
37 trigger_specs = ConfigList( 40 trigger_specs = ConfigList(
38 lambda: ConfigGroup( 41 lambda: ConfigGroup(
(...skipping 12 matching lines...) Expand all
51 step_nest_level = Single(int, required=False), 54 step_nest_level = Single(int, required=False),
52 ) 55 )
53 56
54 57
55 config_ctx = config_item_context(BaseConfig) 58 config_ctx = config_item_context(BaseConfig)
56 59
57 @config_ctx() 60 @config_ctx()
58 def test(c): # pragma: no cover 61 def test(c): # pragma: no cover
59 c.name = 'test' 62 c.name = 'test'
60 c.cmd = [Path('[CHECKOUT]', 'build', 'tools', 'cool_script.py')] 63 c.cmd = [Path('[CHECKOUT]', 'build', 'tools', 'cool_script.py')]
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698