| 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 | 6 |
| 7 class StepApi(recipe_api.RecipeApi): | 7 class StepApi(recipe_api.RecipeApi): |
| 8 def __init__(self, *args, **kwargs): | 8 def __init__(self, *args, **kwargs): |
| 9 self._auto_resolve_conflicts = False | 9 self._auto_resolve_conflicts = False |
| 10 self._name_function = None | 10 self._name_function = None |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 name: The name of this step. | 29 name: The name of this step. |
| 30 cmd: A list of strings in the style of subprocess.Popen. | 30 cmd: A list of strings in the style of subprocess.Popen. |
| 31 **kwargs: Additional entries to add to the annotator.py step dictionary. | 31 **kwargs: Additional entries to add to the annotator.py step dictionary. |
| 32 | 32 |
| 33 Returns: | 33 Returns: |
| 34 A step dictionary which is compatible with annotator.py. | 34 A step dictionary which is compatible with annotator.py. |
| 35 """ | 35 """ |
| 36 assert 'shell' not in kwargs | 36 assert 'shell' not in kwargs |
| 37 assert isinstance(cmd, list) | 37 assert isinstance(cmd, list) |
| 38 | 38 |
| 39 if kwargs.get('abort_on_failure', False): |
| 40 @recipe_api.wrap_followup(kwargs) |
| 41 def assert_success(step_result): |
| 42 if step_result.presentation.status == 'FAILURE': |
| 43 raise recipe_api.RecipeAbort( |
| 44 "Step(%s) failed and was marked as abort_on_failure" % name) |
| 45 kwargs['followup_fn'] = assert_success |
| 46 |
| 39 cmd = list(cmd) # Create a copy in order to not alter the input argument. | 47 cmd = list(cmd) # Create a copy in order to not alter the input argument. |
| 40 if self.auto_resolve_conflicts: | 48 if self.auto_resolve_conflicts: |
| 41 step_count = self._step_names.setdefault(name, 0) + 1 | 49 step_count = self._step_names.setdefault(name, 0) + 1 |
| 42 self._step_names[name] = step_count | 50 self._step_names[name] = step_count |
| 43 if step_count > 1: | 51 if step_count > 1: |
| 44 name = "%s (%d)" % (name, step_count) | 52 name = "%s (%d)" % (name, step_count) |
| 45 ret = kwargs | 53 ret = kwargs |
| 46 ret.update({'name': name, 'cmd': cmd}) | 54 ret.update({'name': name, 'cmd': cmd}) |
| 47 return ret | 55 return ret |
| OLD | NEW |