Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(232)

Side by Side Diff: tests/gclient_scm_test.py

Issue 8994016: [depot_tools] Disabling new git checkouts with safesync_urls until fixed. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: code review nit Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « gclient_scm.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2011 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 986 matching lines...) Expand 10 before | Expand all | Expand 10 after
997 def tearDown(self): 997 def tearDown(self):
998 BaseTestCase.tearDown(self) 998 BaseTestCase.tearDown(self)
999 999
1000 def testGetUsableRevGit(self): 1000 def testGetUsableRevGit(self):
1001 # pylint: disable=E1101 1001 # pylint: disable=E1101
1002 options = self.Options(verbose=True) 1002 options = self.Options(verbose=True)
1003 1003
1004 self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'IsValidRevision', True) 1004 self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'IsValidRevision', True)
1005 gclient_scm.scm.GIT.IsValidRevision(cwd=self.base_path, rev=self.fake_hash_1 1005 gclient_scm.scm.GIT.IsValidRevision(cwd=self.base_path, rev=self.fake_hash_1
1006 ).AndReturn(True) 1006 ).AndReturn(True)
1007 gclient_scm.scm.GIT.IsValidRevision(cwd=self.base_path, rev='1'
1008 ).AndReturn(False)
1009 1007
1010 self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'IsGitSvn', True) 1008 self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'IsGitSvn', True)
1011 gclient_scm.scm.GIT.IsGitSvn(cwd=self.base_path).MultipleTimes( 1009 gclient_scm.scm.GIT.IsGitSvn(cwd=self.base_path).MultipleTimes(
1012 ).AndReturn(False) 1010 ).AndReturn(False)
1013 1011
1012 gclient_scm.scm.os.path.isdir(self.base_path).AndReturn(True)
1013
1014 self.mox.ReplayAll() 1014 self.mox.ReplayAll()
1015 1015
1016 git_scm = gclient_scm.CreateSCM(url=self.url, root_dir=self.root_dir, 1016 git_scm = gclient_scm.CreateSCM(url=self.url, root_dir=self.root_dir,
1017 relpath=self.relpath) 1017 relpath=self.relpath)
1018 # A [fake] git sha1 with a git repo should work (this is in the case that 1018 # A [fake] git sha1 with a git repo should work (this is in the case that
1019 # the LKGR gets flipped to git sha1's some day). 1019 # the LKGR gets flipped to git sha1's some day).
1020 self.assertEquals(git_scm.GetUsableRev(self.fake_hash_1, options), 1020 self.assertEquals(git_scm.GetUsableRev(self.fake_hash_1, options),
1021 self.fake_hash_1) 1021 self.fake_hash_1)
1022 # An SVN rev with a purely git repo should raise an exception. 1022 # An SVN rev with an existing purely git repo should raise an exception.
1023 self.assertRaises(gclient_scm.gclient_utils.Error, 1023 self.assertRaises(gclient_scm.gclient_utils.Error,
1024 git_scm.GetUsableRev, '1', options) 1024 git_scm.GetUsableRev, '1', options)
1025 1025
1026 def testGetUsableRevGitSvn(self): 1026 def testGetUsableRevGitSvn(self):
1027 # pylint: disable=E1101 1027 # pylint: disable=E1101
1028 options = self.Options() 1028 options = self.Options()
1029 too_big = str(1e7) 1029 too_big = str(1e7)
1030 1030
1031 # Pretend like the git-svn repo's HEAD is at r2. 1031 # Pretend like the git-svn repo's HEAD is at r2.
1032 self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'GetGitSvnHeadRev', True) 1032 self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'GetGitSvnHeadRev', True)
(...skipping 14 matching lines...) Expand all
1047 self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'IsGitSvn', True) 1047 self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'IsGitSvn', True)
1048 gclient_scm.scm.GIT.IsGitSvn(cwd=self.base_path).MultipleTimes( 1048 gclient_scm.scm.GIT.IsGitSvn(cwd=self.base_path).MultipleTimes(
1049 ).AndReturn(True) 1049 ).AndReturn(True)
1050 1050
1051 self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'IsValidRevision', True) 1051 self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'IsValidRevision', True)
1052 gclient_scm.scm.GIT.IsValidRevision(cwd=self.base_path, rev=self.fake_hash_1 1052 gclient_scm.scm.GIT.IsValidRevision(cwd=self.base_path, rev=self.fake_hash_1
1053 ).AndReturn(True) 1053 ).AndReturn(True)
1054 gclient_scm.scm.GIT.IsValidRevision(cwd=self.base_path, rev=too_big 1054 gclient_scm.scm.GIT.IsValidRevision(cwd=self.base_path, rev=too_big
1055 ).AndReturn(False) 1055 ).AndReturn(False)
1056 1056
1057 gclient_scm.os.path.isdir(self.base_path).AndReturn(False)
1058 gclient_scm.os.path.isdir(self.base_path).MultipleTimes().AndReturn(True)
1059
1057 self.mox.ReplayAll() 1060 self.mox.ReplayAll()
1058 1061
1059 git_svn_scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, 1062 git_svn_scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir,
1060 relpath=self.relpath) 1063 relpath=self.relpath)
1064 # Without an existing checkout, this should fail. TODO(dbeam) Fix this.
1065 self.assertRaises(gclient_scm.gclient_utils.Error,
1066 git_svn_scm.GetUsableRev, '1', options)
1061 # Given an SVN revision with a git-svn checkout, it should be translated to 1067 # Given an SVN revision with a git-svn checkout, it should be translated to
1062 # a git sha1 and be usable. 1068 # a git sha1 and be usable.
1063 self.assertEquals(git_svn_scm.GetUsableRev('1', options), 1069 self.assertEquals(git_svn_scm.GetUsableRev('1', options),
1064 self.fake_hash_1) 1070 self.fake_hash_1)
1065 # Our fake HEAD rev is r2, so this should call git svn fetch to get more 1071 # Our fake HEAD rev is r2, so this should call git svn fetch to get more
1066 # revs (pymox will complain if this doesn't happen). 1072 # revs (pymox will complain if this doesn't happen).
1067 self.assertEquals(git_svn_scm.GetUsableRev('3', options), 1073 self.assertEquals(git_svn_scm.GetUsableRev('3', options),
1068 self.fake_hash_2) 1074 self.fake_hash_2)
1069 # Given a git sha1 with a git-svn checkout, it should be used as is. 1075 # Given a git sha1 with a git-svn checkout, it should be used as is.
1070 self.assertEquals(git_svn_scm.GetUsableRev(self.fake_hash_1, options), 1076 self.assertEquals(git_svn_scm.GetUsableRev(self.fake_hash_1, options),
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
1137 1143
1138 if __name__ == '__main__': 1144 if __name__ == '__main__':
1139 if '-v' in sys.argv: 1145 if '-v' in sys.argv:
1140 logging.basicConfig( 1146 logging.basicConfig(
1141 level=logging.DEBUG, 1147 level=logging.DEBUG,
1142 format='%(asctime).19s %(levelname)s %(filename)s:' 1148 format='%(asctime).19s %(levelname)s %(filename)s:'
1143 '%(lineno)s %(message)s') 1149 '%(lineno)s %(message)s')
1144 unittest.main() 1150 unittest.main()
1145 1151
1146 # vim: ts=2:sw=2:tw=80:et: 1152 # vim: ts=2:sw=2:tw=80:et:
OLDNEW
« no previous file with comments | « gclient_scm.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698