Chromium Code Reviews| Index: PRESUBMIT.py |
| =================================================================== |
| --- PRESUBMIT.py (revision 17847) |
| +++ PRESUBMIT.py (working copy) |
| @@ -63,6 +63,7 @@ |
| input_api, output_api, |
| 'http://chromium-status.appspot.com/status', '0' |
| )) |
| + results.extend(CheckTryJobExecution(input_api, output_api)) |
| return results |
| @@ -147,3 +148,47 @@ |
| 'These files should end in one (and only one) newline character:', |
| items=eof_files)) |
| return results |
| + |
| + |
| +def CheckTryJobExecution(input_api, output_api): |
| + url = "http://codereview.chromium.org/%d/get_build_results/%d" % ( |
| + input_api.change.issue, input_api.change.patchset) |
| + outputs = [] |
| + try: |
| + connection = input_api.urllib2.urlopen(url) |
| + # platform|status|url |
| + values = [item.split('|', 2) for item in connection.read().splitlines()] |
| + connection.close() |
| + statuses = map(lambda x: x[1], values) |
| + if 'failure' in statuses: |
| + failures = filter(lambda x: x[1] != 'success', values) |
| + long_text = '\n'.join("% 5s: % 7s %s" % (item[0], item[1], item[2]) |
| + for item in failures) |
| + # TODO(maruel): Change to a PresubmitPromptWarning once the try server is |
| + # stable enough and it seems to work fine. |
| + message = 'You had try job failures. Are you sure you want to check-in?' |
| + outputs.append(output_api.PresubmitNotifyResult(message=message, |
| + long_text=long_text)) |
| + elif 'pending' in statuses or len(values) != 3: |
| + long_text = '\n'.join("% 5s: % 7s %s" % (item[0], item[1], item[2]) |
| + for item in values) |
| + # TODO(maruel): Change to a PresubmitPromptWarning once the try server is |
| + # stable enough and it seems to work fine. |
| + message = 'You should try the patch first (and wait for it to finish).' |
| + outputs.append(output_api.PresubmitNotifyResult(message=message, |
| + long_text=long_text)) |
| + except input_api.urllib2.HTTPError, e: |
| + #except ValueError, e: |
|
Nicolas Sylvain
2009/06/08 17:27:34
uh?
|
| + if e.code == 404: |
| + # Fallback to no try job. |
| + # TODO(maruel): Change to a PresubmitPromptWarning once the try server is |
| + # stable enough and it seems to work fine. |
| + outputs.append(output_api.PresubmitNotifyResult( |
| + 'You should try the patch first.')) |
| + else: |
| + # Another HTTP error happened, warn the user. |
| + # TODO(maruel): Change to a PresubmitPromptWarning once it deemed to work |
| + # fine. |
| + outputs.append(output_api.PresubmitNotifyResult( |
| + 'Got %s while looking for try job status.' % str(e))) |
| + return outputs |