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 782 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
793 self.relpath = '.' | 793 self.relpath = '.' |
794 self.base_path = join(self.root_dir, self.relpath) | 794 self.base_path = join(self.root_dir, self.relpath) |
795 self.enabled = self.CreateGitRepo(self.sample_git_import, self.base_path) | 795 self.enabled = self.CreateGitRepo(self.sample_git_import, self.base_path) |
796 StdoutCheck.setUp(self) | 796 StdoutCheck.setUp(self) |
797 self._original_GitBinaryExists = gclient_scm.GitWrapper.BinaryExists | 797 self._original_GitBinaryExists = gclient_scm.GitWrapper.BinaryExists |
798 self._original_SVNBinaryExists = gclient_scm.SVNWrapper.BinaryExists | 798 self._original_SVNBinaryExists = gclient_scm.SVNWrapper.BinaryExists |
799 gclient_scm.GitWrapper.BinaryExists = staticmethod(lambda : True) | 799 gclient_scm.GitWrapper.BinaryExists = staticmethod(lambda : True) |
800 gclient_scm.SVNWrapper.BinaryExists = staticmethod(lambda : True) | 800 gclient_scm.SVNWrapper.BinaryExists = staticmethod(lambda : True) |
801 | 801 |
802 def tearDown(self): | 802 def tearDown(self): |
803 StdoutCheck.tearDown(self) | 803 try: |
804 TestCaseUtils.tearDown(self) | 804 rmtree(self.root_dir) |
805 unittest.TestCase.tearDown(self) | 805 StdoutCheck.tearDown(self) |
806 rmtree(self.root_dir) | 806 TestCaseUtils.tearDown(self) |
807 gclient_scm.GitWrapper.BinaryExists = self._original_GitBinaryExists | 807 unittest.TestCase.tearDown(self) |
808 gclient_scm.SVNWrapper.BinaryExists = self._original_SVNBinaryExists | 808 finally: |
| 809 # TODO(maruel): Use auto_stub.TestCase. |
| 810 gclient_scm.GitWrapper.BinaryExists = self._original_GitBinaryExists |
| 811 gclient_scm.SVNWrapper.BinaryExists = self._original_SVNBinaryExists |
| 812 |
809 | 813 |
810 class ManagedGitWrapperTestCase(BaseGitWrapperTestCase): | 814 class ManagedGitWrapperTestCase(BaseGitWrapperTestCase): |
811 def testDir(self): | 815 def testDir(self): |
812 members = [ | 816 members = [ |
813 'BinaryExists', | 817 'BinaryExists', |
814 'FullUrlForRelativeUrl', | 818 'FullUrlForRelativeUrl', |
815 'GetCheckoutRoot', | 819 'GetCheckoutRoot', |
816 'GetRevisionDate', | 820 'GetRevisionDate', |
817 'GetUsableRev', | 821 'GetUsableRev', |
818 'RunCommand', | 822 'RunCommand', |
819 'cache_dir', | 823 'cache_dir', |
820 'cache_locks', | 824 'cache_locks', |
821 'cleanup', | 825 'cleanup', |
822 'diff', | 826 'diff', |
823 'name', | 827 'name', |
824 'pack', | 828 'pack', |
825 'UpdateSubmoduleConfig', | 829 'UpdateSubmoduleConfig', |
826 'relpath', | 830 'relpath', |
| 831 'remote', |
827 'revert', | 832 'revert', |
828 'revinfo', | 833 'revinfo', |
829 'runhooks', | 834 'runhooks', |
830 'status', | 835 'status', |
831 'update', | 836 'update', |
832 'url', | 837 'url', |
833 ] | 838 ] |
834 | 839 |
835 # If you add a member, be sure to add the relevant test! | 840 # If you add a member, be sure to add the relevant test! |
836 self.compareMembers(gclient_scm.CreateSCM(url=self.url), members) | 841 self.compareMembers(gclient_scm.CreateSCM(url=self.url), members) |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1032 scm = gclient_scm.CreateSCM(url=self.url, root_dir=self.root_dir, | 1037 scm = gclient_scm.CreateSCM(url=self.url, root_dir=self.root_dir, |
1033 relpath=self.relpath) | 1038 relpath=self.relpath) |
1034 file_path = join(self.base_path, 'b') | 1039 file_path = join(self.base_path, 'b') |
1035 open(file_path, 'w').writelines('conflict\n') | 1040 open(file_path, 'w').writelines('conflict\n') |
1036 scm._Run(['commit', '-am', 'test'], options) | 1041 scm._Run(['commit', '-am', 'test'], options) |
1037 __builtin__.raw_input = lambda x: 'y' | 1042 __builtin__.raw_input = lambda x: 'y' |
1038 exception = ('Conflict while rebasing this branch.\n' | 1043 exception = ('Conflict while rebasing this branch.\n' |
1039 'Fix the conflict and run gclient again.\n' | 1044 'Fix the conflict and run gclient again.\n' |
1040 'See \'man git-rebase\' for details.\n') | 1045 'See \'man git-rebase\' for details.\n') |
1041 self.assertRaisesError(exception, scm.update, options, (), []) | 1046 self.assertRaisesError(exception, scm.update, options, (), []) |
1042 exception = ('\n____ . at refs/heads/master\n' | 1047 exception = ('\n____ . at refs/remotes/origin/master\n' |
1043 '\tYou have unstaged changes.\n' | 1048 '\tYou have unstaged changes.\n' |
1044 '\tPlease commit, stash, or reset.\n') | 1049 '\tPlease commit, stash, or reset.\n') |
1045 self.assertRaisesError(exception, scm.update, options, (), []) | 1050 self.assertRaisesError(exception, scm.update, options, (), []) |
1046 sys.stdout.close() | 1051 sys.stdout.close() |
1047 | 1052 |
1048 def testRevinfo(self): | 1053 def testRevinfo(self): |
1049 if not self.enabled: | 1054 if not self.enabled: |
1050 return | 1055 return |
1051 options = self.Options() | 1056 options = self.Options() |
1052 scm = gclient_scm.CreateSCM(url=self.url, root_dir=self.root_dir, | 1057 scm = gclient_scm.CreateSCM(url=self.url, root_dir=self.root_dir, |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1200 | 1205 |
1201 if __name__ == '__main__': | 1206 if __name__ == '__main__': |
1202 if '-v' in sys.argv: | 1207 if '-v' in sys.argv: |
1203 logging.basicConfig( | 1208 logging.basicConfig( |
1204 level=logging.DEBUG, | 1209 level=logging.DEBUG, |
1205 format='%(asctime).19s %(levelname)s %(filename)s:' | 1210 format='%(asctime).19s %(levelname)s %(filename)s:' |
1206 '%(lineno)s %(message)s') | 1211 '%(lineno)s %(message)s') |
1207 unittest.main() | 1212 unittest.main() |
1208 | 1213 |
1209 # vim: ts=2:sw=2:tw=80:et: | 1214 # vim: ts=2:sw=2:tw=80:et: |
OLD | NEW |