Chromium Code Reviews| Index: recipe_engine/step_runner.py |
| diff --git a/recipe_engine/step_runner.py b/recipe_engine/step_runner.py |
| index 2cd05d3576c4bacd0c501c2156d871dbcdeecd83..f9a9e71ebf1fb7ecf415fbcd7dacd8ee472b087a 100644 |
| --- a/recipe_engine/step_runner.py |
| +++ b/recipe_engine/step_runner.py |
| @@ -448,14 +448,20 @@ def render_step(step, step_test): |
| rendered_step = dict(step) |
| # Process 'cmd', rendering placeholders there. |
| - placeholders = collections.defaultdict(lambda: collections.defaultdict(list)) |
| + placeholders = collections.defaultdict( |
| + lambda: collections.defaultdict(collections.OrderedDict)) |
| new_cmd = [] |
| for item in step.get('cmd', []): |
| if isinstance(item, util.Placeholder): |
| module_name, placeholder_name = item.name_pieces |
| - tdata = step_test.pop_placeholder(item.name_pieces) |
| + tdata = step_test.pop_placeholder(module_name, placeholder_name, item.id) |
| new_cmd.extend(item.render(tdata)) |
| - placeholders[module_name][placeholder_name].append((item, tdata)) |
| + # TODO(http://crbug.com/593198): enable this assert when all recipes and |
| + # recipe modules are updated. |
| + #assert item.id not in placeholders[module_name][placeholder_name], ( |
| + # 'You have multiple place holders of %s.%s, please specify different ' |
| + # 'ids for them.' % (module_name, placeholder_name)) |
| + placeholders[module_name][placeholder_name][item.id] = (item, tdata) |
| else: |
| new_cmd.append(item) |
| rendered_step['cmd'] = new_cmd |
| @@ -495,8 +501,14 @@ def construct_step_result(step, retcode, placeholders): |
| setattr(step_result, module_name, o) |
| for placeholder_name, items in pholders.iteritems(): |
| - lst = [ph.result(step_result.presentation, td) for ph, td in items] |
| - setattr(o, placeholder_name+"_all", lst) |
| + named_results = {} |
| + lst = [] |
| + for _, (ph, td) in items.iteritems(): |
| + result = ph.result(step_result.presentation, td) |
| + lst.append(result) |
| + named_results[ph.id] = result |
| + setattr(o, placeholder_name + "s", named_results) |
| + setattr(o, placeholder_name + "_all", lst) |
|
iannucci
2016/03/10 03:17:42
so, actually, because of the way the recipe pinnin
stgao
2016/03/10 20:34:23
Sounds good. Let's go with this approach then.
|
| setattr(o, placeholder_name, lst[0]) |
| # Placeholders that are used with IO redirection. |