Chromium Code Reviews| Index: master/skia_master_scripts/skia_build_step.py |
| diff --git a/master/skia_master_scripts/skia_build_step.py b/master/skia_master_scripts/skia_build_step.py |
| index 0efbccd08850ffa26c2e66587f18fb83dcbe61b6..f771e7792fb6496f33d7220d2f963be5829b3e90 100644 |
| --- a/master/skia_master_scripts/skia_build_step.py |
| +++ b/master/skia_master_scripts/skia_build_step.py |
| @@ -16,14 +16,18 @@ class SkiaBuildStep(retcode_command.ReturnCodeCommand): |
| to by BuildStep.getProperty() are scoped for the entire duration of the build. |
| """ |
| def __init__(self, is_upload_step=False, is_rebaseline_step=False, |
| - get_props_from_stdout=None, exception_on_failure=False, |
| - **kwargs): |
| + get_links_from_stdout=None, get_props_from_stdout=None, |
| + exception_on_failure=False, **kwargs): |
| """ Instantiates a new SkiaBuildStep. |
| is_upload_step: boolean indicating whether this step should be skipped when |
| the buildbot is not performing uploads. |
| is_rebaseline_step: boolean indicating whether this step is required for |
| rebaseline-only builds. |
| + get_links_from_stdout: optional dictionary. Keys are strings indicating |
| + link text to set based on the output of this step. Values are |
| + strings containing regular expressions for parsing the linked URL from |
| + the output of the step. |
| get_props_from_stdout: optional dictionary. Keys are strings indicating |
| build properties to set based on the output of this step. Values are |
| strings containing regular expressions for parsing the property from |
| @@ -36,6 +40,7 @@ class SkiaBuildStep(retcode_command.ReturnCodeCommand): |
| """ |
| self._is_upload_step = is_upload_step |
| self._is_rebaseline_step = is_rebaseline_step |
| + self._get_links_from_stdout = get_links_from_stdout |
| self._get_props_from_stdout = get_props_from_stdout |
| self._exception_on_failure = exception_on_failure |
| @@ -57,28 +62,41 @@ class SkiaBuildStep(retcode_command.ReturnCodeCommand): |
| """ Override of BuildStep's commandComplete method which allows us to parse |
| build properties from the output of this step. """ |
| - # We make a best effort to parse the properties out of stdout, whether |
| - # the command succeeded or failed. If the command succeeded, we |
| - # definitely expect the property to be found in stdout--if not, raise |
| - # an exception. |
| - if self._get_props_from_stdout: |
| + if self._get_props_from_stdout or self._get_links_from_stdout: |
| log = cmd.logs['stdio'] |
| stdout = ''.join(log.getChunks([STDOUT], onlyText=True)) |
|
borenet
2014/06/06 12:10:34
This is probably a performance killer. Seems like
epoger
2014/06/09 13:33:29
I don't know how the chunks are split. It would n
|
| self._changed_props = {} |
| - for prop, regex in self._get_props_from_stdout.iteritems(): |
| - matches = re.search(regex, stdout) |
| - if not matches: |
| - if cmd.rc == 0: |
| - raise Exception('Unable to parse %s from stdout.' % prop) |
| - continue |
| - groups = matches.groups() |
| - if len(groups) != 1: |
| - if cmd.rc == 0: |
| - raise Exception('Multiple matches for "%s"' % regex) |
| - continue |
| - prop_value = groups[0] |
| - self.setProperty(prop, prop_value, ''.join(self.description)) |
| - self._changed_props[prop] = prop_value |
| + |
| + # We make a best effort to parse the properties out of stdout, whether |
| + # the command succeeded or failed. If the command succeeded, we |
| + # definitely expect the property to be found in stdout--if not, raise |
| + # an exception. |
| + if self._get_props_from_stdout: |
| + for prop, regex in self._get_props_from_stdout.iteritems(): |
| + matches = re.search(regex, stdout) |
| + if not matches: |
| + if cmd.rc == 0: |
| + raise Exception('Unable to parse %s from stdout.' % prop) |
| + continue |
| + groups = matches.groups() |
| + if len(groups) != 1: |
| + if cmd.rc == 0: |
| + raise Exception('Multiple matches for "%s"' % regex) |
| + continue |
| + prop_value = groups[0] |
| + self.setProperty(prop, prop_value, ''.join(self.description)) |
| + self._changed_props[prop] = prop_value |
| + |
| + # If there might be URL links we want in stdout, look for them; |
| + # their presence is optional, though, so we don't throw an exception |
| + # if they are not found. |
| + if self._get_links_from_stdout: |
| + for name, regex in self._get_links_from_stdout.iteritems(): |
| + matches = re.search(regex, stdout) |
| + if matches: |
| + groups = matches.groups() |
| + for url in groups: |
| + self.addURL(name, url) |
| if (cmd.rc not in (0, retcode_command.ReturnCodeCommand.RETCODE_WARNINGS) |
| and self._exception_on_failure): |