| 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 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 """ | 251 """ |
| 252 bad = [] | 252 bad = [] |
| 253 for f, line_num, line in input_api.RightHandSideLines(source_file_filter): | 253 for f, line_num, line in input_api.RightHandSideLines(source_file_filter): |
| 254 # Allow lines with http://, https:// and #define/#pragma/#include/#if/#endif | 254 # Allow lines with http://, https:// and #define/#pragma/#include/#if/#endif |
| 255 # to exceed the maxlen rule. | 255 # to exceed the maxlen rule. |
| 256 if (len(line) > maxlen and | 256 if (len(line) > maxlen and |
| 257 not 'http://' in line and | 257 not 'http://' in line and |
| 258 not 'https://' in line and | 258 not 'https://' in line and |
| 259 not line.startswith('#define') and | 259 not line.startswith('#define') and |
| 260 not line.startswith('#include') and | 260 not line.startswith('#include') and |
| 261 not line.startswith('#import') and |
| 261 not line.startswith('#pragma') and | 262 not line.startswith('#pragma') and |
| 262 not line.startswith('#if') and | 263 not line.startswith('#if') and |
| 263 not line.startswith('#endif')): | 264 not line.startswith('#endif')): |
| 264 bad.append( | 265 bad.append( |
| 265 '%s, line %s, %s chars' % | 266 '%s, line %s, %s chars' % |
| 266 (f.LocalPath(), line_num, len(line))) | 267 (f.LocalPath(), line_num, len(line))) |
| 267 if len(bad) == 5: # Just show the first 5 errors. | 268 if len(bad) == 5: # Just show the first 5 errors. |
| 268 break | 269 break |
| 269 | 270 |
| 270 if bad: | 271 if bad: |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 518 pending_builds_len = len(builder.get('pending_builds', [])) | 519 pending_builds_len = len(builder.get('pending_builds', [])) |
| 519 if pending_builds_len > max_pendings: | 520 if pending_builds_len > max_pendings: |
| 520 out.append('%s has %d build(s) pending' % | 521 out.append('%s has %d build(s) pending' % |
| 521 (builder_name, pending_builds_len)) | 522 (builder_name, pending_builds_len)) |
| 522 if out: | 523 if out: |
| 523 return [output_api.PresubmitPromptWarning( | 524 return [output_api.PresubmitPromptWarning( |
| 524 'Build(s) pending. It is suggested to wait that no more than %d ' | 525 'Build(s) pending. It is suggested to wait that no more than %d ' |
| 525 'builds are pending.' % max_pendings, | 526 'builds are pending.' % max_pendings, |
| 526 long_text='\n'.join(out))] | 527 long_text='\n'.join(out))] |
| 527 return [] | 528 return [] |
| OLD | NEW |