Chromium Code Reviews| Index: tests/presubmit_unittest.py |
| diff --git a/tests/presubmit_unittest.py b/tests/presubmit_unittest.py |
| index d8f186b5cd3e75e510db31fcaa71ed22f1d3a30a..cc799fa9683586a4585826893ac17b8b421f2821 100755 |
| --- a/tests/presubmit_unittest.py |
| +++ b/tests/presubmit_unittest.py |
| @@ -37,6 +37,47 @@ def GetPreferredTrySlaves(): |
| return %s |
| """ |
| + presubmit_diffs = """ |
| +--- /tmp/file1 2011-02-08 21:35:31.998479201 -0800 |
| ++++ /tmp/file2 2011-02-08 21:36:50.487240201 -0800 |
| +@@ -1,6 +1,5 @@ |
| + this is line number 0 |
| + this is line number 1 |
| +-this is line number 2 to be deleted |
| + this is line number 3 |
| + this is line number 4 |
| + this is line number 5 |
| +@@ -8,7 +7,7 @@ |
| + this is line number 7 |
| + this is line number 8 |
| + this is line number 9 |
| +-this is line number 10 to be modified |
| ++this is line number 10 |
| + this is line number 11 |
| + this is line number 12 |
| + this is line number 13 |
| +@@ -21,9 +20,8 @@ |
| + this is line number 20 |
| + this is line number 21 |
| + this is line number 22 |
| +-this is line number 23 |
| +-this is line number 24 |
| +-this is line number 25 |
| ++this is line number 23.1 |
| ++this is line number 25.1 |
| + this is line number 26 |
| + this is line number 27 |
| + this is line number 28 |
| +@@ -31,6 +29,7 @@ |
| + this is line number 30 |
| + this is line number 31 |
| + this is line number 32 |
| ++this is line number 32.1 |
|
M-A Ruel
2011/02/09 18:30:26
Add a
+
on a single line to verify my concern abou
vb
2011/02/09 18:54:11
Done.
|
| + this is line number 33 |
| + this is line number 34 |
| + this is line number 35 |
| +""" |
| + |
| def setUp(self): |
| SuperMoxTestBase.setUp(self) |
| self.mox.StubOutWithMock(presubmit, 'random') |
| @@ -56,6 +97,7 @@ def GetPreferredTrySlaves(): |
| self.mox.StubOutWithMock(presubmit.scm.SVN, 'GetFileProperty') |
| self.mox.StubOutWithMock(presubmit.gclient_utils, 'FileRead') |
| self.mox.StubOutWithMock(presubmit.gclient_utils, 'FileWrite') |
| + self.mox.StubOutWithMock(presubmit.scm.SVN, 'GenerateDiff') |
| class PresubmitUnittest(PresubmitTestsBase): |
| @@ -197,8 +239,9 @@ class PresubmitUnittest(PresubmitTestsBase): |
| presubmit.scm.SVN.CaptureInfo(notfound).AndReturn({}) |
| presubmit.scm.SVN.CaptureInfo(flap).AndReturn( |
| {'URL': 'svn:/foo/boo/flap.h'}) |
| - presubmit.gclient_utils.FileRead(blat, 'rU').AndReturn('boo!\nahh?') |
| - presubmit.gclient_utils.FileRead(notfound, 'rU').AndReturn('look!\nthere?') |
| + presubmit.scm.SVN.GenerateDiff(blat).AndReturn(self.presubmit_diffs) |
| + presubmit.scm.SVN.GenerateDiff(notfound).AndReturn(self.presubmit_diffs) |
| + |
| self.mox.ReplayAll() |
| change = presubmit.SvnChange('mychange', '\n'.join(description_lines), |
| @@ -242,20 +285,20 @@ class PresubmitUnittest(PresubmitTestsBase): |
| for line in change.RightHandSideLines(): |
| rhs_lines.append(line) |
| self.assertEquals(rhs_lines[0][0].LocalPath(), files[0][1]) |
| - self.assertEquals(rhs_lines[0][1], 1) |
| - self.assertEquals(rhs_lines[0][2],'boo!') |
| + self.assertEquals(rhs_lines[0][1], 10) |
| + self.assertEquals(rhs_lines[0][2],'this is line number 10') |
| - self.assertEquals(rhs_lines[1][0].LocalPath(), files[0][1]) |
| - self.assertEquals(rhs_lines[1][1], 2) |
| - self.assertEquals(rhs_lines[1][2], 'ahh?') |
| + self.assertEquals(rhs_lines[3][0].LocalPath(), files[0][1]) |
| + self.assertEquals(rhs_lines[3][1], 32) |
| + self.assertEquals(rhs_lines[3][2], 'this is line number 32.1') |
| - self.assertEquals(rhs_lines[2][0].LocalPath(), files[3][1]) |
| - self.assertEquals(rhs_lines[2][1], 1) |
| - self.assertEquals(rhs_lines[2][2], 'look!') |
| + self.assertEquals(rhs_lines[5][0].LocalPath(), files[3][1]) |
| + self.assertEquals(rhs_lines[5][1], 23) |
| + self.assertEquals(rhs_lines[5][2], 'this is line number 23.1') |
| - self.assertEquals(rhs_lines[3][0].LocalPath(), files[3][1]) |
| - self.assertEquals(rhs_lines[3][1], 2) |
| - self.assertEquals(rhs_lines[3][2], 'there?') |
| + self.assertEquals(rhs_lines[6][0].LocalPath(), files[3][1]) |
| + self.assertEquals(rhs_lines[6][1], 24) |
| + self.assertEquals(rhs_lines[6][2], 'this is line number 25.1') |
| def testExecPresubmitScript(self): |
| description_lines = ('Hello there', |
| @@ -711,10 +754,9 @@ class InputApiUnittest(PresubmitTestsBase): |
| presubmit.scm.SVN.GetFileProperty(another, 'svn:mime-type').AndReturn(None) |
| presubmit.scm.SVN.GetFileProperty(third_party, 'svn:mime-type' |
| ).AndReturn(None) |
| - presubmit.gclient_utils.FileRead(blat, 'rU' |
| - ).AndReturn('whatever\ncookie') |
| - presubmit.gclient_utils.FileRead(another, 'rU' |
| - ).AndReturn('whatever\ncookie2') |
| + presubmit.scm.SVN.GenerateDiff(blat).AndReturn(self.presubmit_diffs) |
| + presubmit.scm.SVN.GenerateDiff(another).AndReturn(self.presubmit_diffs) |
| + |
| self.mox.ReplayAll() |
| change = presubmit.SvnChange('mychange', '\n'.join(description_lines), |
| @@ -737,14 +779,14 @@ class InputApiUnittest(PresubmitTestsBase): |
| # binary isn't a text file and beingdeleted doesn't exist. The rest is |
| # outside foo/. |
| rhs_lines = [x for x in input_api.RightHandSideLines(None)] |
| - self.assertEquals(len(rhs_lines), 4) |
| + self.assertEquals(len(rhs_lines), 8) |
| self.assertEqual(rhs_lines[0][0].LocalPath(), |
| presubmit.normpath(files[0][1])) |
| - self.assertEqual(rhs_lines[1][0].LocalPath(), |
| + self.assertEqual(rhs_lines[3][0].LocalPath(), |
| presubmit.normpath(files[0][1])) |
| - self.assertEqual(rhs_lines[2][0].LocalPath(), |
| + self.assertEqual(rhs_lines[4][0].LocalPath(), |
| presubmit.normpath(files[4][1])) |
| - self.assertEqual(rhs_lines[3][0].LocalPath(), |
| + self.assertEqual(rhs_lines[7][0].LocalPath(), |
| presubmit.normpath(files[4][1])) |
| def testDefaultWhiteListBlackListFilters(self): |
| @@ -1018,11 +1060,13 @@ class AffectedFileUnittest(PresubmitTestsBase): |
| def testMembersChanged(self): |
| self.mox.ReplayAll() |
| members = [ |
| - 'AbsoluteLocalPath', 'Action', 'IsDirectory', 'IsTextFile', 'LocalPath', |
| - 'NewContents', 'OldContents', 'OldFileTempPath', 'Property', 'ServerPath', |
| + 'AbsoluteLocalPath', 'Action', 'ChangedContents', 'IsDirectory', |
| + 'IsTextFile', 'LocalPath', 'NewContents', 'OldContents', |
| + 'OldFileTempPath', 'Property', 'ServerPath', |
| ] |
| # If this test fails, you should add the relevant test. |
| self.compareMembers(presubmit.AffectedFile('a', 'b'), members) |
| + members.append('GenerateScmDiff') |
| self.compareMembers(presubmit.SvnAffectedFile('a', 'b'), members) |
| def testAffectedFile(self): |