| OLD | NEW |
| 1 # Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2010 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 """Generic presubmit checks that can be reused by other presubmit checks.""" | 5 """Generic presubmit checks that can be reused by other presubmit checks.""" |
| 6 | 6 |
| 7 ### Description checks | 7 ### Description checks |
| 8 | 8 |
| 9 def CheckChangeHasTestField(input_api, output_api): | 9 def CheckChangeHasTestField(input_api, output_api): |
| 10 """Requires that the changelist have a TEST= field.""" | 10 """Requires that the changelist have a TEST= field.""" |
| (...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 509 try: | 509 try: |
| 510 data = input_api.json.loads(raw_data) | 510 data = input_api.json.loads(raw_data) |
| 511 except ValueError: | 511 except ValueError: |
| 512 return [output_api.PresubmitNotifyResult('Received malformed json while ' | 512 return [output_api.PresubmitNotifyResult('Received malformed json while ' |
| 513 'looking up buildbot status')] | 513 'looking up buildbot status')] |
| 514 | 514 |
| 515 out = [] | 515 out = [] |
| 516 for (builder_name, builder) in data.iteritems(): | 516 for (builder_name, builder) in data.iteritems(): |
| 517 if builder_name in ignored: | 517 if builder_name in ignored: |
| 518 continue | 518 continue |
| 519 if builder.get('state', '') == 'offline': |
| 520 continue |
| 519 pending_builds_len = len(builder.get('pending_builds', [])) | 521 pending_builds_len = len(builder.get('pending_builds', [])) |
| 520 if pending_builds_len > max_pendings: | 522 if pending_builds_len > max_pendings: |
| 521 out.append('%s has %d build(s) pending' % | 523 out.append('%s has %d build(s) pending' % |
| 522 (builder_name, pending_builds_len)) | 524 (builder_name, pending_builds_len)) |
| 523 if out: | 525 if out: |
| 524 return [output_api.PresubmitPromptWarning( | 526 return [output_api.PresubmitPromptWarning( |
| 525 'Build(s) pending. It is suggested to wait that no more than %d ' | 527 'Build(s) pending. It is suggested to wait that no more than %d ' |
| 526 'builds are pending.' % max_pendings, | 528 'builds are pending.' % max_pendings, |
| 527 long_text='\n'.join(out))] | 529 long_text='\n'.join(out))] |
| 528 return [] | 530 return [] |
| OLD | NEW |