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 1838 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1849 presubmit.OutputApi.PresubmitPromptWarning) | 1849 presubmit.OutputApi.PresubmitPromptWarning) |
1850 self.assertEquals(results1[0]._long_text, | 1850 self.assertEquals(results1[0]._long_text, |
1851 'makefile.foo, line 46') | 1851 'makefile.foo, line 46') |
1852 | 1852 |
1853 def testCannedCheckLongLines(self): | 1853 def testCannedCheckLongLines(self): |
1854 check = lambda x, y, z: presubmit_canned_checks.CheckLongLines(x, y, 10, z) | 1854 check = lambda x, y, z: presubmit_canned_checks.CheckLongLines(x, y, 10, z) |
1855 self.ContentTest(check, '0123456789', None, '01234567890', None, | 1855 self.ContentTest(check, '0123456789', None, '01234567890', None, |
1856 presubmit.OutputApi.PresubmitPromptWarning) | 1856 presubmit.OutputApi.PresubmitPromptWarning) |
1857 | 1857 |
1858 def testCannedCheckJavaLongLines(self): | 1858 def testCannedCheckJavaLongLines(self): |
1859 check = lambda x, y, _: presubmit_canned_checks.CheckLongLines(x, y) | 1859 check = lambda x, y, _: presubmit_canned_checks.CheckLongLines(x, y, 80) |
1860 self.ContentTest(check, 'A ' * 50, 'foo.java', 'A ' * 50 + 'B', 'foo.java', | 1860 self.ContentTest(check, 'A ' * 50, 'foo.java', 'A ' * 50 + 'B', 'foo.java', |
1861 presubmit.OutputApi.PresubmitPromptWarning) | 1861 presubmit.OutputApi.PresubmitPromptWarning) |
1862 | 1862 |
1863 def testCannedCheckSpecialJavaLongLines(self): | 1863 def testCannedCheckSpecialJavaLongLines(self): |
1864 check = lambda x, y, _: presubmit_canned_checks.CheckLongLines(x, y) | 1864 check = lambda x, y, _: presubmit_canned_checks.CheckLongLines(x, y, 80) |
1865 self.ContentTest(check, 'import ' + 'A ' * 150, 'foo.java', | 1865 self.ContentTest(check, 'import ' + 'A ' * 150, 'foo.java', |
1866 'importSomething ' + 'A ' * 50, 'foo.java', | 1866 'importSomething ' + 'A ' * 50, 'foo.java', |
1867 presubmit.OutputApi.PresubmitPromptWarning) | 1867 presubmit.OutputApi.PresubmitPromptWarning) |
1868 | 1868 |
1869 def testCannedCheckMakefileLongLines(self): | 1869 def testCannedCheckMakefileLongLines(self): |
1870 check = lambda x, y, _: presubmit_canned_checks.CheckLongLines(x, y) | 1870 check = lambda x, y, _: presubmit_canned_checks.CheckLongLines(x, y, 80) |
1871 self.ContentTest(check, 'A ' * 100, 'foo.mk', 'A ' * 100 + 'B', 'foo.mk', | 1871 self.ContentTest(check, 'A ' * 100, 'foo.mk', 'A ' * 100 + 'B', 'foo.mk', |
1872 presubmit.OutputApi.PresubmitPromptWarning) | 1872 presubmit.OutputApi.PresubmitPromptWarning) |
1873 | 1873 |
1874 def testCannedCheckLongLinesLF(self): | 1874 def testCannedCheckLongLinesLF(self): |
1875 check = lambda x, y, z: presubmit_canned_checks.CheckLongLines(x, y, 10, z) | 1875 check = lambda x, y, z: presubmit_canned_checks.CheckLongLines(x, y, 10, z) |
1876 self.ContentTest(check, '012345678\n', None, '0123456789\n', None, | 1876 self.ContentTest(check, '012345678\n', None, '0123456789\n', None, |
1877 presubmit.OutputApi.PresubmitPromptWarning) | 1877 presubmit.OutputApi.PresubmitPromptWarning) |
1878 | 1878 |
1879 def testCannedCheckLongLinesMacro(self): | 1879 def testCannedCheckLongLinesMacro(self): |
1880 check = lambda x, y, z: presubmit_canned_checks.CheckLongLines(x, y, 10, z) | 1880 check = lambda x, y, z: presubmit_canned_checks.CheckLongLines(x, y, 10, z) |
(...skipping 655 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2536 owners_check=False) | 2536 owners_check=False) |
2537 self.assertEqual(1, len(results)) | 2537 self.assertEqual(1, len(results)) |
2538 self.assertEqual( | 2538 self.assertEqual( |
2539 'Found line ending with white spaces in:', results[0]._message) | 2539 'Found line ending with white spaces in:', results[0]._message) |
2540 self.checkstdout('') | 2540 self.checkstdout('') |
2541 | 2541 |
2542 | 2542 |
2543 if __name__ == '__main__': | 2543 if __name__ == '__main__': |
2544 import unittest | 2544 import unittest |
2545 unittest.main() | 2545 unittest.main() |
OLD | NEW |