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

Unified Diff: tests/gclient_scm_test.py

Issue 133073015: Re-reland r245404 ("If the destination directory doesn't contain the desired repo, delete it") (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Clean up check_output call, print hostname on bots Created 6 years, 10 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « scm.py ('k') | tests/gclient_smoketest.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/gclient_scm_test.py
diff --git a/tests/gclient_scm_test.py b/tests/gclient_scm_test.py
index 741727e34f69c58b42145616866fff6377fae95c..65d5a405e46fbf08a4b0f0f39ab31d3e8fb8effc 100755
--- a/tests/gclient_scm_test.py
+++ b/tests/gclient_scm_test.py
@@ -101,6 +101,7 @@ class SVNWrapperTestCase(BaseTestCase):
'BinaryExists',
'FullUrlForRelativeUrl',
'GetCheckoutRoot',
+ 'GetRemoteURL',
'GetRevisionDate',
'GetUsableRev',
'Svnversion',
@@ -161,9 +162,9 @@ class SVNWrapperTestCase(BaseTestCase):
def testRunCommandException(self):
options = self.Options(verbose=False)
- gclient_scm.os.path.exists(join(self.base_path, '.git')).AndReturn(False)
- gclient_scm.os.path.exists(join(self.base_path, '.hg')).AndReturn(False)
-
+ gclient_scm.os.path.exists(self.base_path).AndReturn(True)
+ self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'IsGitSvn', True)
+ gclient_scm.scm.GIT.IsGitSvn(self.base_path).AndReturn(False)
self.mox.ReplayAll()
scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir,
relpath=self.relpath)
@@ -182,8 +183,6 @@ class SVNWrapperTestCase(BaseTestCase):
gclient_scm.scm.SVN.Capture(['--version', '--quiet'], None
).AndReturn('1.5.1')
# It'll to a checkout instead.
- gclient_scm.os.path.exists(join(self.base_path, '.git')).AndReturn(False)
- gclient_scm.os.path.exists(join(self.base_path, '.hg')).AndReturn(False)
# Checkout.
gclient_scm.os.path.exists(self.base_path).AndReturn(False)
parent = gclient_scm.os.path.dirname(self.base_path)
@@ -211,16 +210,14 @@ class SVNWrapperTestCase(BaseTestCase):
options = self.Options(verbose=True, force=True)
gclient_scm.os.path.isdir(self.base_path).AndReturn(True)
gclient_scm.os.path.isdir(join(self.base_path, '.svn')).AndReturn(False)
- gclient_scm.os.path.isdir(join(self.base_path, '.git')).AndReturn(False)
- gclient_scm.os.path.isdir(join(self.base_path, '.hg')).AndReturn(False)
# Checkout.
- gclient_scm.os.path.exists(join(self.base_path, '.git')).AndReturn(False)
- gclient_scm.os.path.exists(join(self.base_path, '.hg')).AndReturn(False)
gclient_scm.os.path.exists(self.base_path).AndReturn(False)
parent = gclient_scm.os.path.dirname(self.base_path)
gclient_scm.os.path.exists(parent).AndReturn(False)
gclient_scm.os.makedirs(parent)
gclient_scm.os.path.exists(parent).AndReturn(True)
+ self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'IsGitSvn', True)
+ gclient_scm.scm.GIT.IsGitSvn(self.base_path).AndReturn(False)
files_list = self.mox.CreateMockAnything()
gclient_scm.scm.SVN.Capture(['--version', '--quiet'], None
).AndReturn('1.6')
@@ -340,8 +337,6 @@ class SVNWrapperTestCase(BaseTestCase):
file_info.url = self.url
file_info.uuid = 'ABC'
file_info.revision = 42
- gclient_scm.os.path.exists(join(self.base_path, '.git')).AndReturn(False)
- gclient_scm.os.path.exists(join(self.base_path, '.hg')).AndReturn(False)
# Checkout.
gclient_scm.os.path.exists(self.base_path).AndReturn(False)
parent = gclient_scm.os.path.dirname(self.base_path)
@@ -373,8 +368,8 @@ class SVNWrapperTestCase(BaseTestCase):
'UUID': 'ABC',
'Revision': 42,
}
- gclient_scm.os.path.exists(join(self.base_path, '.git')).AndReturn(False)
- gclient_scm.os.path.exists(join(self.base_path, '.hg')).AndReturn(False)
+ self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'IsGitSvn', True)
+ gclient_scm.scm.GIT.IsGitSvn(self.base_path).AndReturn(False)
gclient_scm.os.path.exists(self.base_path).AndReturn(True)
# Checkout or update.
@@ -419,8 +414,8 @@ class SVNWrapperTestCase(BaseTestCase):
'UUID': 'ABC',
'Revision': 42,
}
- gclient_scm.os.path.exists(join(self.base_path, '.git')).AndReturn(False)
- gclient_scm.os.path.exists(join(self.base_path, '.hg')).AndReturn(False)
+ self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'IsGitSvn', True)
+ gclient_scm.scm.GIT.IsGitSvn(self.base_path).AndReturn(False)
gclient_scm.os.path.exists(self.base_path).AndReturn(True)
# Checkout or update.
@@ -455,8 +450,8 @@ class SVNWrapperTestCase(BaseTestCase):
'UUID': 'ABC',
'Revision': 42,
}
- gclient_scm.os.path.exists(join(self.base_path, '.git')).AndReturn(False)
- gclient_scm.os.path.exists(join(self.base_path, '.hg')).AndReturn(False)
+ self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'IsGitSvn', True)
+ gclient_scm.scm.GIT.IsGitSvn(self.base_path).AndReturn(False)
gclient_scm.os.path.exists(self.base_path).AndReturn(True)
# Checkout or update.
@@ -521,8 +516,8 @@ class SVNWrapperTestCase(BaseTestCase):
file_list=files_list)
# Now we fall back on scm.update().
- gclient_scm.os.path.exists(join(self.base_path, '.git')).AndReturn(False)
- gclient_scm.os.path.exists(join(self.base_path, '.hg')).AndReturn(False)
+ self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'IsGitSvn', True)
+ gclient_scm.scm.GIT.IsGitSvn(self.base_path).AndReturn(False)
gclient_scm.os.path.exists(self.base_path).AndReturn(True)
gclient_scm.scm.SVN._CaptureInfo([], dotted_path).AndReturn(file_info)
gclient_scm.scm.SVN._CaptureInfo([file_info['URL']], None
@@ -591,8 +586,8 @@ class SVNWrapperTestCase(BaseTestCase):
file_list=files_list)
# Now we fall back on scm.update().
- gclient_scm.os.path.exists(join(self.base_path, '.git')).AndReturn(False)
- gclient_scm.os.path.exists(join(self.base_path, '.hg')).AndReturn(False)
+ self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'IsGitSvn', True)
+ gclient_scm.scm.GIT.IsGitSvn(self.base_path).AndReturn(False)
gclient_scm.os.path.exists(self.base_path).AndReturn(True)
gclient_scm.scm.SVN._CaptureInfo(
[], join(self.base_path, ".")).AndReturn(file_info)
@@ -627,8 +622,8 @@ class SVNWrapperTestCase(BaseTestCase):
# Now we fall back on scm.update().
files_list = self.mox.CreateMockAnything()
- gclient_scm.os.path.exists(join(self.base_path, '.git')).AndReturn(False)
- gclient_scm.os.path.exists(join(self.base_path, '.hg')).AndReturn(False)
+ self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'IsGitSvn', True)
+ gclient_scm.scm.GIT.IsGitSvn(self.base_path).AndReturn(False)
gclient_scm.os.path.exists(self.base_path).AndReturn(True)
gclient_scm.scm.SVN._CaptureInfo(
[], join(self.base_path, '.')).AndReturn(file_info)
@@ -644,23 +639,11 @@ class SVNWrapperTestCase(BaseTestCase):
scm.updatesingle(options, ['DEPS'], files_list)
self.checkstdout('\n_____ %s at 42\n' % self.relpath)
- def testUpdateGit(self):
+ def testUpdateGitSvn(self):
options = self.Options(verbose=True)
- file_path = gclient_scm.os.path.join(self.root_dir, self.relpath, '.git')
- gclient_scm.os.path.exists(file_path).AndReturn(True)
-
- self.mox.ReplayAll()
- scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir,
- relpath=self.relpath)
- file_list = []
- scm.update(options, self.args, file_list)
- self.checkstdout(
- ('________ found .git directory; skipping %s\n' % self.relpath))
-
- def testUpdateHg(self):
- options = self.Options(verbose=True)
- gclient_scm.os.path.exists(join(self.base_path, '.git')).AndReturn(False)
- gclient_scm.os.path.exists(join(self.base_path, '.hg')).AndReturn(True)
+ gclient_scm.os.path.exists(self.base_path).AndReturn(True)
+ self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'IsGitSvn', True)
+ gclient_scm.scm.GIT.IsGitSvn(self.base_path).AndReturn(True)
self.mox.ReplayAll()
scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir,
@@ -668,7 +651,7 @@ class SVNWrapperTestCase(BaseTestCase):
file_list = []
scm.update(options, self.args, file_list)
self.checkstdout(
- ('________ found .hg directory; skipping %s\n' % self.relpath))
+ ('________ %s looks like git-svn; skipping.\n' % self.relpath))
def testGetUsableRevSVN(self):
# pylint: disable=E1101
@@ -691,6 +674,48 @@ class SVNWrapperTestCase(BaseTestCase):
self.assertRaises(gclient_scm.gclient_utils.Error,
svn_scm.GetUsableRev, 'fake', options)
+ def testGetRemoteURL(self):
+ self.mox.UnsetStubs()
+ options = self.Options(verbose=True)
+ self.mox.StubOutWithMock(gclient_scm.scm.SVN, 'Capture', True)
+ svn_scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir,
+ relpath=self.relpath)
+
+ if svn_scm.relpath:
+ cwd = os.path.join(svn_scm._root_dir, svn_scm.relpath)
+ else:
+ cwd = svn_scm._root_dir
+
+ gclient_scm.scm.SVN.Capture(['info', '--xml', os.curdir], cwd).AndReturn(
+"""<?xml version="1.0"?>
+<info>
+<entry
+ path="."
+ revision="1234"
+ kind="dir">
+<url>%s</url>
+<repository>
+<root>https://dummy.repo.com/svn</root>
+<uuid>FAKE</uuid>
+</repository>
+<wc-info>
+<schedule>normal</schedule>
+<depth>infinity</depth>
+</wc-info>
+<commit
+ revision="1234">
+<author>fakedev@chromium.org</author>
+<date>2013-11-14T15:08:21.757885Z</date>
+</commit>
+</entry>
+</info>
+""" % svn_scm.url)
+
+ self.mox.ReplayAll()
+
+ self.assertEquals(svn_scm.GetRemoteURL(options), self.url)
+
+
class BaseGitWrapperTestCase(GCBaseTestCase, StdoutCheck, TestCaseUtils,
unittest.TestCase):
"""This class doesn't use pymox."""
@@ -836,6 +861,7 @@ class ManagedGitWrapperTestCase(BaseGitWrapperTestCase):
'BinaryExists',
'FullUrlForRelativeUrl',
'GetCheckoutRoot',
+ 'GetRemoteURL',
'GetRevisionDate',
'GetUsableRev',
'RunCommand',
@@ -1162,7 +1188,7 @@ class ManagedGitWrapperTestCaseMox(BaseTestCase):
).AndReturn(True)
self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'IsGitSvn', True)
- gclient_scm.scm.GIT.IsGitSvn(cwd=self.base_path).MultipleTimes(
+ gclient_scm.scm.GIT.IsGitSvn(self.base_path).MultipleTimes(
).AndReturn(False)
gclient_scm.scm.os.path.isdir(self.base_path).AndReturn(True)
@@ -1211,7 +1237,7 @@ class ManagedGitWrapperTestCaseMox(BaseTestCase):
gclient_scm.scm.GIT.Capture(['fetch', 'origin'], cwd=self.base_path)
self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'IsGitSvn', True)
- gclient_scm.scm.GIT.IsGitSvn(cwd=self.base_path).MultipleTimes(
+ gclient_scm.scm.GIT.IsGitSvn(self.base_path).MultipleTimes(
).AndReturn(True)
self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'IsValidRevision', True)
@@ -1251,6 +1277,18 @@ class ManagedGitWrapperTestCaseMox(BaseTestCase):
self.assertRaises(gclient_scm.gclient_utils.Error,
git_svn_scm.GetUsableRev, too_big, options)
+ def testGetRemoteURL(self):
+ options = self.Options(verbose=True)
+ self.mox.StubOutWithMock(gclient_scm.GitWrapper, '_Capture', True)
+ git_scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir,
+ relpath=self.relpath)
+ git_scm._Capture(['config', 'remote.origin.url'], cwd='/tmp/fake'
+ ).AndReturn('%s\n' % git_scm.url)
+
+ self.mox.ReplayAll()
+
+ self.assertEquals(git_scm.GetRemoteURL(options), self.url)
+
class UnmanagedGitWrapperTestCase(BaseGitWrapperTestCase):
def testUpdateUpdate(self):
« no previous file with comments | « scm.py ('k') | tests/gclient_smoketest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698