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 703 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
714 members = [ | 714 members = [ |
715 'AbsoluteLocalPaths', 'AffectedFiles', 'AffectedSourceFiles', | 715 'AbsoluteLocalPaths', 'AffectedFiles', 'AffectedSourceFiles', |
716 'AffectedTextFiles', | 716 'AffectedTextFiles', |
717 'DEFAULT_BLACK_LIST', 'DEFAULT_WHITE_LIST', | 717 'DEFAULT_BLACK_LIST', 'DEFAULT_WHITE_LIST', |
718 'DepotToLocalPath', 'FilterSourceFile', 'LocalPaths', | 718 'DepotToLocalPath', 'FilterSourceFile', 'LocalPaths', |
719 'LocalToDepotPath', | 719 'LocalToDepotPath', |
720 'PresubmitLocalPath', 'ReadFile', 'RightHandSideLines', 'ServerPaths', | 720 'PresubmitLocalPath', 'ReadFile', 'RightHandSideLines', 'ServerPaths', |
721 'basename', 'cPickle', 'cStringIO', 'canned_checks', 'change', 'environ', | 721 'basename', 'cPickle', 'cStringIO', 'canned_checks', 'change', 'environ', |
722 'host_url', 'is_committing', 'json', 'marshal', 'os_path', | 722 'host_url', 'is_committing', 'json', 'marshal', 'os_path', |
723 'owners_db', 'pickle', 'platform', 'python_executable', 're', | 723 'owners_db', 'pickle', 'platform', 'python_executable', 're', |
724 'subprocess', 'tbr', 'tempfile', 'traceback', 'unittest', 'urllib2', | 724 'subprocess', 'tbr', 'tempfile', 'time', 'traceback', 'unittest', |
725 'version', | 725 'urllib2', 'version', |
726 ] | 726 ] |
727 # If this test fails, you should add the relevant test. | 727 # If this test fails, you should add the relevant test. |
728 self.compareMembers(presubmit.InputApi(self.fake_change, './.', False, | 728 self.compareMembers(presubmit.InputApi(self.fake_change, './.', False, |
729 False, None), | 729 False, None), |
730 members) | 730 members) |
731 | 731 |
732 def testDepotToLocalPath(self): | 732 def testDepotToLocalPath(self): |
733 presubmit.scm.SVN.CaptureInfo('svn://foo/smurf').AndReturn( | 733 presubmit.scm.SVN.CaptureInfo('svn://foo/smurf').AndReturn( |
734 {'Path': 'prout'}) | 734 {'Path': 'prout'}) |
735 presubmit.scm.SVN.CaptureInfo('svn:/foo/notfound/burp').AndReturn({}) | 735 presubmit.scm.SVN.CaptureInfo('svn:/foo/notfound/burp').AndReturn({}) |
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1240 input_api.change = change | 1240 input_api.change = change |
1241 input_api.host_url = 'http://localhost' | 1241 input_api.host_url = 'http://localhost' |
1242 input_api.is_committing = committing | 1242 input_api.is_committing = committing |
1243 input_api.tbr = False | 1243 input_api.tbr = False |
1244 input_api.python_executable = 'pyyyyython' | 1244 input_api.python_executable = 'pyyyyython' |
1245 return input_api | 1245 return input_api |
1246 | 1246 |
1247 def testMembersChanged(self): | 1247 def testMembersChanged(self): |
1248 self.mox.ReplayAll() | 1248 self.mox.ReplayAll() |
1249 members = [ | 1249 members = [ |
| 1250 'CheckBuildbotPendingBuilds', |
1250 'CheckChangeHasBugField', 'CheckChangeHasDescription', | 1251 'CheckChangeHasBugField', 'CheckChangeHasDescription', |
1251 'CheckChangeHasNoStrayWhitespace', | 1252 'CheckChangeHasNoStrayWhitespace', |
1252 'CheckChangeHasOnlyOneEol', 'CheckChangeHasNoCR', | 1253 'CheckChangeHasOnlyOneEol', 'CheckChangeHasNoCR', |
1253 'CheckChangeHasNoCrAndHasOnlyOneEol', 'CheckChangeHasNoTabs', | 1254 'CheckChangeHasNoCrAndHasOnlyOneEol', 'CheckChangeHasNoTabs', |
1254 'CheckChangeTodoHasOwner', | 1255 'CheckChangeTodoHasOwner', |
1255 'CheckChangeHasQaField', 'CheckChangeHasTestedField', | 1256 'CheckChangeHasQaField', 'CheckChangeHasTestedField', |
1256 'CheckChangeHasTestField', | 1257 'CheckChangeHasTestField', |
1257 'CheckChangeLintsClean', | 1258 'CheckChangeLintsClean', |
1258 'CheckChangeSvnEolStyle', | 1259 'CheckChangeSvnEolStyle', |
| 1260 'CheckDoNotSubmit', |
| 1261 'CheckDoNotSubmitInDescription', 'CheckDoNotSubmitInFiles', |
| 1262 'CheckLongLines', 'CheckTreeIsOpen', 'PanProjectChecks', |
1259 'CheckLicense', | 1263 'CheckLicense', |
| 1264 'CheckOwners', |
| 1265 'CheckRietveldTryJobExecution', |
1260 'CheckSvnModifiedDirectories', | 1266 'CheckSvnModifiedDirectories', |
1261 'CheckSvnForCommonMimeTypes', 'CheckSvnProperty', | 1267 'CheckSvnForCommonMimeTypes', 'CheckSvnProperty', |
1262 'CheckDoNotSubmit', | 1268 'RunPythonUnitTests', 'RunPylint', |
1263 'CheckDoNotSubmitInDescription', 'CheckDoNotSubmitInFiles', | |
1264 'CheckLongLines', 'CheckTreeIsOpen', 'RunPythonUnitTests', | |
1265 'RunPylint', | |
1266 'CheckBuildbotPendingBuilds', 'CheckRietveldTryJobExecution', | |
1267 'CheckOwners', | |
1268 ] | 1269 ] |
1269 # If this test fails, you should add the relevant test. | 1270 # If this test fails, you should add the relevant test. |
1270 self.compareMembers(presubmit_canned_checks, members) | 1271 self.compareMembers(presubmit_canned_checks, members) |
1271 | 1272 |
1272 def DescriptionTest(self, check, description1, description2, error_type, | 1273 def DescriptionTest(self, check, description1, description2, error_type, |
1273 committing): | 1274 committing): |
1274 change1 = presubmit.Change('foo1', description1, self.fake_root_dir, None, | 1275 change1 = presubmit.Change('foo1', description1, self.fake_root_dir, None, |
1275 0, 0) | 1276 0, 0) |
1276 input_api1 = self.MockInputApi(change1, committing) | 1277 input_api1 = self.MockInputApi(change1, committing) |
1277 change2 = presubmit.Change('foo2', description2, self.fake_root_dir, None, | 1278 change2 = presubmit.Change('foo2', description2, self.fake_root_dir, None, |
(...skipping 690 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1968 | 1969 |
1969 def testCannedCheckOwners_HTTPS_HostURL(self): | 1970 def testCannedCheckOwners_HTTPS_HostURL(self): |
1970 self.OwnersTest(is_committing=True, | 1971 self.OwnersTest(is_committing=True, |
1971 approvers=set(['ben@example.com']), | 1972 approvers=set(['ben@example.com']), |
1972 uncovered_files=set(), host_url='https://localhost') | 1973 uncovered_files=set(), host_url='https://localhost') |
1973 | 1974 |
1974 | 1975 |
1975 if __name__ == '__main__': | 1976 if __name__ == '__main__': |
1976 import unittest | 1977 import unittest |
1977 unittest.main() | 1978 unittest.main() |
OLD | NEW |