OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 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 """Unit tests for presubmit_support.py and presubmit_canned_checks.py.""" | 6 """Unit tests for presubmit_support.py and presubmit_canned_checks.py.""" |
7 | 7 |
8 # pylint: disable=E1101,E1103 | 8 # pylint: disable=E1101,E1103 |
9 | 9 |
10 import StringIO | 10 import StringIO |
(...skipping 2161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2172 check = lambda x, y, _: presubmit_canned_checks.CheckLongLines(x, y, 80) | 2172 check = lambda x, y, _: presubmit_canned_checks.CheckLongLines(x, y, 80) |
2173 self.ContentTest(check, 'A ' * 50, 'foo.java', 'A ' * 50 + 'B', 'foo.java', | 2173 self.ContentTest(check, 'A ' * 50, 'foo.java', 'A ' * 50 + 'B', 'foo.java', |
2174 presubmit.OutputApi.PresubmitPromptWarning) | 2174 presubmit.OutputApi.PresubmitPromptWarning) |
2175 | 2175 |
2176 def testCannedCheckSpecialJavaLongLines(self): | 2176 def testCannedCheckSpecialJavaLongLines(self): |
2177 check = lambda x, y, _: presubmit_canned_checks.CheckLongLines(x, y, 80) | 2177 check = lambda x, y, _: presubmit_canned_checks.CheckLongLines(x, y, 80) |
2178 self.ContentTest(check, 'import ' + 'A ' * 150, 'foo.java', | 2178 self.ContentTest(check, 'import ' + 'A ' * 150, 'foo.java', |
2179 'importSomething ' + 'A ' * 50, 'foo.java', | 2179 'importSomething ' + 'A ' * 50, 'foo.java', |
2180 presubmit.OutputApi.PresubmitPromptWarning) | 2180 presubmit.OutputApi.PresubmitPromptWarning) |
2181 | 2181 |
| 2182 def testCannedCheckJSLongLines(self): |
| 2183 check = lambda x, y, _: presubmit_canned_checks.CheckLongLines(x, y, 10) |
| 2184 self.ContentTest(check, 'GEN(\'#include "c/b/ui/webui/fixture.h"\');', |
| 2185 'foo.js', "// GEN('something');", 'foo.js', |
| 2186 presubmit.OutputApi.PresubmitPromptWarning) |
| 2187 |
2182 def testCannedCheckObjCExceptionLongLines(self): | 2188 def testCannedCheckObjCExceptionLongLines(self): |
2183 check = lambda x, y, _: presubmit_canned_checks.CheckLongLines(x, y, 80) | 2189 check = lambda x, y, _: presubmit_canned_checks.CheckLongLines(x, y, 80) |
2184 self.ContentTest(check, '#import ' + 'A ' * 150, 'foo.mm', | 2190 self.ContentTest(check, '#import ' + 'A ' * 150, 'foo.mm', |
2185 'import' + 'A ' * 150, 'foo.mm', | 2191 'import' + 'A ' * 150, 'foo.mm', |
2186 presubmit.OutputApi.PresubmitPromptWarning) | 2192 presubmit.OutputApi.PresubmitPromptWarning) |
2187 | 2193 |
2188 def testCannedCheckMakefileLongLines(self): | 2194 def testCannedCheckMakefileLongLines(self): |
2189 check = lambda x, y, _: presubmit_canned_checks.CheckLongLines(x, y, 80) | 2195 check = lambda x, y, _: presubmit_canned_checks.CheckLongLines(x, y, 80) |
2190 self.ContentTest(check, 'A ' * 100, 'foo.mk', 'A ' * 100 + 'B', 'foo.mk', | 2196 self.ContentTest(check, 'A ' * 100, 'foo.mk', 'A ' * 100 + 'B', 'foo.mk', |
2191 presubmit.OutputApi.PresubmitPromptWarning) | 2197 presubmit.OutputApi.PresubmitPromptWarning) |
(...skipping 709 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2901 owners_check=False) | 2907 owners_check=False) |
2902 self.assertEqual(1, len(results)) | 2908 self.assertEqual(1, len(results)) |
2903 self.assertEqual( | 2909 self.assertEqual( |
2904 'Found line ending with white spaces in:', results[0]._message) | 2910 'Found line ending with white spaces in:', results[0]._message) |
2905 self.checkstdout('') | 2911 self.checkstdout('') |
2906 | 2912 |
2907 | 2913 |
2908 if __name__ == '__main__': | 2914 if __name__ == '__main__': |
2909 import unittest | 2915 import unittest |
2910 unittest.main() | 2916 unittest.main() |
OLD | NEW |