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 logging | 10 import logging |
(...skipping 1816 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1827 check = lambda x, y, _: presubmit_canned_checks.CheckLongLines(x, y) | 1827 check = lambda x, y, _: presubmit_canned_checks.CheckLongLines(x, y) |
1828 self.ContentTest(check, 'A ' * 50, 'foo.java', 'A ' * 50 + 'B', 'foo.java', | 1828 self.ContentTest(check, 'A ' * 50, 'foo.java', 'A ' * 50 + 'B', 'foo.java', |
1829 presubmit.OutputApi.PresubmitPromptWarning) | 1829 presubmit.OutputApi.PresubmitPromptWarning) |
1830 | 1830 |
1831 def testCannedCheckSpecialJavaLongLines(self): | 1831 def testCannedCheckSpecialJavaLongLines(self): |
1832 check = lambda x, y, _: presubmit_canned_checks.CheckLongLines(x, y) | 1832 check = lambda x, y, _: presubmit_canned_checks.CheckLongLines(x, y) |
1833 self.ContentTest(check, 'import ' + 'A ' * 150, 'foo.java', | 1833 self.ContentTest(check, 'import ' + 'A ' * 150, 'foo.java', |
1834 'importSomething ' + 'A ' * 50, 'foo.java', | 1834 'importSomething ' + 'A ' * 50, 'foo.java', |
1835 presubmit.OutputApi.PresubmitPromptWarning) | 1835 presubmit.OutputApi.PresubmitPromptWarning) |
1836 | 1836 |
| 1837 def testCannedCheckMakefileLongLines(self): |
| 1838 check = lambda x, y, _: presubmit_canned_checks.CheckLongLines(x, y) |
| 1839 self.ContentTest(check, 'A ' * 100, 'foo.mk', 'A ' * 100 + 'B', 'foo.mk', |
| 1840 presubmit.OutputApi.PresubmitPromptWarning) |
| 1841 |
1837 def testCannedCheckLongLinesLF(self): | 1842 def testCannedCheckLongLinesLF(self): |
1838 check = lambda x, y, z: presubmit_canned_checks.CheckLongLines(x, y, 10, z) | 1843 check = lambda x, y, z: presubmit_canned_checks.CheckLongLines(x, y, 10, z) |
1839 self.ContentTest(check, '012345678\n', None, '0123456789\n', None, | 1844 self.ContentTest(check, '012345678\n', None, '0123456789\n', None, |
1840 presubmit.OutputApi.PresubmitPromptWarning) | 1845 presubmit.OutputApi.PresubmitPromptWarning) |
1841 | 1846 |
1842 def testCannedCheckLongLinesMacro(self): | 1847 def testCannedCheckLongLinesMacro(self): |
1843 check = lambda x, y, z: presubmit_canned_checks.CheckLongLines(x, y, 10, z) | 1848 check = lambda x, y, z: presubmit_canned_checks.CheckLongLines(x, y, 10, z) |
1844 self.ContentTest( | 1849 self.ContentTest( |
1845 check, | 1850 check, |
1846 # Put a space in so it doesn't trigger long symbols. Allow 1/3 more. | 1851 # Put a space in so it doesn't trigger long symbols. Allow 1/3 more. |
(...skipping 639 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2486 owners_check=False) | 2491 owners_check=False) |
2487 self.assertEqual(1, len(results)) | 2492 self.assertEqual(1, len(results)) |
2488 self.assertEqual( | 2493 self.assertEqual( |
2489 'Found line ending with white spaces in:', results[0]._message) | 2494 'Found line ending with white spaces in:', results[0]._message) |
2490 self.checkstdout('') | 2495 self.checkstdout('') |
2491 | 2496 |
2492 | 2497 |
2493 if __name__ == '__main__': | 2498 if __name__ == '__main__': |
2494 import unittest | 2499 import unittest |
2495 unittest.main() | 2500 unittest.main() |
OLD | NEW |