OLD | NEW |
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 from slave import recipe_api | 5 from slave import recipe_api |
6 from slave import recipe_util | 6 from slave import recipe_util |
7 | 7 |
8 # Inherit from RecipeApiPlain because the only thing which is a step is | 8 # Inherit from RecipeApiPlain because the only thing which is a step is |
9 # run_from_dict() | 9 # run_from_dict() |
10 class StepApi(recipe_api.RecipeApiPlain): | 10 class StepApi(recipe_api.RecipeApiPlain): |
| 11 def __init__(self, **kwargs): |
| 12 super(StepApi, self).__init__(**kwargs) |
| 13 self._step_names = {} |
| 14 |
11 EXCEPTION = 'EXCEPTION' | 15 EXCEPTION = 'EXCEPTION' |
12 FAILURE = 'FAILURE' | 16 FAILURE = 'FAILURE' |
13 SUCCESS = 'SUCCESS' | 17 SUCCESS = 'SUCCESS' |
14 WARNING = 'WARNING' | 18 WARNING = 'WARNING' |
15 | 19 |
16 @property | 20 @property |
17 def StepFailure(self): | 21 def StepFailure(self): |
18 """ See recipe_api.py for docs. """ | 22 """ See recipe_api.py for docs. """ |
19 return recipe_api.StepFailure | 23 return recipe_api.StepFailure |
20 | 24 |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 assert 'shell' not in kwargs | 88 assert 'shell' not in kwargs |
85 assert isinstance(cmd, list) | 89 assert isinstance(cmd, list) |
86 if not ok_ret: | 90 if not ok_ret: |
87 ok_ret = {0} | 91 ok_ret = {0} |
88 if ok_ret in ('any', 'all'): | 92 if ok_ret in ('any', 'all'): |
89 ok_ret = set(range(-256, 256)) | 93 ok_ret = set(range(-256, 256)) |
90 | 94 |
91 command = list(wrapper) | 95 command = list(wrapper) |
92 command += cmd | 96 command += cmd |
93 | 97 |
| 98 step_count = self._step_names.setdefault(name, 0) + 1 |
| 99 self._step_names[name] = step_count |
| 100 if step_count > 1: |
| 101 name = "%s (%d)" % (name, step_count) |
| 102 |
94 kwargs.update({'name': name, 'cmd': command}) | 103 kwargs.update({'name': name, 'cmd': command}) |
95 kwargs['ok_ret'] = ok_ret | 104 kwargs['ok_ret'] = ok_ret |
96 kwargs['infra_step'] = bool(infra_step) | 105 kwargs['infra_step'] = bool(infra_step) |
97 | 106 |
98 schema = self.make_config() | 107 schema = self.make_config() |
99 schema.set_val(kwargs) | 108 schema.set_val(kwargs) |
100 return self.run_from_dict(self._engine.create_step(schema)) | 109 return self.run_from_dict(self._engine.create_step(schema)) |
101 | 110 |
102 # TODO(martiniss) delete, and make generator_script use **kwargs on step() | 111 # TODO(martiniss) delete, and make generator_script use **kwargs on step() |
103 @recipe_api.composite_step | 112 @recipe_api.composite_step |
104 def run_from_dict(self, dct): | 113 def run_from_dict(self, dct): |
105 return self._engine.run_step(dct) | 114 return self._engine.run_step(dct) |
OLD | NEW |