Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(160)

Side by Side Diff: tests/presubmit_unittest.py

Issue 9417023: Presubmit tests: allow 100columns limit for .java files. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools/
Patch Set: Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« presubmit_support.py ('K') | « presubmit_support.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1281 matching lines...) Expand 10 before | Expand all | Expand 10 after
1292 output.prompt_yes_no('prompt: ') 1292 output.prompt_yes_no('prompt: ')
1293 self.failIf(output.should_continue()) 1293 self.failIf(output.should_continue())
1294 self.failUnless(output.getvalue().count('???')) 1294 self.failUnless(output.getvalue().count('???'))
1295 1295
1296 1296
1297 class AffectedFileUnittest(PresubmitTestsBase): 1297 class AffectedFileUnittest(PresubmitTestsBase):
1298 def testMembersChanged(self): 1298 def testMembersChanged(self):
1299 self.mox.ReplayAll() 1299 self.mox.ReplayAll()
1300 members = [ 1300 members = [
1301 'AbsoluteLocalPath', 'Action', 'ChangedContents', 'GenerateScmDiff', 1301 'AbsoluteLocalPath', 'Action', 'ChangedContents', 'GenerateScmDiff',
1302 'IsDirectory', 'IsTextFile', 'LocalPath', 'NewContents', 'OldContents', 1302 'GetFileExt', 'IsDirectory', 'IsTextFile', 'LocalPath', 'NewContents',
1303 'OldFileTempPath', 'Property', 'ServerPath', 1303 'OldContents', 'OldFileTempPath', 'Property', 'ServerPath',
1304 ] 1304 ]
1305 # If this test fails, you should add the relevant test. 1305 # If this test fails, you should add the relevant test.
1306 self.compareMembers( 1306 self.compareMembers(
1307 presubmit.AffectedFile('a', 'b', self.fake_root_dir), members) 1307 presubmit.AffectedFile('a', 'b', self.fake_root_dir), members)
1308 self.compareMembers( 1308 self.compareMembers(
1309 presubmit.SvnAffectedFile('a', 'b', self.fake_root_dir), members) 1309 presubmit.SvnAffectedFile('a', 'b', self.fake_root_dir), members)
1310 1310
1311 def testAffectedFile(self): 1311 def testAffectedFile(self):
1312 path = presubmit.os.path.join('foo', 'blat.cc') 1312 path = presubmit.os.path.join('foo', 'blat.cc')
1313 f_path = presubmit.os.path.join(self.fake_root_dir, path) 1313 f_path = presubmit.os.path.join(self.fake_root_dir, path)
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
1491 'foo2', description2, self.fake_root_dir, None, 0, 0, None) 1491 'foo2', description2, self.fake_root_dir, None, 0, 0, None)
1492 input_api2 = self.MockInputApi(change2, committing) 1492 input_api2 = self.MockInputApi(change2, committing)
1493 self.mox.ReplayAll() 1493 self.mox.ReplayAll()
1494 1494
1495 results1 = check(input_api1, presubmit.OutputApi) 1495 results1 = check(input_api1, presubmit.OutputApi)
1496 self.assertEquals(results1, []) 1496 self.assertEquals(results1, [])
1497 results2 = check(input_api2, presubmit.OutputApi) 1497 results2 = check(input_api2, presubmit.OutputApi)
1498 self.assertEquals(len(results2), 1) 1498 self.assertEquals(len(results2), 1)
1499 self.assertEquals(results2[0].__class__, error_type) 1499 self.assertEquals(results2[0].__class__, error_type)
1500 1500
1501 def ContentTest(self, check, content1, content2, error_type): 1501 def ContentTest(self, check, content1, content1_extension, content2,
1502 content2_extension, error_type):
1502 """Runs a test of a content-checking rule. 1503 """Runs a test of a content-checking rule.
1503 1504
1504 Args: 1505 Args:
1505 check: the check to run. 1506 check: the check to run.
1506 content1: content which is expected to pass the check. 1507 content1: content which is expected to pass the check.
1508 content1_extension: file extension for content1.
1507 content2: content which is expected to fail the check. 1509 content2: content which is expected to fail the check.
1510 content2_extension: file extension for content2.
1508 error_type: the type of the error expected for content2. 1511 error_type: the type of the error expected for content2.
1509 """ 1512 """
1510 change1 = presubmit.Change( 1513 change1 = presubmit.Change(
1511 'foo1', 'foo1\n', self.fake_root_dir, None, 0, 0, None) 1514 'foo1', 'foo1\n', self.fake_root_dir, None, 0, 0, None)
1512 input_api1 = self.MockInputApi(change1, False) 1515 input_api1 = self.MockInputApi(change1, False)
1513 affected_file = self.mox.CreateMock(presubmit.SvnAffectedFile) 1516 affected_file = self.mox.CreateMock(presubmit.SvnAffectedFile)
1514 input_api1.AffectedFiles( 1517 input_api1.AffectedFiles(
1515 include_deletes=False, 1518 include_deletes=False,
1516 file_filter=mox.IgnoreArg()).AndReturn([affected_file]) 1519 file_filter=mox.IgnoreArg()).AndReturn([affected_file])
1520 affected_file.GetFileExt().AndReturn(content1_extension)
1517 affected_file.NewContents().AndReturn([ 1521 affected_file.NewContents().AndReturn([
1518 'ahoy', 1522 'afoo',
1519 content1, 1523 content1,
1520 'hay', 1524 'bfoo',
1521 'yer', 1525 'cfoo',
1522 'ya']) 1526 'dfoo'])
1523 1527
1524 change2 = presubmit.Change( 1528 change2 = presubmit.Change(
1525 'foo2', 'foo2\n', self.fake_root_dir, None, 0, 0, None) 1529 'foo2', 'foo2\n', self.fake_root_dir, None, 0, 0, None)
1526 input_api2 = self.MockInputApi(change2, False) 1530 input_api2 = self.MockInputApi(change2, False)
1527 1531
1528 input_api2.AffectedFiles( 1532 input_api2.AffectedFiles(
1529 include_deletes=False, 1533 include_deletes=False,
1530 file_filter=mox.IgnoreArg()).AndReturn([affected_file]) 1534 file_filter=mox.IgnoreArg()).AndReturn([affected_file])
1535 affected_file.GetFileExt().AndReturn(content2_extension)
1531 affected_file.NewContents().AndReturn([ 1536 affected_file.NewContents().AndReturn([
1532 'ahoy', 1537 'dfoo',
1533 content2, 1538 content2,
1534 'hay', 1539 'efoo',
1535 'yer', 1540 'ffoo',
1536 'ya']) 1541 'gfoo'])
1537 # It falls back to ChangedContents when there is a failure. This is an 1542 # It falls back to ChangedContents when there is a failure. This is an
1538 # optimization since NewContents() is much faster to execute than 1543 # optimization since NewContents() is much faster to execute than
1539 # ChangedContents(). 1544 # ChangedContents().
1540 affected_file.ChangedContents().AndReturn([ 1545 affected_file.ChangedContents().AndReturn([
1541 (42, content2), 1546 (42, content2),
1542 (43, 'yer'), 1547 (43, 'hfoo'),
1543 (23, 'ya')]) 1548 (23, 'ifoo')])
1544 affected_file.LocalPath().AndReturn('foo.cc') 1549 affected_file.LocalPath().AndReturn('foo.cc')
1545 1550
1546 self.mox.ReplayAll() 1551 self.mox.ReplayAll()
1547 1552
1548 results1 = check(input_api1, presubmit.OutputApi, None) 1553 results1 = check(input_api1, presubmit.OutputApi, None)
1549 self.assertEquals(results1, []) 1554 self.assertEquals(results1, [])
1550 results2 = check(input_api2, presubmit.OutputApi, None) 1555 results2 = check(input_api2, presubmit.OutputApi, None)
1551 self.assertEquals(len(results2), 1) 1556 self.assertEquals(len(results2), 1)
1552 self.assertEquals(results2[0].__class__, error_type) 1557 self.assertEquals(results2[0].__class__, error_type)
1553 1558
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
1656 1661
1657 def testCannedCheckDoNotSubmitInDescription(self): 1662 def testCannedCheckDoNotSubmitInDescription(self):
1658 self.DescriptionTest(presubmit_canned_checks.CheckDoNotSubmitInDescription, 1663 self.DescriptionTest(presubmit_canned_checks.CheckDoNotSubmitInDescription,
1659 'Foo\nDO NOTSUBMIT', 'Foo\nDO NOT ' + 'SUBMIT', 1664 'Foo\nDO NOTSUBMIT', 'Foo\nDO NOT ' + 'SUBMIT',
1660 presubmit.OutputApi.PresubmitError, 1665 presubmit.OutputApi.PresubmitError,
1661 False) 1666 False)
1662 1667
1663 def testCannedCheckDoNotSubmitInFiles(self): 1668 def testCannedCheckDoNotSubmitInFiles(self):
1664 self.ContentTest( 1669 self.ContentTest(
1665 lambda x,y,z: presubmit_canned_checks.CheckDoNotSubmitInFiles(x, y), 1670 lambda x,y,z: presubmit_canned_checks.CheckDoNotSubmitInFiles(x, y),
1666 'DO NOTSUBMIT', 'DO NOT ' + 'SUBMIT', 1671 'DO NOTSUBMIT', None, 'DO NOT ' + 'SUBMIT', None,
1667 presubmit.OutputApi.PresubmitError) 1672 presubmit.OutputApi.PresubmitError)
1668 1673
1669 def testCheckChangeHasNoStrayWhitespace(self): 1674 def testCheckChangeHasNoStrayWhitespace(self):
1670 self.ContentTest( 1675 self.ContentTest(
1671 lambda x,y,z: 1676 lambda x,y,z:
1672 presubmit_canned_checks.CheckChangeHasNoStrayWhitespace(x, y), 1677 presubmit_canned_checks.CheckChangeHasNoStrayWhitespace(x, y),
1673 'Foo', 'Foo ', 1678 'Foo', None, 'Foo ', None,
1674 presubmit.OutputApi.PresubmitPromptWarning) 1679 presubmit.OutputApi.PresubmitPromptWarning)
1675 1680
1676 def testCheckChangeHasOnlyOneEol(self): 1681 def testCheckChangeHasOnlyOneEol(self):
1677 self.ReadFileTest(presubmit_canned_checks.CheckChangeHasOnlyOneEol, 1682 self.ReadFileTest(presubmit_canned_checks.CheckChangeHasOnlyOneEol,
1678 "Hey!\nHo!\n", "Hey!\nHo!\n\n", 1683 "Hey!\nHo!\n", "Hey!\nHo!\n\n",
1679 presubmit.OutputApi.PresubmitPromptWarning) 1684 presubmit.OutputApi.PresubmitPromptWarning)
1680 1685
1681 def testCheckChangeHasNoCR(self): 1686 def testCheckChangeHasNoCR(self):
1682 self.ReadFileTest(presubmit_canned_checks.CheckChangeHasNoCR, 1687 self.ReadFileTest(presubmit_canned_checks.CheckChangeHasNoCR,
1683 "Hey!\nHo!\n", "Hey!\r\nHo!\r\n", 1688 "Hey!\nHo!\n", "Hey!\r\nHo!\r\n",
1684 presubmit.OutputApi.PresubmitPromptWarning) 1689 presubmit.OutputApi.PresubmitPromptWarning)
1685 1690
1686 def testCheckChangeHasNoCrAndHasOnlyOneEol(self): 1691 def testCheckChangeHasNoCrAndHasOnlyOneEol(self):
1687 self.ReadFileTest( 1692 self.ReadFileTest(
1688 presubmit_canned_checks.CheckChangeHasNoCrAndHasOnlyOneEol, 1693 presubmit_canned_checks.CheckChangeHasNoCrAndHasOnlyOneEol,
1689 "Hey!\nHo!\n", "Hey!\nHo!\n\n", 1694 "Hey!\nHo!\n", "Hey!\nHo!\n\n",
1690 presubmit.OutputApi.PresubmitPromptWarning) 1695 presubmit.OutputApi.PresubmitPromptWarning)
1691 self.mox.VerifyAll() 1696 self.mox.VerifyAll()
1692 self.ReadFileTest( 1697 self.ReadFileTest(
1693 presubmit_canned_checks.CheckChangeHasNoCrAndHasOnlyOneEol, 1698 presubmit_canned_checks.CheckChangeHasNoCrAndHasOnlyOneEol,
1694 "Hey!\nHo!\n", "Hey!\r\nHo!\r\n", 1699 "Hey!\nHo!\n", "Hey!\r\nHo!\r\n",
1695 presubmit.OutputApi.PresubmitPromptWarning) 1700 presubmit.OutputApi.PresubmitPromptWarning)
1696 1701
1697 def testCheckChangeTodoHasOwner(self): 1702 def testCheckChangeTodoHasOwner(self):
1698 self.ContentTest(presubmit_canned_checks.CheckChangeTodoHasOwner, 1703 self.ContentTest(presubmit_canned_checks.CheckChangeTodoHasOwner,
1699 "TODO(foo): bar", "TODO: bar", 1704 "TODO(foo): bar", None, "TODO: bar", None,
1700 presubmit.OutputApi.PresubmitPromptWarning) 1705 presubmit.OutputApi.PresubmitPromptWarning)
1701 1706
1702 def testCannedCheckChangeHasNoTabs(self): 1707 def testCannedCheckChangeHasNoTabs(self):
1703 self.ContentTest(presubmit_canned_checks.CheckChangeHasNoTabs, 1708 self.ContentTest(presubmit_canned_checks.CheckChangeHasNoTabs,
1704 'blah blah', 'blah\tblah', 1709 'blah blah', None, 'blah\tblah', None,
1705 presubmit.OutputApi.PresubmitPromptWarning) 1710 presubmit.OutputApi.PresubmitPromptWarning)
1706 1711
1707 # Make sure makefiles are ignored. 1712 # Make sure makefiles are ignored.
1708 change1 = presubmit.Change( 1713 change1 = presubmit.Change(
1709 'foo1', 'foo1\n', self.fake_root_dir, None, 0, 0, None) 1714 'foo1', 'foo1\n', self.fake_root_dir, None, 0, 0, None)
1710 input_api1 = self.MockInputApi(change1, False) 1715 input_api1 = self.MockInputApi(change1, False)
1711 affected_file1 = self.mox.CreateMock(presubmit.SvnAffectedFile) 1716 affected_file1 = self.mox.CreateMock(presubmit.SvnAffectedFile)
1712 affected_file1.LocalPath().AndReturn('foo.cc') 1717 affected_file1.LocalPath().AndReturn('foo.cc')
1713 affected_file2 = self.mox.CreateMock(presubmit.SvnAffectedFile) 1718 affected_file2 = self.mox.CreateMock(presubmit.SvnAffectedFile)
1714 affected_file2.LocalPath().AndReturn('foo/Makefile') 1719 affected_file2.LocalPath().AndReturn('foo/Makefile')
1715 affected_file3 = self.mox.CreateMock(presubmit.SvnAffectedFile) 1720 affected_file3 = self.mox.CreateMock(presubmit.SvnAffectedFile)
1716 affected_file3.LocalPath().AndReturn('makefile') 1721 affected_file3.LocalPath().AndReturn('makefile')
1717 # Only this one will trigger. 1722 # Only this one will trigger.
1718 affected_file4 = self.mox.CreateMock(presubmit.SvnAffectedFile) 1723 affected_file4 = self.mox.CreateMock(presubmit.SvnAffectedFile)
1719 affected_file4.LocalPath().AndReturn('makefile.foo') 1724 affected_file4.LocalPath().AndReturn('makefile.foo')
1725 affected_file1.GetFileExt().AndReturn('.foo')
1720 affected_file1.NewContents().AndReturn(['yo, ']) 1726 affected_file1.NewContents().AndReturn(['yo, '])
1727 affected_file4.GetFileExt().AndReturn('.foo')
1721 affected_file4.NewContents().AndReturn(['ye\t']) 1728 affected_file4.NewContents().AndReturn(['ye\t'])
1722 affected_file4.ChangedContents().AndReturn([(46, 'ye\t')]) 1729 affected_file4.ChangedContents().AndReturn([(46, 'ye\t')])
1723 affected_file4.LocalPath().AndReturn('makefile.foo') 1730 affected_file4.LocalPath().AndReturn('makefile.foo')
1724 affected_files = (affected_file1, affected_file2, 1731 affected_files = (affected_file1, affected_file2,
1725 affected_file3, affected_file4) 1732 affected_file3, affected_file4)
1726 1733
1727 def test(file_filter, include_deletes): 1734 def test(file_filter, include_deletes):
1728 self.assertFalse(include_deletes) 1735 self.assertFalse(include_deletes)
1729 for x in affected_files: 1736 for x in affected_files:
1730 if file_filter(x): 1737 if file_filter(x):
1731 yield x 1738 yield x
1732 # Override the mock of these functions. 1739 # Override the mock of these functions.
1733 input_api1.FilterSourceFile = lambda x: x 1740 input_api1.FilterSourceFile = lambda x: x
1734 input_api1.AffectedFiles = test 1741 input_api1.AffectedFiles = test
1735 self.mox.ReplayAll() 1742 self.mox.ReplayAll()
1736 1743
1737 results1 = presubmit_canned_checks.CheckChangeHasNoTabs(input_api1, 1744 results1 = presubmit_canned_checks.CheckChangeHasNoTabs(input_api1,
1738 presubmit.OutputApi, None) 1745 presubmit.OutputApi, None)
1739 self.assertEquals(len(results1), 1) 1746 self.assertEquals(len(results1), 1)
1740 self.assertEquals(results1[0].__class__, 1747 self.assertEquals(results1[0].__class__,
1741 presubmit.OutputApi.PresubmitPromptWarning) 1748 presubmit.OutputApi.PresubmitPromptWarning)
1742 self.assertEquals(results1[0]._long_text, 1749 self.assertEquals(results1[0]._long_text,
1743 'makefile.foo, line 46') 1750 'makefile.foo, line 46')
1744 1751
1745 def testCannedCheckLongLines(self): 1752 def testCannedCheckLongLines(self):
1746 check = lambda x, y, z: presubmit_canned_checks.CheckLongLines(x, y, 10, z) 1753 check = lambda x, y, z: presubmit_canned_checks.CheckLongLines(x, y, 10, z)
1747 self.ContentTest(check, '0123456789', '01234567890', 1754 self.ContentTest(check, '0123456789', None, '01234567890', None,
1755 presubmit.OutputApi.PresubmitPromptWarning)
1756
1757 def testCannedCheckJavaLongLines(self):
1758 check = lambda x, y, _: presubmit_canned_checks.CheckLongLines(x, y)
1759 self.ContentTest(check, 'A ' * 50, '.java', 'A ' * 50 + 'B', '.java',
1748 presubmit.OutputApi.PresubmitPromptWarning) 1760 presubmit.OutputApi.PresubmitPromptWarning)
1749 1761
1750 def testCannedCheckLongLinesLF(self): 1762 def testCannedCheckLongLinesLF(self):
1751 check = lambda x, y, z: presubmit_canned_checks.CheckLongLines(x, y, 10, z) 1763 check = lambda x, y, z: presubmit_canned_checks.CheckLongLines(x, y, 10, z)
1752 self.ContentTest(check, '012345678\n', '0123456789\n', 1764 self.ContentTest(check, '012345678\n', None, '0123456789\n', None,
1753 presubmit.OutputApi.PresubmitPromptWarning) 1765 presubmit.OutputApi.PresubmitPromptWarning)
1754 1766
1755 def testCannedCheckLongLinesMacro(self): 1767 def testCannedCheckLongLinesMacro(self):
1756 check = lambda x, y, z: presubmit_canned_checks.CheckLongLines(x, y, 10, z) 1768 check = lambda x, y, z: presubmit_canned_checks.CheckLongLines(x, y, 10, z)
1757 self.ContentTest( 1769 self.ContentTest(
1758 check, 1770 check,
1759 # Put a space in so it doesn't trigger long symbols. Allow 1/3 more. 1771 # Put a space in so it doesn't trigger long symbols. Allow 1/3 more.
1760 '#if 56 89 12 45', 1772 '#if 56 89 12 45',
1773 None,
1761 '#if 56 89 12 456', 1774 '#if 56 89 12 456',
1775 None,
1762 presubmit.OutputApi.PresubmitPromptWarning) 1776 presubmit.OutputApi.PresubmitPromptWarning)
1763 1777
1764 def testCannedCheckLongLinesHttp(self): 1778 def testCannedCheckLongLinesHttp(self):
1765 check = lambda x, y, z: presubmit_canned_checks.CheckLongLines(x, y, 10, z) 1779 check = lambda x, y, z: presubmit_canned_checks.CheckLongLines(x, y, 10, z)
1766 self.ContentTest( 1780 self.ContentTest(
1767 check, 1781 check,
1768 ' http:// 0 23 5', 1782 ' http:// 0 23 5',
1783 None,
1769 ' http:// 0 23 56', 1784 ' http:// 0 23 56',
1785 None,
1770 presubmit.OutputApi.PresubmitPromptWarning) 1786 presubmit.OutputApi.PresubmitPromptWarning)
1771 1787
1772 def testCannedCheckLongLinesLongSymbol(self): 1788 def testCannedCheckLongLinesLongSymbol(self):
1773 check = lambda x, y, z: presubmit_canned_checks.CheckLongLines(x, y, 10, z) 1789 check = lambda x, y, z: presubmit_canned_checks.CheckLongLines(x, y, 10, z)
1774 self.ContentTest( 1790 self.ContentTest(
1775 check, 1791 check,
1776 ' TUP5D_LoNG_SY ', 1792 ' TUP5D_LoNG_SY ',
1793 None,
1777 ' TUP5D_LoNG_SY5 ', 1794 ' TUP5D_LoNG_SY5 ',
1795 None,
1778 presubmit.OutputApi.PresubmitPromptWarning) 1796 presubmit.OutputApi.PresubmitPromptWarning)
1779 1797
1780 def testCheckChangeSvnEolStyleCommit(self): 1798 def testCheckChangeSvnEolStyleCommit(self):
1781 # Test CheckSvnProperty at the same time. 1799 # Test CheckSvnProperty at the same time.
1782 self.SvnPropertyTest(presubmit_canned_checks.CheckChangeSvnEolStyle, 1800 self.SvnPropertyTest(presubmit_canned_checks.CheckChangeSvnEolStyle,
1783 'svn:eol-style', 'LF', '', True, 1801 'svn:eol-style', 'LF', '', True,
1784 presubmit.OutputApi.PresubmitError, True) 1802 presubmit.OutputApi.PresubmitError, True)
1785 1803
1786 def testCheckChangeSvnEolStyleUpload(self): 1804 def testCheckChangeSvnEolStyleUpload(self):
1787 self.SvnPropertyTest(presubmit_canned_checks.CheckChangeSvnEolStyle, 1805 self.SvnPropertyTest(presubmit_canned_checks.CheckChangeSvnEolStyle,
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after
2250 2268
2251 def testPanProjectChecks(self): 2269 def testPanProjectChecks(self):
2252 # Make sure it accepts both list and tuples. 2270 # Make sure it accepts both list and tuples.
2253 change = presubmit.Change( 2271 change = presubmit.Change(
2254 'foo1', 'description1', self.fake_root_dir, None, 0, 0, None) 2272 'foo1', 'description1', self.fake_root_dir, None, 0, 0, None)
2255 input_api = self.MockInputApi(change, False) 2273 input_api = self.MockInputApi(change, False)
2256 affected_file = self.mox.CreateMock(presubmit.SvnAffectedFile) 2274 affected_file = self.mox.CreateMock(presubmit.SvnAffectedFile)
2257 for _ in range(3): 2275 for _ in range(3):
2258 input_api.AffectedFiles(file_filter=mox.IgnoreArg(), include_deletes=False 2276 input_api.AffectedFiles(file_filter=mox.IgnoreArg(), include_deletes=False
2259 ).AndReturn([affected_file]) 2277 ).AndReturn([affected_file])
2278 affected_file.GetFileExt()
2260 affected_file.NewContents().AndReturn('Hey!\nHo!\nHey!\nHo!\n\n') 2279 affected_file.NewContents().AndReturn('Hey!\nHo!\nHey!\nHo!\n\n')
2261 affected_file.ChangedContents().AndReturn([ 2280 affected_file.ChangedContents().AndReturn([
2262 (0, 'Hey!\n'), 2281 (0, 'Hey!\n'),
2263 (1, 'Ho!\n'), 2282 (1, 'Ho!\n'),
2264 (2, 'Hey!\n'), 2283 (2, 'Hey!\n'),
2265 (3, 'Ho!\n'), 2284 (3, 'Ho!\n'),
2266 (4, '\n')]) 2285 (4, '\n')])
2267 for _ in range(5): 2286 for _ in range(5):
2268 affected_file.LocalPath().AndReturn('hello.py') 2287 affected_file.LocalPath().AndReturn('hello.py')
2269 input_api.AffectedSourceFiles(mox.IgnoreArg()).AndReturn([affected_file]) 2288 input_api.AffectedSourceFiles(mox.IgnoreArg()).AndReturn([affected_file])
(...skipping 13 matching lines...) Expand all
2283 owners_check=True) 2302 owners_check=True)
2284 self.assertEqual(1, len(results)) 2303 self.assertEqual(1, len(results))
2285 self.assertEqual( 2304 self.assertEqual(
2286 'Found line ending with white spaces in:', results[0]._message) 2305 'Found line ending with white spaces in:', results[0]._message)
2287 self.checkstdout('') 2306 self.checkstdout('')
2288 2307
2289 2308
2290 if __name__ == '__main__': 2309 if __name__ == '__main__':
2291 import unittest 2310 import unittest
2292 unittest.main() 2311 unittest.main()
OLDNEW
« presubmit_support.py ('K') | « presubmit_support.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698