| 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 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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 61   return [] | 61   return [] | 
| 62 | 62 | 
| 63 | 63 | 
| 64 def CheckDoNotSubmit(input_api, output_api): | 64 def CheckDoNotSubmit(input_api, output_api): | 
| 65   return ( | 65   return ( | 
| 66       CheckDoNotSubmitInDescription(input_api, output_api) + | 66       CheckDoNotSubmitInDescription(input_api, output_api) + | 
| 67       CheckDoNotSubmitInFiles(input_api, output_api) | 67       CheckDoNotSubmitInFiles(input_api, output_api) | 
| 68       ) | 68       ) | 
| 69 | 69 | 
| 70 | 70 | 
|  | 71 def CheckChangeHasNoCR(input_api, output_api): | 
|  | 72   """Checks that there are no \r, \r\n (CR or CRLF) characters in any of the | 
|  | 73   text files to be submitted. | 
|  | 74   """ | 
|  | 75   outputs = [] | 
|  | 76   for f in input_api.AffectedTextFiles(): | 
|  | 77     if '\r' in input_api.ReadFile(f, 'rb'): | 
|  | 78       outputs.append(output_api.PresubmitPromptWarning( | 
|  | 79           "Found a CR character in %s" % f.LocalPath())) | 
|  | 80   return outputs | 
|  | 81 | 
|  | 82 | 
| 71 def CheckChangeHasNoTabs(input_api, output_api): | 83 def CheckChangeHasNoTabs(input_api, output_api): | 
| 72   """Checks that there are no tab characters in any of the text files to be | 84   """Checks that there are no tab characters in any of the text files to be | 
| 73   submitted. | 85   submitted. | 
| 74   """ | 86   """ | 
| 75   for f, line_num, line in input_api.RightHandSideLines(): | 87   for f, line_num, line in input_api.RightHandSideLines(): | 
| 76     if '\t' in line: | 88     if '\t' in line: | 
| 77       return [output_api.PresubmitPromptWarning( | 89       return [output_api.PresubmitPromptWarning( | 
| 78           "Found a tab character in %s, line %s" % | 90           "Found a tab character in %s, line %s" % | 
| 79           (f.LocalPath(), line_num))] | 91           (f.LocalPath(), line_num))] | 
| 80   return [] | 92   return [] | 
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 139     except ImportError: | 151     except ImportError: | 
| 140       outputs.append(message_type("Failed to load %s" % unit_test, | 152       outputs.append(message_type("Failed to load %s" % unit_test, | 
| 141                                   long_text=input_api.traceback.format_exc())) | 153                                   long_text=input_api.traceback.format_exc())) | 
| 142 | 154 | 
| 143   results = input_api.unittest.TextTestRunner(verbosity=0).run( | 155   results = input_api.unittest.TextTestRunner(verbosity=0).run( | 
| 144       input_api.unittest.TestSuite(tests_suite)) | 156       input_api.unittest.TestSuite(tests_suite)) | 
| 145   if not results.wasSuccessful(): | 157   if not results.wasSuccessful(): | 
| 146     outputs.append(message_type("%d unit tests failed." % | 158     outputs.append(message_type("%d unit tests failed." % | 
| 147                                 (len(results.failures) + len(results.errors)))) | 159                                 (len(results.failures) + len(results.errors)))) | 
| 148   return outputs | 160   return outputs | 
| OLD | NEW | 
|---|