| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # Copyright (c) 2010 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2010 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 is too confused. | 8 # pylint is too confused. |
| 9 # pylint: disable=E1101,E1103,W0212,W0403 | 9 # pylint: disable=E1101,E1103,W0212,W0403 |
| 10 | 10 |
| (...skipping 1113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1124 input_api.python_executable = 'pyyyyython' | 1124 input_api.python_executable = 'pyyyyython' |
| 1125 return input_api | 1125 return input_api |
| 1126 | 1126 |
| 1127 def testMembersChanged(self): | 1127 def testMembersChanged(self): |
| 1128 self.mox.ReplayAll() | 1128 self.mox.ReplayAll() |
| 1129 members = [ | 1129 members = [ |
| 1130 'CheckChangeHasBugField', 'CheckChangeHasDescription', | 1130 'CheckChangeHasBugField', 'CheckChangeHasDescription', |
| 1131 'CheckChangeHasNoStrayWhitespace', | 1131 'CheckChangeHasNoStrayWhitespace', |
| 1132 'CheckChangeHasOnlyOneEol', 'CheckChangeHasNoCR', | 1132 'CheckChangeHasOnlyOneEol', 'CheckChangeHasNoCR', |
| 1133 'CheckChangeHasNoCrAndHasOnlyOneEol', 'CheckChangeHasNoTabs', | 1133 'CheckChangeHasNoCrAndHasOnlyOneEol', 'CheckChangeHasNoTabs', |
| 1134 'CheckChangeTodoHasOwner', |
| 1134 'CheckChangeHasQaField', 'CheckChangeHasTestedField', | 1135 'CheckChangeHasQaField', 'CheckChangeHasTestedField', |
| 1135 'CheckChangeHasTestField', | 1136 'CheckChangeHasTestField', |
| 1136 'CheckChangeLintsClean', | 1137 'CheckChangeLintsClean', |
| 1137 'CheckChangeSvnEolStyle', | 1138 'CheckChangeSvnEolStyle', |
| 1138 'CheckLicense', | 1139 'CheckLicense', |
| 1139 'CheckSvnModifiedDirectories', | 1140 'CheckSvnModifiedDirectories', |
| 1140 'CheckSvnForCommonMimeTypes', 'CheckSvnProperty', | 1141 'CheckSvnForCommonMimeTypes', 'CheckSvnProperty', |
| 1141 'CheckDoNotSubmit', | 1142 'CheckDoNotSubmit', |
| 1142 'CheckDoNotSubmitInDescription', 'CheckDoNotSubmitInFiles', | 1143 'CheckDoNotSubmitInDescription', 'CheckDoNotSubmitInFiles', |
| 1143 'CheckLongLines', 'CheckTreeIsOpen', 'RunPythonUnitTests', | 1144 'CheckLongLines', 'CheckTreeIsOpen', 'RunPythonUnitTests', |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1302 'DO NOTSUBMIT', 'DO NOT ' + 'SUBMIT', | 1303 'DO NOTSUBMIT', 'DO NOT ' + 'SUBMIT', |
| 1303 presubmit.OutputApi.PresubmitError) | 1304 presubmit.OutputApi.PresubmitError) |
| 1304 | 1305 |
| 1305 def testCheckChangeHasNoStrayWhitespace(self): | 1306 def testCheckChangeHasNoStrayWhitespace(self): |
| 1306 self.ContentTest( | 1307 self.ContentTest( |
| 1307 lambda x,y,z: | 1308 lambda x,y,z: |
| 1308 presubmit_canned_checks.CheckChangeHasNoStrayWhitespace(x, y), | 1309 presubmit_canned_checks.CheckChangeHasNoStrayWhitespace(x, y), |
| 1309 'Foo', 'Foo ', | 1310 'Foo', 'Foo ', |
| 1310 presubmit.OutputApi.PresubmitPromptWarning) | 1311 presubmit.OutputApi.PresubmitPromptWarning) |
| 1311 | 1312 |
| 1312 | |
| 1313 def testCheckChangeHasOnlyOneEol(self): | 1313 def testCheckChangeHasOnlyOneEol(self): |
| 1314 self.ReadFileTest(presubmit_canned_checks.CheckChangeHasOnlyOneEol, | 1314 self.ReadFileTest(presubmit_canned_checks.CheckChangeHasOnlyOneEol, |
| 1315 "Hey!\nHo!\n", "Hey!\nHo!\n\n", | 1315 "Hey!\nHo!\n", "Hey!\nHo!\n\n", |
| 1316 presubmit.OutputApi.PresubmitPromptWarning) | 1316 presubmit.OutputApi.PresubmitPromptWarning) |
| 1317 | 1317 |
| 1318 def testCheckChangeHasNoCR(self): | 1318 def testCheckChangeHasNoCR(self): |
| 1319 self.ReadFileTest(presubmit_canned_checks.CheckChangeHasNoCR, | 1319 self.ReadFileTest(presubmit_canned_checks.CheckChangeHasNoCR, |
| 1320 "Hey!\nHo!\n", "Hey!\r\nHo!\r\n", | 1320 "Hey!\nHo!\n", "Hey!\r\nHo!\r\n", |
| 1321 presubmit.OutputApi.PresubmitPromptWarning) | 1321 presubmit.OutputApi.PresubmitPromptWarning) |
| 1322 | 1322 |
| 1323 def testCheckChangeHasNoCrAndHasOnlyOneEol(self): | 1323 def testCheckChangeHasNoCrAndHasOnlyOneEol(self): |
| 1324 self.ReadFileTest( | 1324 self.ReadFileTest( |
| 1325 presubmit_canned_checks.CheckChangeHasNoCrAndHasOnlyOneEol, | 1325 presubmit_canned_checks.CheckChangeHasNoCrAndHasOnlyOneEol, |
| 1326 "Hey!\nHo!\n", "Hey!\nHo!\n\n", | 1326 "Hey!\nHo!\n", "Hey!\nHo!\n\n", |
| 1327 presubmit.OutputApi.PresubmitPromptWarning) | 1327 presubmit.OutputApi.PresubmitPromptWarning) |
| 1328 self.mox.VerifyAll() | 1328 self.mox.VerifyAll() |
| 1329 self.ReadFileTest( | 1329 self.ReadFileTest( |
| 1330 presubmit_canned_checks.CheckChangeHasNoCrAndHasOnlyOneEol, | 1330 presubmit_canned_checks.CheckChangeHasNoCrAndHasOnlyOneEol, |
| 1331 "Hey!\nHo!\n", "Hey!\r\nHo!\r\n", | 1331 "Hey!\nHo!\n", "Hey!\r\nHo!\r\n", |
| 1332 presubmit.OutputApi.PresubmitPromptWarning) | 1332 presubmit.OutputApi.PresubmitPromptWarning) |
| 1333 | 1333 |
| 1334 def testCheckChangeTodoHasOwner(self): |
| 1335 self.ContentTest(presubmit_canned_checks.CheckChangeTodoHasOwner, |
| 1336 "TODO(foo): bar", "TODO: bar", |
| 1337 presubmit.OutputApi.PresubmitPromptWarning) |
| 1338 |
| 1334 def testCannedCheckChangeHasNoTabs(self): | 1339 def testCannedCheckChangeHasNoTabs(self): |
| 1335 self.ContentTest(presubmit_canned_checks.CheckChangeHasNoTabs, | 1340 self.ContentTest(presubmit_canned_checks.CheckChangeHasNoTabs, |
| 1336 'blah blah', 'blah\tblah', | 1341 'blah blah', 'blah\tblah', |
| 1337 presubmit.OutputApi.PresubmitPromptWarning) | 1342 presubmit.OutputApi.PresubmitPromptWarning) |
| 1338 | 1343 |
| 1339 # Make sure makefiles are ignored. | 1344 # Make sure makefiles are ignored. |
| 1340 change1 = presubmit.Change('foo1', 'foo1\n', self.fake_root_dir, None, | 1345 change1 = presubmit.Change('foo1', 'foo1\n', self.fake_root_dir, None, |
| 1341 0, 0) | 1346 0, 0) |
| 1342 input_api1 = self.MockInputApi(change1, False) | 1347 input_api1 = self.MockInputApi(change1, False) |
| 1343 affected_file1 = self.mox.CreateMock(presubmit.SvnAffectedFile) | 1348 affected_file1 = self.mox.CreateMock(presubmit.SvnAffectedFile) |
| (...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1754 results = presubmit_canned_checks.CheckBuildbotPendingBuilds( | 1759 results = presubmit_canned_checks.CheckBuildbotPendingBuilds( |
| 1755 input_api, presubmit.OutputApi, 'uurl', 2, ('foo')) | 1760 input_api, presubmit.OutputApi, 'uurl', 2, ('foo')) |
| 1756 self.assertEquals(len(results), 1) | 1761 self.assertEquals(len(results), 1) |
| 1757 self.assertEquals(results[0].__class__, | 1762 self.assertEquals(results[0].__class__, |
| 1758 presubmit.OutputApi.PresubmitNotifyResult) | 1763 presubmit.OutputApi.PresubmitNotifyResult) |
| 1759 | 1764 |
| 1760 | 1765 |
| 1761 if __name__ == '__main__': | 1766 if __name__ == '__main__': |
| 1762 import unittest | 1767 import unittest |
| 1763 unittest.main() | 1768 unittest.main() |
| OLD | NEW |