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 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 | 49 |
50 def IsUploadStep(self): | 50 def IsUploadStep(self): |
51 return self._is_upload_step | 51 return self._is_upload_step |
52 | 52 |
53 def IsRebaselineStep(self): | 53 def IsRebaselineStep(self): |
54 return self._is_rebaseline_step | 54 return self._is_rebaseline_step |
55 | 55 |
56 def commandComplete(self, cmd): | 56 def commandComplete(self, cmd): |
57 """ Override of BuildStep's commandComplete method which allows us to parse | 57 """ Override of BuildStep's commandComplete method which allows us to parse |
58 build properties from the output of this step. """ | 58 build properties from the output of this step. """ |
59 if (cmd.rc not in (0, retcode_command.ReturnCodeCommand.RETCODE_WARNINGS) | 59 |
60 and self._exception_on_failure): | 60 # We make a best effort to parse the properties out of stdout, whether |
61 raise Exception('Command marked exception_on_failure failed.') | 61 # the command succeeded or failed. If the command succeeded, we |
62 if self._get_props_from_stdout and cmd.rc == 0: | 62 # definitely expect the property to be found in stdout--if not, raise |
| 63 # an exception. |
| 64 if self._get_props_from_stdout: |
63 log = cmd.logs['stdio'] | 65 log = cmd.logs['stdio'] |
64 stdout = ''.join(log.getChunks([STDOUT], onlyText=True)) | 66 stdout = ''.join(log.getChunks([STDOUT], onlyText=True)) |
65 self._changed_props = {} | 67 self._changed_props = {} |
66 for prop, regex in self._get_props_from_stdout.iteritems(): | 68 for prop, regex in self._get_props_from_stdout.iteritems(): |
67 matches = re.search(regex, stdout) | 69 matches = re.search(regex, stdout) |
68 if not matches: | 70 if not matches: |
69 raise Exception('Unable to parse %s from stdout.' % prop) | 71 if cmd.rc == 0: |
| 72 raise Exception('Unable to parse %s from stdout.' % prop) |
| 73 continue |
70 groups = matches.groups() | 74 groups = matches.groups() |
71 if len(groups) != 1: | 75 if len(groups) != 1: |
72 raise Exception('Multiple matches for "%s"' % regex) | 76 if cmd.rc == 0: |
| 77 raise Exception('Multiple matches for "%s"' % regex) |
| 78 continue |
73 prop_value = groups[0] | 79 prop_value = groups[0] |
74 self.setProperty(prop, prop_value, ''.join(self.description)) | 80 self.setProperty(prop, prop_value, ''.join(self.description)) |
75 self._changed_props[prop] = prop_value | 81 self._changed_props[prop] = prop_value |
| 82 |
| 83 if (cmd.rc not in (0, retcode_command.ReturnCodeCommand.RETCODE_WARNINGS) |
| 84 and self._exception_on_failure): |
| 85 raise Exception('Command marked exception_on_failure failed.') |
76 retcode_command.ReturnCodeCommand.commandComplete(self, cmd) | 86 retcode_command.ReturnCodeCommand.commandComplete(self, cmd) |
77 | 87 |
78 def getText(self, cmd, results): | 88 def getText(self, cmd, results): |
79 """ Override of BuildStep's getText method which appends any changed build | 89 """ Override of BuildStep's getText method which appends any changed build |
80 properties to the description of the BuildStep. """ | 90 properties to the description of the BuildStep. """ |
81 text = self.description | 91 text = self.description |
82 if self._changed_props: | 92 if self._changed_props: |
83 text.extend(['%s: %s' % ( | 93 text.extend(['%s: %s' % ( |
84 key, self._changed_props.get(key)) for key in self._changed_props]) | 94 key, self._changed_props.get(key)) for key in self._changed_props]) |
85 return text | 95 return text |
(...skipping 27 matching lines...) Expand all Loading... |
113 # If this step uploads results (and thus overwrites the most recently uploaded | 123 # If this step uploads results (and thus overwrites the most recently uploaded |
114 # results), only run it on scheduled builds (i.e. most recent revision) or if | 124 # results), only run it on scheduled builds (i.e. most recent revision) or if |
115 # the "force_upload" property was set. | 125 # the "force_upload" property was set. |
116 if step.IsUploadStep() and \ | 126 if step.IsUploadStep() and \ |
117 not _HasProperty(step, 'scheduler') and \ | 127 not _HasProperty(step, 'scheduler') and \ |
118 not _HasProperty(step, 'force_upload'): | 128 not _HasProperty(step, 'force_upload'): |
119 return False | 129 return False |
120 | 130 |
121 # Unless we have determined otherwise, run the step. | 131 # Unless we have determined otherwise, run the step. |
122 return True | 132 return True |
OLD | NEW |