| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2006-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 """Generic presubmit checks that can be reused by other presubmit checks.""" | 6 """Generic presubmit checks that can be reused by other presubmit checks.""" |
| 7 | 7 |
| 8 | 8 |
| 9 ### Description checks | 9 ### Description checks |
| 10 | 10 |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 if len(bad) == 5: # Just show the first 5 errors. | 112 if len(bad) == 5: # Just show the first 5 errors. |
| 113 break | 113 break |
| 114 | 114 |
| 115 if bad: | 115 if bad: |
| 116 msg = "Found lines longer than %s characters (first 5 shown)." % maxlen | 116 msg = "Found lines longer than %s characters (first 5 shown)." % maxlen |
| 117 return [output_api.PresubmitPromptWarning(msg, items=bad)] | 117 return [output_api.PresubmitPromptWarning(msg, items=bad)] |
| 118 else: | 118 else: |
| 119 return [] | 119 return [] |
| 120 | 120 |
| 121 | 121 |
| 122 def CheckChangeSvnEolStyle(input_api, output_api, source_file_filter): | 122 def CheckChangeSvnEolStyle(input_api, output_api, source_file_filter=None): |
| 123 """Checks that the source files have svn:eol-style=LF.""" | 123 """Checks that the source files have svn:eol-style=LF.""" |
| 124 bad = filter(lambda f: f.scm == 'svn' and f.Property('svn:eol-style') != 'LF', | 124 bad = filter(lambda f: f.scm == 'svn' and f.Property('svn:eol-style') != 'LF', |
| 125 input_api.AffectedSourceFiles(source_file_filter)) | 125 input_api.AffectedSourceFiles(source_file_filter)) |
| 126 if bad: | 126 if bad: |
| 127 return [output_api.PresubmitError( | 127 return [output_api.PresubmitError( |
| 128 "Fix these files with svn svn:eol-style=LF", items=bad)] | 128 "Fix these files with svn svn:eol-style=LF", items=bad)] |
| 129 return [] | 129 return [] |
| 130 | 130 |
| 131 | 131 |
| 132 ### Other checks | 132 ### Other checks |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 long_text=input_api.traceback.format_exc())) | 180 long_text=input_api.traceback.format_exc())) |
| 181 | 181 |
| 182 buffer = input_api.cStringIO.StringIO() | 182 buffer = input_api.cStringIO.StringIO() |
| 183 results = input_api.unittest.TextTestRunner(stream=buffer, verbosity=0).run( | 183 results = input_api.unittest.TextTestRunner(stream=buffer, verbosity=0).run( |
| 184 input_api.unittest.TestSuite(tests_suite)) | 184 input_api.unittest.TestSuite(tests_suite)) |
| 185 if not results.wasSuccessful(): | 185 if not results.wasSuccessful(): |
| 186 outputs.append(message_type("%d unit tests failed." % | 186 outputs.append(message_type("%d unit tests failed." % |
| 187 (len(results.failures) + len(results.errors)), | 187 (len(results.failures) + len(results.errors)), |
| 188 long_text=buffer.getvalue())) | 188 long_text=buffer.getvalue())) |
| 189 return outputs | 189 return outputs |
| OLD | NEW |