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): |
| 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', |
| 125 input_api.AffectedSourceFiles(source_file_filter)) |
| 126 if bad: |
| 127 return [output_api.PresubmitError( |
| 128 "Fix these files with svn svn:eol-style=LF", items=bad)] |
| 129 return [] |
| 130 |
| 131 |
122 ### Other checks | 132 ### Other checks |
123 | 133 |
124 def CheckDoNotSubmit(input_api, output_api): | 134 def CheckDoNotSubmit(input_api, output_api): |
125 return ( | 135 return ( |
126 CheckDoNotSubmitInDescription(input_api, output_api) + | 136 CheckDoNotSubmitInDescription(input_api, output_api) + |
127 CheckDoNotSubmitInFiles(input_api, output_api) | 137 CheckDoNotSubmitInFiles(input_api, output_api) |
128 ) | 138 ) |
129 | 139 |
130 | 140 |
131 def CheckTreeIsOpen(input_api, output_api, url, closed): | 141 def CheckTreeIsOpen(input_api, output_api, url, closed): |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 except ImportError: | 178 except ImportError: |
169 outputs.append(message_type("Failed to load %s" % unit_test, | 179 outputs.append(message_type("Failed to load %s" % unit_test, |
170 long_text=input_api.traceback.format_exc())) | 180 long_text=input_api.traceback.format_exc())) |
171 | 181 |
172 results = input_api.unittest.TextTestRunner(verbosity=0).run( | 182 results = input_api.unittest.TextTestRunner(verbosity=0).run( |
173 input_api.unittest.TestSuite(tests_suite)) | 183 input_api.unittest.TestSuite(tests_suite)) |
174 if not results.wasSuccessful(): | 184 if not results.wasSuccessful(): |
175 outputs.append(message_type("%d unit tests failed." % | 185 outputs.append(message_type("%d unit tests failed." % |
176 (len(results.failures) + len(results.errors)))) | 186 (len(results.failures) + len(results.errors)))) |
177 return outputs | 187 return outputs |
OLD | NEW |