Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # Copyright (c) 2009 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2009 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 """Top-level presubmit script for Chromium. | 6 """Top-level presubmit script for Chromium. |
| 7 | 7 |
| 8 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts for | 8 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts for |
| 9 details on the presubmit API built into gcl. | 9 details on the presubmit API built into gcl. |
| 10 """ | 10 """ |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 56 results.extend(LocalChecks(input_api, output_api, max_cols=0)) | 56 results.extend(LocalChecks(input_api, output_api, max_cols=0)) |
| 57 results.extend(input_api.canned_checks.CheckChangeHasBugField(input_api, | 57 results.extend(input_api.canned_checks.CheckChangeHasBugField(input_api, |
| 58 output_api)) | 58 output_api)) |
| 59 results.extend(input_api.canned_checks.CheckChangeHasTestField(input_api, | 59 results.extend(input_api.canned_checks.CheckChangeHasTestField(input_api, |
| 60 output_api)) | 60 output_api)) |
| 61 # Make sure the tree is 'open'. | 61 # Make sure the tree is 'open'. |
| 62 results.extend(input_api.canned_checks.CheckTreeIsOpen( | 62 results.extend(input_api.canned_checks.CheckTreeIsOpen( |
| 63 input_api, output_api, | 63 input_api, output_api, |
| 64 'http://chromium-status.appspot.com/status', '0' | 64 'http://chromium-status.appspot.com/status', '0' |
| 65 )) | 65 )) |
| 66 results.extend(CheckTryJobExecution(input_api, output_api)) | |
| 66 return results | 67 return results |
| 67 | 68 |
| 68 | 69 |
| 69 def LocalChecks(input_api, output_api, max_cols=80): | 70 def LocalChecks(input_api, output_api, max_cols=80): |
| 70 """Reports an error if for any source file in SOURCE_FILE_EXTENSIONS: | 71 """Reports an error if for any source file in SOURCE_FILE_EXTENSIONS: |
| 71 - uses CR (or CRLF) | 72 - uses CR (or CRLF) |
| 72 - contains a TAB | 73 - contains a TAB |
| 73 - has a line that ends with whitespace | 74 - has a line that ends with whitespace |
| 74 - contains a line >|max_cols| cols unless |max_cols| is 0. | 75 - contains a line >|max_cols| cols unless |max_cols| is 0. |
| 75 - File does not end in a newline, or ends in more than one. | 76 - File does not end in a newline, or ends in more than one. |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 140 | 141 |
| 141 if cr_files: | 142 if cr_files: |
| 142 results.append(output_api.PresubmitError( | 143 results.append(output_api.PresubmitError( |
| 143 'Found CR (or CRLF) line ending in these files, please use only LF:', | 144 'Found CR (or CRLF) line ending in these files, please use only LF:', |
| 144 items=cr_files)) | 145 items=cr_files)) |
| 145 if eof_files: | 146 if eof_files: |
| 146 results.append(output_api.PresubmitError( | 147 results.append(output_api.PresubmitError( |
| 147 'These files should end in one (and only one) newline character:', | 148 'These files should end in one (and only one) newline character:', |
| 148 items=eof_files)) | 149 items=eof_files)) |
| 149 return results | 150 return results |
| 151 | |
| 152 | |
| 153 def CheckTryJobExecution(input_api, output_api): | |
| 154 url = "http://codereview.chromium.org/%d/get_build_results/%d" % ( | |
| 155 input_api.change.issue, input_api.change.patchset) | |
| 156 outputs = [] | |
| 157 try: | |
| 158 connection = input_api.urllib2.urlopen(url) | |
| 159 # platform|status|url | |
| 160 values = [item.split('|', 2) for item in connection.read().splitlines()] | |
| 161 connection.close() | |
| 162 statuses = map(lambda x: x[1], values) | |
| 163 if 'failure' in statuses: | |
| 164 failures = filter(lambda x: x[1] != 'success', values) | |
| 165 long_text = '\n'.join("% 5s: % 7s %s" % (item[0], item[1], item[2]) | |
| 166 for item in failures) | |
| 167 # TODO(maruel): Change to a PresubmitPromptWarning once the try server is | |
| 168 # stable enough and it seems to work fine. | |
| 169 message = 'You had try job failures. Are you sure you want to check-in?' | |
| 170 outputs.append(output_api.PresubmitNotifyResult(message=message, | |
| 171 long_text=long_text)) | |
| 172 elif 'pending' in statuses or len(values) != 3: | |
| 173 long_text = '\n'.join("% 5s: % 7s %s" % (item[0], item[1], item[2]) | |
| 174 for item in values) | |
| 175 # TODO(maruel): Change to a PresubmitPromptWarning once the try server is | |
| 176 # stable enough and it seems to work fine. | |
| 177 message = 'You should try the patch first (and wait for it to finish).' | |
| 178 outputs.append(output_api.PresubmitNotifyResult(message=message, | |
| 179 long_text=long_text)) | |
| 180 except input_api.urllib2.HTTPError, e: | |
| 181 #except ValueError, e: | |
|
Nicolas Sylvain
2009/06/08 17:27:34
uh?
| |
| 182 if e.code == 404: | |
| 183 # Fallback to no try job. | |
| 184 # TODO(maruel): Change to a PresubmitPromptWarning once the try server is | |
| 185 # stable enough and it seems to work fine. | |
| 186 outputs.append(output_api.PresubmitNotifyResult( | |
| 187 'You should try the patch first.')) | |
| 188 else: | |
| 189 # Another HTTP error happened, warn the user. | |
| 190 # TODO(maruel): Change to a PresubmitPromptWarning once it deemed to work | |
| 191 # fine. | |
| 192 outputs.append(output_api.PresubmitNotifyResult( | |
| 193 'Got %s while looking for try job status.' % str(e))) | |
| 194 return outputs | |
| OLD | NEW |