OLD | NEW |
1 # Copyright 2016 The LUCI Authors. All rights reserved. | 1 # Copyright 2016 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 from __future__ import absolute_import | 5 from __future__ import absolute_import |
6 import contextlib | 6 import contextlib |
7 import collections | 7 import collections |
8 import keyword | 8 import keyword |
9 import re | 9 import re |
10 import types | 10 import types |
11 | 11 |
12 from functools import wraps | 12 from functools import wraps |
13 | 13 |
14 from .recipe_test_api import DisabledTestData, ModuleTestData | 14 from .recipe_test_api import DisabledTestData, ModuleTestData |
15 from .config import Single | 15 from .config import Single |
16 | 16 |
17 from .util import ModuleInjectionSite | 17 from .util import ModuleInjectionSite |
18 | 18 |
19 from . import field_composer | 19 from . import field_composer |
20 | 20 |
21 | 21 |
22 _StepConfig = collections.namedtuple('StepConfig', | 22 _StepConfig = collections.namedtuple('StepConfig', |
23 ('name', 'cmd', 'cwd', 'env', 'allow_subannotations', 'trigger_specs', | 23 ('name', 'base_name', 'cmd', 'cwd', 'env', 'allow_subannotations', |
24 'timeout', 'infra_step', 'stdout', 'stderr', 'stdin', 'ok_ret', | 24 'trigger_specs', 'timeout', 'infra_step', 'stdout', 'stderr', 'stdin', |
25 'step_test_data', 'nest_level')) | 25 'ok_ret', 'step_test_data', 'nest_level')) |
26 | 26 |
27 class StepConfig(_StepConfig): | 27 class StepConfig(_StepConfig): |
28 """ | 28 """ |
29 StepConfig parameters: | 29 StepConfig parameters: |
30 name: name of the step, will appear in buildbots waterfall | 30 name: name of the step, will appear in buildbots waterfall |
| 31 base_name: the base step name, not including any parent/nesting composition. |
31 cmd: command to run, list of one or more strings | 32 cmd: command to run, list of one or more strings |
32 cwd: absolute path to working directory for the command | 33 cwd: absolute path to working directory for the command |
33 env: dict with overrides for environment variables | 34 env: dict with overrides for environment variables |
34 allow_subannotations: if True, lets the step emit its own annotations | 35 allow_subannotations: if True, lets the step emit its own annotations |
35 trigger_specs: a list of trigger specifications, see also _trigger_builds. | 36 trigger_specs: a list of trigger specifications, see also _trigger_builds. |
36 timeout: if not None, a datetime.timedelta for the step timeout. | 37 timeout: if not None, a datetime.timedelta for the step timeout. |
37 infra_step: if True, this is an infrastructure step. | 38 infra_step: if True, this is an infrastructure step. |
38 stdout: Path to a file to put step stdout into. If used, stdout won't | 39 stdout: Path to a file to put step stdout into. If used, stdout won't |
39 appear in annotator's stdout (and |allow_subannotations| is | 40 appear in annotator's stdout (and |allow_subannotations| is |
40 ignored). | 41 ignored). |
41 stderr: Path to a file to put step stderr into. If used, stderr won't | 42 stderr: Path to a file to put step stderr into. If used, stderr won't |
42 appear in annotator's stderr. | 43 appear in annotator's stderr. |
43 stdin: Path to a file to read step stdin from. | 44 stdin: Path to a file to read step stdin from. |
44 ok_ret: Allowed return code list. | 45 ok_ret: Allowed return code list. |
45 step_test_data: Possible associated step test data. | 46 step_test_data: Possible associated step test data. |
46 nest_level: the step's nesting level. | 47 nest_level: the step's nesting level. |
47 """ | 48 """ |
48 | 49 |
49 | 50 |
50 def _make_step_config(**step): | 51 def _make_step_config(**step): |
51 """Galvanize a step dictionary into a formal StepConfig.""" | 52 """Galvanize a step dictionary into a formal StepConfig.""" |
| 53 name = step.pop('name') |
52 step_config = StepConfig( | 54 step_config = StepConfig( |
53 name=step.pop('name'), | 55 name=name, |
| 56 base_name=step.pop('base_name', name), |
54 cmd=step.pop('cmd', None), | 57 cmd=step.pop('cmd', None), |
55 cwd=step.pop('cwd', None), | 58 cwd=step.pop('cwd', None), |
56 env=step.pop('env', None), | 59 env=step.pop('env', None), |
57 allow_subannotations=step.pop('allow_subannotations', False), | 60 allow_subannotations=step.pop('allow_subannotations', False), |
58 trigger_specs=step.pop('trigger_specs', ()), | 61 trigger_specs=step.pop('trigger_specs', ()), |
59 timeout=step.pop('timeout', None), | 62 timeout=step.pop('timeout', None), |
60 infra_step=step.pop('infra_step', False), | 63 infra_step=step.pop('infra_step', False), |
61 stdout=step.pop('stdout', None), | 64 stdout=step.pop('stdout', None), |
62 stderr=step.pop('stderr', None), | 65 stderr=step.pop('stderr', None), |
63 stdin=step.pop('stdin', None), | 66 stdin=step.pop('stdin', None), |
(...skipping 654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
718 """ | 721 """ |
719 Gets the BoundProperty version of this Property. Requires a name. | 722 Gets the BoundProperty version of this Property. Requires a name. |
720 """ | 723 """ |
721 return BoundProperty( | 724 return BoundProperty( |
722 self._default, self.help, self.kind, name, property_type, module, | 725 self._default, self.help, self.kind, name, property_type, module, |
723 self.param_name) | 726 self.param_name) |
724 | 727 |
725 class UndefinedPropertyException(TypeError): | 728 class UndefinedPropertyException(TypeError): |
726 pass | 729 pass |
727 | 730 |
OLD | NEW |