Index: tests/gclient_scm_test.py |
diff --git a/tests/gclient_scm_test.py b/tests/gclient_scm_test.py |
index 03a87fd75bed19722d8db70f6fe67851ade1d4b9..d3fdc684f58ab796de2284c51ea2f547ba06c85d 100755 |
--- a/tests/gclient_scm_test.py |
+++ b/tests/gclient_scm_test.py |
@@ -115,690 +115,6 @@ class BasicTests(SuperMoxTestBase): |
SuperMoxTestBase.tearDown(self) |
-class SVNWrapperTestCase(BaseTestCase): |
- class OptionsObject(object): |
- def __init__(self, verbose=False, revision=None, force=False): |
- self.verbose = verbose |
- self.revision = revision |
- self.manually_grab_svn_rev = True |
- self.deps_os = None |
- self.force = force |
- self.reset = False |
- self.nohooks = False |
- # TODO(maruel): Test --jobs > 1. |
- self.jobs = 1 |
- self.delete_unversioned_trees = False |
- |
- def checkstdout(self, expected): |
- value = sys.stdout.getvalue() |
- sys.stdout.close() |
- # pylint: disable=E1101 |
- self.assertEquals(expected, strip_timestamps(value)) |
- |
- def Options(self, *args, **kwargs): |
- return self.OptionsObject(*args, **kwargs) |
- |
- def setUp(self): |
- BaseTestCase.setUp(self) |
- self.url = self.SvnUrl() |
- |
- def testUnsupportedSCM(self): |
- args = ['gopher://foo', self.root_dir, self.relpath] |
- exception_msg = 'No SCM found for url gopher://foo' |
- self.assertRaisesError(exception_msg, self._scm_wrapper, *args) |
- |
- def testSVNFullUrlForRelativeUrl(self): |
- self.url = 'svn://a/b/c/d' |
- |
- self.mox.ReplayAll() |
- scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, |
- relpath=self.relpath) |
- self.assertEqual(scm.FullUrlForRelativeUrl('/crap'), 'svn://a/b/crap') |
- |
- def testGITFullUrlForRelativeUrl(self): |
- self.url = 'git://a/b/c/d' |
- |
- self.mox.ReplayAll() |
- scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, |
- relpath=self.relpath) |
- self.assertEqual(scm.FullUrlForRelativeUrl('/crap'), 'git://a/b/c/crap') |
- |
- def testGITFakeHttpUrl(self): |
- self.url = 'git+http://foo' |
- |
- self.mox.ReplayAll() |
- scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, |
- relpath=self.relpath) |
- self.assertEqual(scm.url, 'http://foo') |
- |
- def testGITFakeHttpsUrl(self): |
- self.url = 'git+https://foo' |
- |
- self.mox.ReplayAll() |
- scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, |
- relpath=self.relpath) |
- self.assertEqual(scm.url, 'https://foo') |
- |
- def testRunCommandException(self): |
- options = self.Options(verbose=False) |
- gclient_scm.os.path.exists(join(self.base_path, '.hg')).AndReturn(False) |
- |
- self.mox.ReplayAll() |
- scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, |
- relpath=self.relpath) |
- exception = "Unsupported argument(s): %s" % ','.join(self.args) |
- self.assertRaisesError(exception, scm.RunCommand, |
- 'update', options, self.args) |
- |
- def testRunCommandUnknown(self): |
- # TODO(maruel): if ever used. |
- pass |
- |
- def testRevertMissing(self): |
- options = self.Options(verbose=True) |
- gclient_scm.os.path.isdir(self.base_path).AndReturn(False) |
- gclient_scm.os.path.exists(self.base_path).AndReturn(False) |
- 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, '.hg')).AndReturn(False) |
- # Checkout. |
- 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) |
- files_list = self.mox.CreateMockAnything() |
- gclient_scm.scm.SVN.RunAndGetFileList( |
- options.verbose, |
- ['checkout', self.url, self.base_path, '--force', '--ignore-externals'], |
- cwd=self.root_dir, |
- file_list=files_list) |
- |
- gclient_scm.scm.SVN._CaptureInfo([], self.base_path+'/.' |
- ).AndReturn({'Revision': 100}) |
- |
- self.mox.ReplayAll() |
- scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, |
- relpath=self.relpath) |
- scm.revert(options, self.args, files_list) |
- self.checkstdout( |
- ('_____ %s is missing, synching instead\n' % self.relpath)) |
- |
- def testRevertNoDotSvn(self): |
- 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, '.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) |
- files_list = self.mox.CreateMockAnything() |
- gclient_scm.scm.SVN.Capture(['--version', '--quiet'], None |
- ).AndReturn('1.6') |
- gclient_scm.scm.SVN.RunAndGetFileList( |
- options.verbose, |
- ['checkout', self.url, self.base_path, '--force', '--ignore-externals'], |
- cwd=self.root_dir, |
- file_list=files_list) |
- gclient_scm.gclient_utils.rmtree(self.base_path) |
- gclient_scm.scm.SVN._CaptureInfo([], self.base_path+'/.' |
- ).AndReturn({'Revision': 100}) |
- self.mox.ReplayAll() |
- scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, |
- relpath=self.relpath) |
- scm.revert(options, self.args, files_list) |
- self.checkstdout( |
- '\n_____ %s is not a valid svn checkout, synching instead\n' % |
- self.relpath) |
- |
- def testRevertNone(self): |
- options = self.Options(verbose=True) |
- gclient_scm.os.path.isdir(self.base_path).AndReturn(True) |
- gclient_scm.os.path.isdir(join(self.base_path, '.svn')).AndReturn(True) |
- gclient_scm.scm.SVN.CaptureStatus( |
- None, self.base_path, no_ignore=False).AndReturn([]) |
- gclient_scm.os.path.isdir(self.base_path).AndReturn(True) |
- gclient_scm.scm.SVN.RunAndGetFileList( |
- options.verbose, |
- ['update', '--revision', 'BASE', '--ignore-externals'], |
- cwd=self.base_path, |
- file_list=mox.IgnoreArg()) |
- |
- self.mox.ReplayAll() |
- scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, |
- relpath=self.relpath) |
- file_list = [] |
- scm.revert(options, self.args, file_list) |
- |
- def testRevertDirectory(self): |
- options = self.Options(verbose=True) |
- gclient_scm.os.path.isdir(self.base_path).AndReturn(True) |
- gclient_scm.os.path.isdir(join(self.base_path, '.svn')).AndReturn(True) |
- items = [ |
- ('~ ', 'a'), |
- ] |
- gclient_scm.scm.SVN.CaptureStatus( |
- None, self.base_path, no_ignore=False).AndReturn(items) |
- file_path = join(self.base_path, 'a') |
- gclient_scm.os.path.exists(file_path).AndReturn(True) |
- gclient_scm.os.path.isfile(file_path).AndReturn(False) |
- gclient_scm.os.path.islink(file_path).AndReturn(False) |
- gclient_scm.os.path.isdir(file_path).AndReturn(True) |
- gclient_scm.gclient_utils.rmtree(file_path) |
- gclient_scm.os.path.isdir(self.base_path).AndReturn(True) |
- gclient_scm.scm.SVN.RunAndGetFileList( |
- options.verbose, |
- ['update', '--revision', 'BASE', '--ignore-externals'], |
- cwd=self.base_path, |
- file_list=mox.IgnoreArg()) |
- |
- self.mox.ReplayAll() |
- scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, |
- relpath=self.relpath) |
- file_list2 = [] |
- scm.revert(options, self.args, file_list2) |
- self.checkstdout(('%s\n' % file_path)) |
- |
- def testRevertDot(self): |
- self.mox.StubOutWithMock(gclient_scm.SVNWrapper, 'update') |
- options = self.Options(verbose=True) |
- gclient_scm.os.path.isdir(self.base_path).AndReturn(True) |
- gclient_scm.os.path.isdir(join(self.base_path, '.svn')).AndReturn(True) |
- items = [ |
- ('~ ', '.'), |
- ] |
- gclient_scm.scm.SVN.CaptureStatus( |
- None, self.base_path, no_ignore=False).AndReturn(items) |
- # gclient_utils.rmtree() doesn't work on path ending with '.', like 'foo/.'. |
- file_path = self.base_path |
- gclient_scm.os.path.exists(file_path).AndReturn(True) |
- gclient_scm.os.path.isfile(file_path).AndReturn(False) |
- gclient_scm.os.path.islink(file_path).AndReturn(False) |
- gclient_scm.os.path.isdir(file_path).AndReturn(True) |
- gclient_scm.gclient_utils.rmtree(file_path) |
- # pylint: disable=E1120 |
- gclient_scm.os.path.isdir(self.base_path).AndReturn(False) |
- gclient_scm.SVNWrapper.update(options, [], ['.']) |
- |
- self.mox.ReplayAll() |
- scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, |
- relpath=self.relpath) |
- file_list2 = [] |
- scm.revert(options, self.args, file_list2) |
- self.checkstdout(('%s\n' % os.path.join(file_path, '.'))) |
- |
- def testStatus(self): |
- options = self.Options(verbose=True) |
- gclient_scm.os.path.isdir(self.base_path).AndReturn(True) |
- gclient_scm.scm.SVN.RunAndGetFileList( |
- options.verbose, |
- ['status'] + self.args + ['--ignore-externals'], |
- cwd=self.base_path, |
- file_list=[]).AndReturn(None) |
- |
- self.mox.ReplayAll() |
- scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, |
- relpath=self.relpath) |
- file_list = [] |
- self.assertEqual(scm.status(options, self.args, file_list), None) |
- |
- # TODO(maruel): TEST REVISIONS!!! |
- # TODO(maruel): TEST RELOCATE!!! |
- def testUpdateCheckout(self): |
- options = self.Options(verbose=True) |
- file_info = gclient_scm.gclient_utils.PrintableObject() |
- file_info.root = 'blah' |
- file_info.url = self.url |
- file_info.uuid = 'ABC' |
- file_info.revision = 42 |
- 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) |
- gclient_scm.os.path.exists(parent).AndReturn(False) |
- gclient_scm.os.makedirs(parent) |
- gclient_scm.os.path.exists(parent).AndReturn(True) |
- files_list = self.mox.CreateMockAnything() |
- gclient_scm.scm.SVN.Capture(['--version', '--quiet'], None |
- ).AndReturn('1.5.1') |
- gclient_scm.scm.SVN.RunAndGetFileList( |
- options.verbose, |
- ['checkout', self.url, self.base_path, '--force', '--ignore-externals'], |
- cwd=self.root_dir, |
- file_list=files_list) |
- gclient_scm.scm.SVN._CaptureInfo([], self.base_path+'/.' |
- ).AndReturn({'Revision': 100}) |
- self.mox.ReplayAll() |
- scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, |
- relpath=self.relpath) |
- scm.update(options, (), files_list) |
- |
- def testUpdateUpdate(self): |
- options = self.Options(verbose=True) |
- options.force = True |
- options.nohooks = False |
- file_info = { |
- 'Repository Root': 'blah', |
- 'URL': self.url, |
- 'UUID': 'ABC', |
- 'Revision': 42, |
- } |
- 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. |
- dotted_path = join(self.base_path, '.') |
- gclient_scm.scm.SVN._CaptureInfo([], dotted_path).AndReturn(file_info) |
- |
- # Verify no locked files. |
- gclient_scm.scm.SVN.CaptureStatus(None, dotted_path).AndReturn([]) |
- |
- # Cheat a bit here. |
- gclient_scm.scm.SVN._CaptureInfo([file_info['URL']], None |
- ).AndReturn(file_info) |
- |
- # _AddAdditionalUpdateFlags() |
- gclient_scm.scm.SVN.Capture(['--version', '--quiet'], None |
- ).AndReturn('1.5.1') |
- |
- gclient_scm.scm.SVN._CaptureInfo([], self.base_path+'/.' |
- ).AndReturn({'Revision': 100}) |
- |
- additional_args = [] |
- if options.manually_grab_svn_rev: |
- additional_args = ['--revision', str(file_info['Revision'])] |
- additional_args.extend(['--force', '--ignore-externals']) |
- files_list = [] |
- gclient_scm.scm.SVN.RunAndGetFileList( |
- options.verbose, |
- ['update', self.base_path] + additional_args, |
- cwd=self.root_dir, file_list=files_list) |
- |
- self.mox.ReplayAll() |
- scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, |
- relpath=self.relpath) |
- scm.update(options, (), files_list) |
- |
- def testUpdateReset(self): |
- options = self.Options(verbose=True) |
- options.reset = True |
- file_info = { |
- 'Repository Root': 'blah', |
- 'URL': self.url, |
- 'UUID': 'ABC', |
- 'Revision': 42, |
- } |
- 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. |
- dotted_path = join(self.base_path, '.') |
- gclient_scm.scm.SVN._CaptureInfo([], dotted_path).AndReturn(file_info) |
- |
- # Create an untracked file and directory. |
- gclient_scm.scm.SVN.CaptureStatus(None, dotted_path |
- ).AndReturn([['? ', 'dir'], ['? ', 'file']]) |
- |
- gclient_scm.scm.SVN._CaptureInfo([file_info['URL']], None |
- ).AndReturn(file_info) |
- |
- gclient_scm.scm.SVN._CaptureInfo([], self.base_path+'/.' |
- ).AndReturn({'Revision': 100}) |
- |
- self.mox.ReplayAll() |
- files_list = [] |
- scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, |
- relpath=self.relpath) |
- scm.update(options, (), files_list) |
- self.checkstdout('_____ %s at 42\n' % self.relpath) |
- |
- def testUpdateResetDeleteUnversionedTrees(self): |
- options = self.Options(verbose=True) |
- options.reset = True |
- options.delete_unversioned_trees = True |
- |
- file_info = { |
- 'Repository Root': 'blah', |
- 'URL': self.url, |
- 'UUID': 'ABC', |
- 'Revision': 42, |
- } |
- 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. |
- dotted_path = join(self.base_path, '.') |
- gclient_scm.scm.SVN._CaptureInfo([], dotted_path).AndReturn(file_info) |
- |
- # Create an untracked file and directory. |
- gclient_scm.scm.SVN.CaptureStatus(None, dotted_path |
- ).AndReturn([['? ', 'dir'], ['? ', 'file']]) |
- |
- gclient_scm.scm.SVN._CaptureInfo([file_info['URL']], None |
- ).AndReturn(file_info) |
- |
- # Confirm that the untracked file is removed. |
- gclient_scm.scm.SVN.CaptureStatus(None, self.base_path |
- ).AndReturn([['? ', 'dir'], ['? ', 'file']]) |
- gclient_scm.os.path.isdir(join(self.base_path, 'dir')).AndReturn(True) |
- gclient_scm.os.path.isdir(join(self.base_path, 'file')).AndReturn(False) |
- gclient_scm.os.path.islink(join(self.base_path, 'dir')).AndReturn(False) |
- gclient_scm.gclient_utils.rmtree(join(self.base_path, 'dir')) |
- |
- gclient_scm.scm.SVN._CaptureInfo([], self.base_path+'/.' |
- ).AndReturn({'Revision': 100}) |
- |
- self.mox.ReplayAll() |
- scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, |
- relpath=self.relpath) |
- files_list = [] |
- scm.update(options, (), files_list) |
- self.checkstdout( |
- ('_____ %s at 42\n' |
- '_____ removing unversioned directory dir\n') % self.relpath) |
- |
- def testUpdateSingleCheckout(self): |
- options = self.Options(verbose=True) |
- file_info = { |
- 'URL': self.url, |
- 'Revision': 42, |
- } |
- |
- # Checks to make sure that we support svn co --depth. |
- gclient_scm.scm.SVN.current_version = None |
- gclient_scm.scm.SVN.Capture(['--version', '--quiet'], None |
- ).AndReturn('1.5.1') |
- gclient_scm.os.path.exists(join(self.base_path, '.svn')).AndReturn(False) |
- gclient_scm.os.path.exists(join(self.base_path, 'DEPS')).AndReturn(False) |
- |
- # Verify no locked files. |
- dotted_path = join(self.base_path, '.') |
- gclient_scm.scm.SVN.CaptureStatus(None, dotted_path).AndReturn([]) |
- |
- # When checking out a single file, we issue an svn checkout and svn update. |
- files_list = self.mox.CreateMockAnything() |
- gclient_scm.gclient_utils.CheckCallAndFilterAndHeader( |
- ['svn', 'checkout', '--depth', 'empty', self.url, self.base_path], |
- always=True, |
- cwd=self.root_dir) |
- gclient_scm.scm.SVN.RunAndGetFileList( |
- options.verbose, |
- ['update', 'DEPS', '--ignore-externals'], |
- cwd=self.base_path, |
- file_list=files_list) |
- |
- # Now we fall back on scm.update(). |
- 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 |
- ).AndReturn(file_info) |
- |
- gclient_scm.scm.SVN._CaptureInfo([], self.base_path+'/.' |
- ).AndReturn({'Revision': 100}) |
- |
- self.mox.ReplayAll() |
- scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, |
- relpath=self.relpath) |
- scm.updatesingle(options, ['DEPS'], files_list) |
- self.checkstdout('_____ %s at 42\n' % self.relpath) |
- |
- def testUpdateSingleCheckoutSVN14(self): |
- options = self.Options(verbose=True) |
- |
- # Checks to make sure that we support svn co --depth. |
- gclient_scm.scm.SVN.current_version = None |
- gclient_scm.scm.SVN.Capture(['--version', '--quiet'], None |
- ).AndReturn('1.4.4') |
- gclient_scm.os.path.exists(self.base_path).AndReturn(True) |
- |
- # When checking out a single file with svn 1.4, we use svn export |
- files_list = self.mox.CreateMockAnything() |
- gclient_scm.gclient_utils.CheckCallAndFilterAndHeader( |
- ['svn', 'export', join(self.url, 'DEPS'), join(self.base_path, 'DEPS')], |
- always=True, cwd=self.root_dir) |
- |
- self.mox.ReplayAll() |
- scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, |
- relpath=self.relpath) |
- scm.updatesingle(options, ['DEPS'], files_list) |
- |
- def testUpdateSingleCheckoutSVNUpgrade(self): |
- options = self.Options(verbose=True) |
- file_info = { |
- 'URL': self.url, |
- 'Revision': 42, |
- } |
- |
- # Checks to make sure that we support svn co --depth. |
- gclient_scm.scm.SVN.current_version = None |
- gclient_scm.scm.SVN.Capture(['--version', '--quiet'], None |
- ).AndReturn('1.5.1') |
- gclient_scm.os.path.exists(join(self.base_path, '.svn')).AndReturn(False) |
- # If DEPS already exists, assume we're upgrading from svn1.4, so delete |
- # the old DEPS file. |
- gclient_scm.os.path.exists(join(self.base_path, 'DEPS')).AndReturn(True) |
- gclient_scm.os.remove(join(self.base_path, 'DEPS')) |
- |
- # Verify no locked files. |
- gclient_scm.scm.SVN.CaptureStatus( |
- None, join(self.base_path, '.')).AndReturn([]) |
- |
- # When checking out a single file, we issue an svn checkout and svn update. |
- files_list = self.mox.CreateMockAnything() |
- gclient_scm.gclient_utils.CheckCallAndFilterAndHeader( |
- ['svn', 'checkout', '--depth', 'empty', self.url, self.base_path], |
- always=True, |
- cwd=self.root_dir) |
- gclient_scm.scm.SVN.RunAndGetFileList( |
- options.verbose, |
- ['update', 'DEPS', '--ignore-externals'], |
- cwd=self.base_path, |
- file_list=files_list) |
- |
- # Now we fall back on scm.update(). |
- 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) |
- gclient_scm.scm.SVN._CaptureInfo([file_info['URL']], None |
- ).AndReturn(file_info) |
- |
- gclient_scm.scm.SVN._CaptureInfo([], self.base_path+'/.' |
- ).AndReturn({'Revision': 100}) |
- |
- self.mox.ReplayAll() |
- scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, |
- relpath=self.relpath) |
- scm.updatesingle(options, ['DEPS'], files_list) |
- self.checkstdout( |
- ('_____ %s at 42\n' % self.relpath)) |
- |
- def testUpdateSingleUpdate(self): |
- options = self.Options(verbose=True) |
- file_info = { |
- 'URL': self.url, |
- 'Revision': 42, |
- } |
- # Checks to make sure that we support svn co --depth. |
- gclient_scm.scm.SVN.current_version = None |
- gclient_scm.scm.SVN.Capture(['--version', '--quiet'], None |
- ).AndReturn('1.5.1') |
- gclient_scm.os.path.exists(join(self.base_path, '.svn')).AndReturn(True) |
- |
- # Verify no locked files. |
- gclient_scm.scm.SVN.CaptureStatus(None, join(self.base_path, '.') |
- ).AndReturn([]) |
- |
- # Now we fall back on scm.update(). |
- files_list = self.mox.CreateMockAnything() |
- 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) |
- gclient_scm.scm.SVN._CaptureInfo([file_info['URL']], None |
- ).AndReturn(file_info) |
- |
- gclient_scm.scm.SVN._CaptureInfo([], self.base_path+'/.' |
- ).AndReturn({'Revision': 100}) |
- |
- self.mox.ReplayAll() |
- scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, |
- relpath=self.relpath) |
- scm.updatesingle(options, ['DEPS'], files_list) |
- self.checkstdout('_____ %s at 42\n' % self.relpath) |
- |
- def testUpdateGit(self): |
- options = self.Options(verbose=True) |
- file_path = gclient_scm.os.path.join(self.root_dir, self.relpath, '.hg') |
- gclient_scm.os.path.exists(file_path).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) |
- error = gclient_scm.subprocess2.CalledProcessError( |
- 1, 'cmd', '/cwd', 'stdout', 'stderr') |
- gclient_scm.scm.SVN._CaptureInfo([], self.base_path+'/.').AndRaise(error) |
- |
- bad_scm_path = os.path.join(self.root_dir, '_bad_scm', |
- os.path.dirname(self.relpath)) |
- gclient_scm.os.makedirs(bad_scm_path) |
- dest_path = os.path.join(bad_scm_path, |
- os.path.basename(self.relpath) + 'ABCD') |
- self.mox.StubOutWithMock(gclient_scm.tempfile, 'mkdtemp', True) |
- gclient_scm.tempfile.mkdtemp( |
- prefix=os.path.basename(self.relpath), |
- dir=os.path.join(self.root_dir, '_bad_scm', |
- os.path.dirname(self.relpath))).AndReturn(dest_path) |
- self.mox.StubOutWithMock(gclient_scm.shutil, 'move', True) |
- gclient_scm.shutil.move(self.base_path, dest_path) |
- gclient_scm.os.path.exists(self.root_dir).AndReturn(True) |
- gclient_scm.scm.SVN.Capture(['--version', '--quiet'], None |
- ).AndReturn('1.5.1') |
- gclient_scm.scm.SVN.RunAndGetFileList( |
- options.verbose, |
- ['checkout', self.url, self.base_path, '--force', '--ignore-externals'], |
- cwd=self.root_dir, |
- file_list=[]) |
- |
- gclient_scm.scm.SVN._CaptureInfo([], self.base_path+'/.' |
- ).AndReturn({'Revision': 100}) |
- |
- self.mox.ReplayAll() |
- scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, |
- relpath=self.relpath) |
- scm.update(options, None, []) |
- self.checkstdout('_____ Conflicting directory found in %s. Moving to %s.\n' |
- % (self.base_path, dest_path)) |
- |
- def testUpdateGitForce(self): |
- options = self.Options(verbose=True, force=True) |
- old_environ = dict(gclient_scm.os.environ) |
- gclient_scm.os.environ['CHROME_HEADLESS'] = '1' |
- try: |
- file_path = gclient_scm.os.path.join(self.root_dir, self.relpath, '.hg') |
- gclient_scm.os.path.exists(file_path).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) |
- error = gclient_scm.subprocess2.CalledProcessError( |
- 1, 'cmd', '/cwd', 'stdout', 'stderr') |
- gclient_scm.scm.SVN._CaptureInfo([], self.base_path+'/.').AndRaise(error) |
- gclient_scm.gclient_utils.rmtree(self.base_path) |
- gclient_scm.os.path.exists(self.root_dir).AndReturn(True) |
- gclient_scm.scm.SVN.Capture(['--version', '--quiet'], None |
- ).AndReturn('1.5.1') |
- gclient_scm.scm.SVN.RunAndGetFileList( |
- options.verbose, |
- ['checkout', self.url, self.base_path, '--force', |
- '--ignore-externals'], |
- cwd=self.root_dir, |
- file_list=[]) |
- |
- gclient_scm.scm.SVN._CaptureInfo([], self.base_path+'/.' |
- ).AndReturn({'Revision': 100}) |
- |
- self.mox.ReplayAll() |
- scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, |
- relpath=self.relpath) |
- file_list = [] |
- scm.update(options, None, file_list) |
- self.checkstdout('_____ Conflicting directory found in %s. Removing.\n' |
- % self.base_path) |
- finally: |
- gclient_scm.os.environ = old_environ |
- |
- def testUpdateGitSvn(self): |
- options = self.Options(verbose=True) |
- file_path = gclient_scm.os.path.join(self.root_dir, self.relpath, '.hg') |
- gclient_scm.os.path.exists(file_path).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(True) |
- self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'Capture', True) |
- gclient_scm.scm.GIT.Capture(['config', '--local', '--get', |
- 'svn-remote.svn.url'], |
- cwd=self.base_path).AndReturn(self.url) |
- |
- self.mox.ReplayAll() |
- scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, |
- relpath=self.relpath) |
- file_list = [] |
- scm.update(options, [], file_list) |
- self.checkstdout( |
- ('\n_____ %s looks like a git-svn checkout. Skipping.\n' % self.relpath) |
- ) |
- |
- def testUpdateHg(self): |
- options = self.Options(verbose=True) |
- gclient_scm.os.path.exists(join(self.base_path, '.hg')).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 .hg directory; skipping %s\n' % self.relpath)) |
- |
- def testGetUsableRevSVN(self): |
- # pylint: disable=E1101 |
- options = self.Options(verbose=True) |
- |
- # Mock SVN revision validity checking. |
- self.mox.StubOutWithMock( |
- gclient_scm.scm.SVN, 'IsValidRevision', True) |
- gclient_scm.scm.SVN.IsValidRevision(url='%s@%s' % (self.url, 1) |
- ).AndReturn(True) |
- gclient_scm.scm.SVN.IsValidRevision(url='%s@%s' % (self.url, 'fake') |
- ).AndReturn(False) |
- |
- self.mox.ReplayAll() |
- |
- svn_scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir) |
- # With an SVN checkout, 1 an example of a valid usable rev. |
- self.assertEquals(svn_scm.GetUsableRev(1, options), 1) |
- # With an SVN checkout, a fake or unknown rev should raise an excpetion. |
- self.assertRaises(gclient_scm.gclient_utils.Error, |
- svn_scm.GetUsableRev, 'fake', options) |
- |
class BaseGitWrapperTestCase(GCBaseTestCase, StdoutCheck, TestCaseUtils, |
unittest.TestCase): |
"""This class doesn't use pymox.""" |