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

Side by Side Diff: scripts/slave/recipe_api.py

Issue 24737002: Add Paths as first-class types in configs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/build
Patch Set: Created 7 years, 2 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 | Annotate | Revision Log
OLDNEW
1 # Copyright 2013 The Chromium Authors. All rights reserved. 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 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import functools 5 import functools
6 6
7 from .recipe_test_api import DisabledTestData, ModuleTestData, StepTestData 7 from .recipe_test_api import DisabledTestData, ModuleTestData, StepTestData
8 8
9 from .recipe_util import ModuleInjectionSite 9 from .recipe_util import ModuleInjectionSite
10 10
(...skipping 26 matching lines...) Expand all
37 def get_config_defaults(self): # pylint: disable=R0201 37 def get_config_defaults(self): # pylint: disable=R0201
38 """ 38 """
39 Allows your api to dynamically determine static default values for configs. 39 Allows your api to dynamically determine static default values for configs.
40 """ 40 """
41 return {} 41 return {}
42 42
43 def make_config(self, config_name=None, optional=False, **CONFIG_VARS): 43 def make_config(self, config_name=None, optional=False, **CONFIG_VARS):
44 """Returns a 'config blob' for the current API.""" 44 """Returns a 'config blob' for the current API."""
45 return self.make_config_params(config_name, optional, **CONFIG_VARS)[0] 45 return self.make_config_params(config_name, optional, **CONFIG_VARS)[0]
46 46
47 def make_config_params(self, config_name=None, optional=False, **CONFIG_VARS): 47 def make_config_params(self, config_name, optional=False, **CONFIG_VARS):
agable 2013/09/26 21:46:02 Why did these lose their default value of config_n
iannucci 2013/09/27 02:08:20 Because it's mostly called from make_config and se
48 """Returns a 'config blob' for the current API, and the computed params 48 """Returns a 'config blob' for the current API, and the computed params
49 for all dependent configurations. 49 for all dependent configurations.
50 50
51 The params have the following order of precendence. Each subsequent param 51 The params have the following order of precendence. Each subsequent param
52 is dict.update'd into the final parameters, so the order is from lowest to 52 is dict.update'd into the final parameters, so the order is from lowest to
53 higest precedence on a per-key basis: 53 higest precedence on a per-key basis:
54 * if config_name in CONFIG_CTX 54 * if config_name in CONFIG_CTX
55 * get_config_defaults() 55 * get_config_defaults()
56 * CONFIG_CTX[config_name].DEFAULT_CONFIG_VARS() 56 * CONFIG_CTX[config_name].DEFAULT_CONFIG_VARS()
57 * CONFIG_VARS 57 * CONFIG_VARS
(...skipping 20 matching lines...) Expand all
78 if config_name is None: 78 if config_name is None:
79 return base, params 79 return base, params
80 else: 80 else:
81 return itm(base), params 81 return itm(base), params
82 except KeyError: 82 except KeyError:
83 if optional: 83 if optional:
84 return None, generic_params 84 return None, generic_params
85 else: 85 else:
86 raise # TODO(iannucci): raise a better exception. 86 raise # TODO(iannucci): raise a better exception.
87 87
88 def set_config(self, config_name, optional=False, **CONFIG_VARS): 88 def set_config(self, config_name=None, optional=False, include_deps=True,
89 **CONFIG_VARS):
89 """Sets the modules and its dependencies to the named configuration.""" 90 """Sets the modules and its dependencies to the named configuration."""
90 assert self._module 91 assert self._module
91 config, params = self.make_config_params(config_name, optional, 92 config, params = self.make_config_params(config_name, optional,
92 **CONFIG_VARS) 93 **CONFIG_VARS)
93 if config: 94 if config:
94 self.c = config 95 self.c = config
95 # TODO(iannucci): This is 'inefficient', since if a dep comes up multiple 96
96 # times in this recursion, it will get set_config()'d multiple times 97 if include_deps:
97 for dep in self._module.DEPS: 98 # TODO(iannucci): This is 'inefficient', since if a dep comes up multiple
98 getattr(self.m, dep).set_config(config_name, optional=True, **params) 99 # times in this recursion, it will get set_config()'d multiple times
100 for dep in self._module.DEPS:
101 getattr(self.m, dep).set_config(config_name, optional=True, **params)
99 102
100 def apply_config(self, config_name, config_object=None): 103 def apply_config(self, config_name, config_object=None):
101 """Apply a named configuration to the provided config object or self.""" 104 """Apply a named configuration to the provided config object or self."""
102 self._module.CONFIG_CTX.CONFIG_ITEMS[config_name](config_object or self.c) 105 self._module.CONFIG_CTX.CONFIG_ITEMS[config_name](config_object or self.c)
103 106
104 @property 107 @property
105 def name(self): 108 def name(self):
106 return self._module.NAME 109 return self._module.NAME
107 110
108 111
(...skipping 24 matching lines...) Expand all
133 % { 136 % {
134 'meth': func.__name__, 137 'meth': func.__name__,
135 'mod': self._module, # pylint: disable=W0212 138 'mod': self._module, # pylint: disable=W0212
136 }) 139 })
137 assert 'default_step_data' not in ret 140 assert 'default_step_data' not in ret
138 data = test_fn(*args, **kwargs) 141 data = test_fn(*args, **kwargs)
139 assert isinstance(data, StepTestData) 142 assert isinstance(data, StepTestData)
140 ret['default_step_data'] = data 143 ret['default_step_data'] = data
141 return ret 144 return ret
142 return inner 145 return inner
OLDNEW
« no previous file with comments | « no previous file | scripts/slave/recipe_config_types.py » ('j') | scripts/slave/recipe_config_types.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698