| 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 gclient_scm.py.""" | 6 """Unit tests for gclient_scm.py.""" |
| 7 | 7 |
| 8 # pylint: disable=E1103 | 8 # pylint: disable=E1103 |
| 9 | 9 |
| 10 # Import before super_mox to keep valid references. | 10 # Import before super_mox to keep valid references. |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 self.jobs = 1 | 89 self.jobs = 1 |
| 90 self.delete_unversioned_trees = False | 90 self.delete_unversioned_trees = False |
| 91 | 91 |
| 92 def Options(self, *args, **kwargs): | 92 def Options(self, *args, **kwargs): |
| 93 return self.OptionsObject(*args, **kwargs) | 93 return self.OptionsObject(*args, **kwargs) |
| 94 | 94 |
| 95 def setUp(self): | 95 def setUp(self): |
| 96 BaseTestCase.setUp(self) | 96 BaseTestCase.setUp(self) |
| 97 self.url = self.SvnUrl() | 97 self.url = self.SvnUrl() |
| 98 | 98 |
| 99 def testDir(self): | |
| 100 members = [ | |
| 101 'BinaryExists', | |
| 102 'FullUrlForRelativeUrl', | |
| 103 'GetCheckoutRoot', | |
| 104 'GetRevisionDate', | |
| 105 'GetUsableRev', | |
| 106 'Svnversion', | |
| 107 'RunCommand', | |
| 108 'cleanup', | |
| 109 'diff', | |
| 110 'name', | |
| 111 'pack', | |
| 112 'relpath', | |
| 113 'revert', | |
| 114 'revinfo', | |
| 115 'runhooks', | |
| 116 'status', | |
| 117 'update', | |
| 118 'updatesingle', | |
| 119 'url', | |
| 120 ] | |
| 121 | |
| 122 # If you add a member, be sure to add the relevant test! | |
| 123 self.compareMembers(self._scm_wrapper('svn://a'), members) | |
| 124 | |
| 125 def testUnsupportedSCM(self): | 99 def testUnsupportedSCM(self): |
| 126 args = ['gopher://foo', self.root_dir, self.relpath] | 100 args = ['gopher://foo', self.root_dir, self.relpath] |
| 127 exception_msg = 'No SCM found for url gopher://foo' | 101 exception_msg = 'No SCM found for url gopher://foo' |
| 128 self.assertRaisesError(exception_msg, self._scm_wrapper, *args) | 102 self.assertRaisesError(exception_msg, self._scm_wrapper, *args) |
| 129 | 103 |
| 130 def testSVNFullUrlForRelativeUrl(self): | 104 def testSVNFullUrlForRelativeUrl(self): |
| 131 self.url = 'svn://a/b/c/d' | 105 self.url = 'svn://a/b/c/d' |
| 132 | 106 |
| 133 self.mox.ReplayAll() | 107 self.mox.ReplayAll() |
| 134 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, | 108 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, |
| (...skipping 689 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 824 StdoutCheck.tearDown(self) | 798 StdoutCheck.tearDown(self) |
| 825 TestCaseUtils.tearDown(self) | 799 TestCaseUtils.tearDown(self) |
| 826 unittest.TestCase.tearDown(self) | 800 unittest.TestCase.tearDown(self) |
| 827 finally: | 801 finally: |
| 828 # TODO(maruel): Use auto_stub.TestCase. | 802 # TODO(maruel): Use auto_stub.TestCase. |
| 829 gclient_scm.GitWrapper.BinaryExists = self._original_GitBinaryExists | 803 gclient_scm.GitWrapper.BinaryExists = self._original_GitBinaryExists |
| 830 gclient_scm.SVNWrapper.BinaryExists = self._original_SVNBinaryExists | 804 gclient_scm.SVNWrapper.BinaryExists = self._original_SVNBinaryExists |
| 831 | 805 |
| 832 | 806 |
| 833 class ManagedGitWrapperTestCase(BaseGitWrapperTestCase): | 807 class ManagedGitWrapperTestCase(BaseGitWrapperTestCase): |
| 834 def testDir(self): | |
| 835 members = [ | |
| 836 'BinaryExists', | |
| 837 'FullUrlForRelativeUrl', | |
| 838 'GetCheckoutRoot', | |
| 839 'GetRevisionDate', | |
| 840 'GetUsableRev', | |
| 841 'RunCommand', | |
| 842 'cache_dir', | |
| 843 'cache_locks', | |
| 844 'cleanup', | |
| 845 'diff', | |
| 846 'name', | |
| 847 'pack', | |
| 848 'UpdateSubmoduleConfig', | |
| 849 'relpath', | |
| 850 'remote', | |
| 851 'revert', | |
| 852 'revinfo', | |
| 853 'runhooks', | |
| 854 'status', | |
| 855 'update', | |
| 856 'url', | |
| 857 ] | |
| 858 | |
| 859 # If you add a member, be sure to add the relevant test! | |
| 860 self.compareMembers(gclient_scm.CreateSCM(url=self.url), members) | |
| 861 | 808 |
| 862 def testRevertMissing(self): | 809 def testRevertMissing(self): |
| 863 if not self.enabled: | 810 if not self.enabled: |
| 864 return | 811 return |
| 865 options = self.Options() | 812 options = self.Options() |
| 866 file_path = join(self.base_path, 'a') | 813 file_path = join(self.base_path, 'a') |
| 867 scm = gclient_scm.CreateSCM(url=self.url, root_dir=self.root_dir, | 814 scm = gclient_scm.CreateSCM(url=self.url, root_dir=self.root_dir, |
| 868 relpath=self.relpath) | 815 relpath=self.relpath) |
| 869 file_list = [] | 816 file_list = [] |
| 870 scm.update(options, None, file_list) | 817 scm.update(options, None, file_list) |
| (...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1271 | 1218 |
| 1272 if __name__ == '__main__': | 1219 if __name__ == '__main__': |
| 1273 if '-v' in sys.argv: | 1220 if '-v' in sys.argv: |
| 1274 logging.basicConfig( | 1221 logging.basicConfig( |
| 1275 level=logging.DEBUG, | 1222 level=logging.DEBUG, |
| 1276 format='%(asctime).19s %(levelname)s %(filename)s:' | 1223 format='%(asctime).19s %(levelname)s %(filename)s:' |
| 1277 '%(lineno)s %(message)s') | 1224 '%(lineno)s %(message)s') |
| 1278 unittest.main() | 1225 unittest.main() |
| 1279 | 1226 |
| 1280 # vim: ts=2:sw=2:tw=80:et: | 1227 # vim: ts=2:sw=2:tw=80:et: |
| OLD | NEW |