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 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 _INHERIT_SETTINGS = 'inherit-review-settings-ok' | 154 _INHERIT_SETTINGS = 'inherit-review-settings-ok' |
155 | 155 |
156 def testMembersChanged(self): | 156 def testMembersChanged(self): |
157 self.mox.ReplayAll() | 157 self.mox.ReplayAll() |
158 members = [ | 158 members = [ |
159 'AffectedFile', 'Change', 'DoGetTrySlaves', 'DoPresubmitChecks', | 159 'AffectedFile', 'Change', 'DoGetTrySlaves', 'DoPresubmitChecks', |
160 'GetTrySlavesExecuter', 'GitAffectedFile', | 160 'GetTrySlavesExecuter', 'GitAffectedFile', |
161 'GitChange', 'InputApi', 'ListRelevantPresubmitFiles', 'Main', | 161 'GitChange', 'InputApi', 'ListRelevantPresubmitFiles', 'Main', |
162 'NonexistantCannedCheckFilter', 'OutputApi', 'ParseFiles', | 162 'NonexistantCannedCheckFilter', 'OutputApi', 'ParseFiles', |
163 'PresubmitFailure', 'PresubmitExecuter', 'PresubmitOutput', 'ScanSubDirs', | 163 'PresubmitFailure', 'PresubmitExecuter', 'PresubmitOutput', 'ScanSubDirs', |
164 'SvnAffectedFile', 'SvnChange', 'cPickle', 'cStringIO', 'contextlib', | 164 'SvnAffectedFile', 'SvnChange', 'cPickle', 'cpplint', 'cStringIO', |
165 'canned_check_filter', 'fix_encoding', 'fnmatch', 'gclient_utils', 'glob', | 165 'contextlib', 'canned_check_filter', 'fix_encoding', 'fnmatch', |
166 'inspect', 'json', 'load_files', | 166 'gclient_utils', 'glob', 'inspect', 'json', 'load_files', 'logging', |
167 'logging', 'marshal', 'normpath', 'optparse', 'os', 'owners', 'pickle', | 167 'marshal', 'normpath', 'optparse', 'os', 'owners', 'pickle', |
168 'presubmit_canned_checks', 'random', 're', 'rietveld', 'scm', | 168 'presubmit_canned_checks', 'random', 're', 'rietveld', 'scm', |
169 'subprocess', | 169 'subprocess', 'sys', 'tempfile', 'time', 'traceback', 'types', 'unittest', |
170 'sys', 'tempfile', 'time', 'traceback', 'types', 'unittest', 'urllib2', | 170 'urllib2', 'warn', |
171 'warn', | |
172 ] | 171 ] |
173 # If this test fails, you should add the relevant test. | 172 # If this test fails, you should add the relevant test. |
174 self.compareMembers(presubmit, members) | 173 self.compareMembers(presubmit, members) |
175 | 174 |
176 def testCannedCheckFilter(self): | 175 def testCannedCheckFilter(self): |
177 canned = presubmit.presubmit_canned_checks | 176 canned = presubmit.presubmit_canned_checks |
178 orig = canned.CheckOwners | 177 orig = canned.CheckOwners |
179 with presubmit.canned_check_filter(['CheckOwners']): | 178 with presubmit.canned_check_filter(['CheckOwners']): |
180 self.assertNotEqual(canned.CheckOwners, orig) | 179 self.assertNotEqual(canned.CheckOwners, orig) |
181 self.assertEqual(canned.CheckOwners(None, None), []) | 180 self.assertEqual(canned.CheckOwners(None, None), []) |
(...skipping 695 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
877 """Tests presubmit.InputApi.""" | 876 """Tests presubmit.InputApi.""" |
878 def testMembersChanged(self): | 877 def testMembersChanged(self): |
879 self.mox.ReplayAll() | 878 self.mox.ReplayAll() |
880 members = [ | 879 members = [ |
881 'AbsoluteLocalPaths', 'AffectedFiles', 'AffectedSourceFiles', | 880 'AbsoluteLocalPaths', 'AffectedFiles', 'AffectedSourceFiles', |
882 'AffectedTextFiles', | 881 'AffectedTextFiles', |
883 'DEFAULT_BLACK_LIST', 'DEFAULT_WHITE_LIST', | 882 'DEFAULT_BLACK_LIST', 'DEFAULT_WHITE_LIST', |
884 'DepotToLocalPath', 'FilterSourceFile', 'LocalPaths', | 883 'DepotToLocalPath', 'FilterSourceFile', 'LocalPaths', |
885 'LocalToDepotPath', | 884 'LocalToDepotPath', |
886 'PresubmitLocalPath', 'ReadFile', 'RightHandSideLines', 'ServerPaths', | 885 'PresubmitLocalPath', 'ReadFile', 'RightHandSideLines', 'ServerPaths', |
887 'basename', 'cPickle', 'cStringIO', 'canned_checks', 'change', 'environ', | 886 'basename', 'cPickle', 'cpplint', 'cStringIO', 'canned_checks', 'change', |
888 'glob', 'host_url', 'is_committing', 'json', 'logging', 'marshal', | 887 'environ', 'glob', 'host_url', 'is_committing', 'json', 'logging', |
889 'os_listdir', 'os_walk', | 888 'marshal', 'os_listdir', 'os_walk', 'os_path', 'owners_db', 'pickle', |
890 'os_path', 'owners_db', 'pickle', 'platform', 'python_executable', 're', | 889 'platform', 'python_executable', 're', 'rietveld', 'subprocess', 'tbr', |
891 'rietveld', 'subprocess', 'tbr', 'tempfile', 'time', 'traceback', | 890 'tempfile', 'time', 'traceback', 'unittest', 'urllib2', 'version', |
892 'unittest', 'urllib2', 'version', 'verbose', | 891 'verbose', |
893 ] | 892 ] |
894 # If this test fails, you should add the relevant test. | 893 # If this test fails, you should add the relevant test. |
895 self.compareMembers( | 894 self.compareMembers( |
896 presubmit.InputApi(self.fake_change, './.', False, None, False), | 895 presubmit.InputApi(self.fake_change, './.', False, None, False), |
897 members) | 896 members) |
898 | 897 |
899 def testDepotToLocalPath(self): | 898 def testDepotToLocalPath(self): |
900 presubmit.scm.SVN._CaptureInfo(['svn://foo/smurf'], self.fake_root_dir | 899 presubmit.scm.SVN._CaptureInfo(['svn://foo/smurf'], self.fake_root_dir |
901 ).AndReturn({'Path': 'prout'}) | 900 ).AndReturn({'Path': 'prout'}) |
902 presubmit.scm.SVN._CaptureInfo( | 901 presubmit.scm.SVN._CaptureInfo( |
(...skipping 1633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2536 owners_check=False) | 2535 owners_check=False) |
2537 self.assertEqual(1, len(results)) | 2536 self.assertEqual(1, len(results)) |
2538 self.assertEqual( | 2537 self.assertEqual( |
2539 'Found line ending with white spaces in:', results[0]._message) | 2538 'Found line ending with white spaces in:', results[0]._message) |
2540 self.checkstdout('') | 2539 self.checkstdout('') |
2541 | 2540 |
2542 | 2541 |
2543 if __name__ == '__main__': | 2542 if __name__ == '__main__': |
2544 import unittest | 2543 import unittest |
2545 unittest.main() | 2544 unittest.main() |
OLD | NEW |