Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 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 """ Skia-specific subclass of BuildStep """ | 5 """ Skia-specific subclass of BuildStep """ |
| 6 | 6 |
| 7 | 7 |
| 8 from buildbot.status.logfile import STDOUT | 8 from buildbot.status.logfile import STDOUT |
| 9 from master.log_parser import retcode_command | 9 from master.log_parser import retcode_command |
| 10 import re | 10 import re |
| 11 | 11 |
| 12 | 12 |
| 13 class SkiaBuildStep(retcode_command.ReturnCodeCommand): | 13 class SkiaBuildStep(retcode_command.ReturnCodeCommand): |
| 14 """ BuildStep wrapper for Skia. Allows us to define properties of BuildSteps | 14 """ BuildStep wrapper for Skia. Allows us to define properties of BuildSteps |
| 15 to be used by ShouldDoStep. This is necessary because the properties referred | 15 to be used by ShouldDoStep. This is necessary because the properties referred |
| 16 to by BuildStep.getProperty() are scoped for the entire duration of the build. | 16 to by BuildStep.getProperty() are scoped for the entire duration of the build. |
| 17 """ | 17 """ |
| 18 def __init__(self, is_upload_step=False, is_rebaseline_step=False, | 18 def __init__(self, is_upload_step=False, is_rebaseline_step=False, |
| 19 get_props_from_stdout=None, **kwargs): | 19 get_props_from_stdout=None, exception_on_failure=False, |
| 20 **kwargs): | |
| 20 """ Instantiates a new SkiaBuildStep. | 21 """ Instantiates a new SkiaBuildStep. |
| 21 | 22 |
| 22 is_upload_step: boolean indicating whether this step should be skipped when | 23 is_upload_step: boolean indicating whether this step should be skipped when |
| 23 the buildbot is not performing uploads. | 24 the buildbot is not performing uploads. |
| 24 is_rebaseline_step: boolean indicating whether this step is required for | 25 is_rebaseline_step: boolean indicating whether this step is required for |
| 25 rebaseline-only builds. | 26 rebaseline-only builds. |
| 26 get_props_from_stdout: optional dictionary. Keys are strings indicating | 27 get_props_from_stdout: optional dictionary. Keys are strings indicating |
| 27 build properties to set based on the output of this step. Values are | 28 build properties to set based on the output of this step. Values are |
| 28 strings containing regular expressions for parsing the property from | 29 strings containing regular expressions for parsing the property from |
| 29 the output of the step. | 30 the output of the step. |
| 31 exception_on_failure: boolean indicating whether to raise an exception if | |
| 32 this step fails. | |
|
rmistry
2014/02/24 14:47:54
Can we add here something like:
If there is a fail
borenet
2014/02/24 15:05:46
Done. Note that this does cause the build as a who
| |
| 30 """ | 33 """ |
| 31 self._is_upload_step = is_upload_step | 34 self._is_upload_step = is_upload_step |
| 32 self._is_rebaseline_step = is_rebaseline_step | 35 self._is_rebaseline_step = is_rebaseline_step |
| 33 self._get_props_from_stdout = get_props_from_stdout | 36 self._get_props_from_stdout = get_props_from_stdout |
| 37 self._exception_on_failure = exception_on_failure | |
| 34 | 38 |
| 35 # self._changed_props will be a dictionary containing the build properties | 39 # self._changed_props will be a dictionary containing the build properties |
| 36 # which were updated by this BuildStep. Those properties will be displayed | 40 # which were updated by this BuildStep. Those properties will be displayed |
| 37 # in the label for this step. | 41 # in the label for this step. |
| 38 self._changed_props = None | 42 self._changed_props = None |
| 39 | 43 |
| 40 retcode_command.ReturnCodeCommand.__init__(self, **kwargs) | 44 retcode_command.ReturnCodeCommand.__init__(self, **kwargs) |
| 41 self.name = ''.join(self.description) | 45 self.name = ''.join(self.description) |
| 42 | 46 |
| 43 def IsUploadStep(self): | 47 def IsUploadStep(self): |
| 44 return self._is_upload_step | 48 return self._is_upload_step |
| 45 | 49 |
| 46 def IsRebaselineStep(self): | 50 def IsRebaselineStep(self): |
| 47 return self._is_rebaseline_step | 51 return self._is_rebaseline_step |
| 48 | 52 |
| 49 def commandComplete(self, cmd): | 53 def commandComplete(self, cmd): |
| 50 """ Override of BuildStep's commandComplete method which allows us to parse | 54 """ Override of BuildStep's commandComplete method which allows us to parse |
| 51 build properties from the output of this step. """ | 55 build properties from the output of this step. """ |
| 56 if cmd.rc and self._exception_on_failure: | |
| 57 raise Exception('Command marked exception_on_failure failed.') | |
| 52 if self._get_props_from_stdout and cmd.rc == 0: | 58 if self._get_props_from_stdout and cmd.rc == 0: |
| 53 log = cmd.logs['stdio'] | 59 log = cmd.logs['stdio'] |
| 54 stdout = ''.join(log.getChunks([STDOUT], onlyText=True)) | 60 stdout = ''.join(log.getChunks([STDOUT], onlyText=True)) |
| 55 self._changed_props = {} | 61 self._changed_props = {} |
| 56 for prop, regex in self._get_props_from_stdout.iteritems(): | 62 for prop, regex in self._get_props_from_stdout.iteritems(): |
| 57 matches = re.search(regex, stdout) | 63 matches = re.search(regex, stdout) |
| 58 if not matches: | 64 if not matches: |
| 59 raise Exception('Unable to parse %s from stdout.' % prop) | 65 raise Exception('Unable to parse %s from stdout.' % prop) |
| 60 groups = matches.groups() | 66 groups = matches.groups() |
| 61 if len(groups) != 1: | 67 if len(groups) != 1: |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 103 # If this step uploads results (and thus overwrites the most recently uploaded | 109 # If this step uploads results (and thus overwrites the most recently uploaded |
| 104 # results), only run it on scheduled builds (i.e. most recent revision) or if | 110 # results), only run it on scheduled builds (i.e. most recent revision) or if |
| 105 # the "force_upload" property was set. | 111 # the "force_upload" property was set. |
| 106 if step.IsUploadStep() and \ | 112 if step.IsUploadStep() and \ |
| 107 not _HasProperty(step, 'scheduler') and \ | 113 not _HasProperty(step, 'scheduler') and \ |
| 108 not _HasProperty(step, 'force_upload'): | 114 not _HasProperty(step, 'force_upload'): |
| 109 return False | 115 return False |
| 110 | 116 |
| 111 # Unless we have determined otherwise, run the step. | 117 # Unless we have determined otherwise, run the step. |
| 112 return True | 118 return True |
| OLD | NEW |