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 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
345 """Checks that an url's content doesn't match a regexp that would mean that | 345 """Checks that an url's content doesn't match a regexp that would mean that |
346 the tree is closed.""" | 346 the tree is closed.""" |
347 if not input_api.is_committing: | 347 if not input_api.is_committing: |
348 return [] | 348 return [] |
349 try: | 349 try: |
350 connection = input_api.urllib2.urlopen(url) | 350 connection = input_api.urllib2.urlopen(url) |
351 status = connection.read() | 351 status = connection.read() |
352 connection.close() | 352 connection.close() |
353 if input_api.re.match(closed, status): | 353 if input_api.re.match(closed, status): |
354 long_text = status + '\n' + url | 354 long_text = status + '\n' + url |
355 return [output_api.PresubmitPromptWarning('The tree is closed.', | 355 return [output_api.PresubmitError('The tree is closed dude!', |
356 long_text=long_text)] | 356 long_text=long_text)] |
357 except IOError: | 357 except IOError: |
358 pass | 358 pass |
359 return [] | 359 return [] |
360 | 360 |
361 | 361 |
362 def RunPythonUnitTests(input_api, output_api, unit_tests): | 362 def RunPythonUnitTests(input_api, output_api, unit_tests): |
363 """Run the unit tests out of process, capture the output and use the result | 363 """Run the unit tests out of process, capture the output and use the result |
364 code to determine success. | 364 code to determine success. |
365 """ | 365 """ |
366 # We don't want to hinder users from uploading incomplete patches. | 366 # We don't want to hinder users from uploading incomplete patches. |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
488 pending_builds_len = len(builder.get('pending_builds', [])) | 488 pending_builds_len = len(builder.get('pending_builds', [])) |
489 if pending_builds_len > max_pendings: | 489 if pending_builds_len > max_pendings: |
490 out.append('%s has %d build(s) pending' % | 490 out.append('%s has %d build(s) pending' % |
491 (builder_name, pending_builds_len)) | 491 (builder_name, pending_builds_len)) |
492 if out: | 492 if out: |
493 return [output_api.PresubmitPromptWarning( | 493 return [output_api.PresubmitPromptWarning( |
494 'Build(s) pending. It is suggested to wait that no more than %d ' | 494 'Build(s) pending. It is suggested to wait that no more than %d ' |
495 'builds are pending.' % max_pendings, | 495 'builds are pending.' % max_pendings, |
496 long_text='\n'.join(out))] | 496 long_text='\n'.join(out))] |
497 return [] | 497 return [] |
OLD | NEW |