| 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 | 48 |
| 49 | 49 |
| 50 class BaseTestCase(GCBaseTestCase, SuperMoxTestBase): | 50 class BaseTestCase(GCBaseTestCase, SuperMoxTestBase): |
| 51 def setUp(self): | 51 def setUp(self): |
| 52 SuperMoxTestBase.setUp(self) | 52 SuperMoxTestBase.setUp(self) |
| 53 self.mox.StubOutWithMock(gclient_scm.gclient_utils, 'CheckCallAndFilter') | 53 self.mox.StubOutWithMock(gclient_scm.gclient_utils, 'CheckCallAndFilter') |
| 54 self.mox.StubOutWithMock(gclient_scm.gclient_utils, | 54 self.mox.StubOutWithMock(gclient_scm.gclient_utils, |
| 55 'CheckCallAndFilterAndHeader') | 55 'CheckCallAndFilterAndHeader') |
| 56 self.mox.StubOutWithMock(gclient_scm.gclient_utils, 'FileRead') | 56 self.mox.StubOutWithMock(gclient_scm.gclient_utils, 'FileRead') |
| 57 self.mox.StubOutWithMock(gclient_scm.gclient_utils, 'FileWrite') | 57 self.mox.StubOutWithMock(gclient_scm.gclient_utils, 'FileWrite') |
| 58 self.mox.StubOutWithMock(gclient_scm.gclient_utils, 'FindCommandExecutable') | |
| 59 self.mox.StubOutWithMock(gclient_scm.gclient_utils, 'RemoveDirectory') | 58 self.mox.StubOutWithMock(gclient_scm.gclient_utils, 'RemoveDirectory') |
| 60 self.mox.StubOutWithMock(gclient_scm.scm.SVN, 'Capture') | 59 self.mox.StubOutWithMock(gclient_scm.scm.SVN, 'Capture') |
| 61 self.mox.StubOutWithMock(gclient_scm.scm.SVN, '_CaptureInfo') | 60 self.mox.StubOutWithMock(gclient_scm.scm.SVN, '_CaptureInfo') |
| 62 self.mox.StubOutWithMock(gclient_scm.scm.SVN, 'CaptureStatus') | 61 self.mox.StubOutWithMock(gclient_scm.scm.SVN, 'CaptureStatus') |
| 63 self.mox.StubOutWithMock(gclient_scm.scm.SVN, 'RunAndGetFileList') | 62 self.mox.StubOutWithMock(gclient_scm.scm.SVN, 'RunAndGetFileList') |
| 64 self.mox.StubOutWithMock(subprocess2, 'communicate') | 63 self.mox.StubOutWithMock(subprocess2, 'communicate') |
| 65 self.mox.StubOutWithMock(subprocess2, 'Popen') | 64 self.mox.StubOutWithMock(subprocess2, 'Popen') |
| 66 self._scm_wrapper = gclient_scm.CreateSCM | 65 self._scm_wrapper = gclient_scm.CreateSCM |
| 67 gclient_scm.scm.SVN.current_version = None | 66 gclient_scm.scm.SVN.current_version = None |
| 68 # Absolute path of the fake checkout directory. | 67 # Absolute path of the fake checkout directory. |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 'relpath', | 104 'relpath', |
| 106 'revert', | 105 'revert', |
| 107 'revinfo', | 106 'revinfo', |
| 108 'runhooks', | 107 'runhooks', |
| 109 'status', | 108 'status', |
| 110 'update', | 109 'update', |
| 111 'updatesingle', | 110 'updatesingle', |
| 112 'url', | 111 'url', |
| 113 ] | 112 ] |
| 114 | 113 |
| 115 gclient_scm.gclient_utils.FindCommandExecutable('svn').AndReturn("./svn") | |
| 116 self.mox.ReplayAll() | |
| 117 | |
| 118 # If you add a member, be sure to add the relevant test! | 114 # If you add a member, be sure to add the relevant test! |
| 119 self.compareMembers(self._scm_wrapper('svn://a'), members) | 115 self.compareMembers(self._scm_wrapper('svn://a'), members) |
| 120 | 116 |
| 121 def testUnsupportedSCM(self): | 117 def testUnsupportedSCM(self): |
| 122 args = ['gopher://foo', self.root_dir, self.relpath] | 118 args = ['gopher://foo', self.root_dir, self.relpath] |
| 123 exception_msg = 'No SCM found for url gopher://foo' | 119 exception_msg = 'No SCM found for url gopher://foo' |
| 124 self.assertRaisesError(exception_msg, self._scm_wrapper, *args) | 120 self.assertRaisesError(exception_msg, self._scm_wrapper, *args) |
| 125 | 121 |
| 126 def testSVNFullUrlForRelativeUrl(self): | 122 def testSVNFullUrlForRelativeUrl(self): |
| 127 self.url = 'svn://a/b/c/d' | 123 self.url = 'svn://a/b/c/d' |
| 128 | 124 |
| 129 gclient_scm.gclient_utils.FindCommandExecutable('svn').AndReturn("./svn") | |
| 130 self.mox.ReplayAll() | 125 self.mox.ReplayAll() |
| 131 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, | 126 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, |
| 132 relpath=self.relpath) | 127 relpath=self.relpath) |
| 133 self.assertEqual(scm.FullUrlForRelativeUrl('/crap'), 'svn://a/b/crap') | 128 self.assertEqual(scm.FullUrlForRelativeUrl('/crap'), 'svn://a/b/crap') |
| 134 | 129 |
| 135 def testGITFullUrlForRelativeUrl(self): | 130 def testGITFullUrlForRelativeUrl(self): |
| 136 self.url = 'git://a/b/c/d' | 131 self.url = 'git://a/b/c/d' |
| 137 | 132 |
| 138 gclient_scm.gclient_utils.FindCommandExecutable('git').AndReturn("./git") | |
| 139 self.mox.ReplayAll() | 133 self.mox.ReplayAll() |
| 140 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, | 134 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, |
| 141 relpath=self.relpath) | 135 relpath=self.relpath) |
| 142 self.assertEqual(scm.FullUrlForRelativeUrl('/crap'), 'git://a/b/c/crap') | 136 self.assertEqual(scm.FullUrlForRelativeUrl('/crap'), 'git://a/b/c/crap') |
| 143 | 137 |
| 144 def testGITFakeHttpUrl(self): | 138 def testGITFakeHttpUrl(self): |
| 145 self.url = 'git+http://foo' | 139 self.url = 'git+http://foo' |
| 146 | 140 |
| 147 gclient_scm.gclient_utils.FindCommandExecutable('git').AndReturn("./git") | |
| 148 self.mox.ReplayAll() | 141 self.mox.ReplayAll() |
| 149 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, | 142 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, |
| 150 relpath=self.relpath) | 143 relpath=self.relpath) |
| 151 self.assertEqual(scm.url, 'http://foo') | 144 self.assertEqual(scm.url, 'http://foo') |
| 152 | 145 |
| 153 def testGITFakeHttpsUrl(self): | 146 def testGITFakeHttpsUrl(self): |
| 154 self.url = 'git+https://foo' | 147 self.url = 'git+https://foo' |
| 155 | 148 |
| 156 gclient_scm.gclient_utils.FindCommandExecutable('git').AndReturn("./git") | |
| 157 self.mox.ReplayAll() | 149 self.mox.ReplayAll() |
| 158 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, | 150 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, |
| 159 relpath=self.relpath) | 151 relpath=self.relpath) |
| 160 self.assertEqual(scm.url, 'https://foo') | 152 self.assertEqual(scm.url, 'https://foo') |
| 161 | 153 |
| 162 def testRunCommandException(self): | 154 def testRunCommandException(self): |
| 163 options = self.Options(verbose=False) | 155 options = self.Options(verbose=False) |
| 164 gclient_scm.os.path.exists(join(self.base_path, '.git')).AndReturn(False) | 156 gclient_scm.os.path.exists(join(self.base_path, '.git')).AndReturn(False) |
| 165 gclient_scm.os.path.exists(join(self.base_path, '.hg')).AndReturn(False) | 157 gclient_scm.os.path.exists(join(self.base_path, '.hg')).AndReturn(False) |
| 166 gclient_scm.gclient_utils.FindCommandExecutable('svn').AndReturn("./svn") | |
| 167 | 158 |
| 168 self.mox.ReplayAll() | 159 self.mox.ReplayAll() |
| 169 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, | 160 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, |
| 170 relpath=self.relpath) | 161 relpath=self.relpath) |
| 171 exception = "Unsupported argument(s): %s" % ','.join(self.args) | 162 exception = "Unsupported argument(s): %s" % ','.join(self.args) |
| 172 self.assertRaisesError(exception, scm.RunCommand, | 163 self.assertRaisesError(exception, scm.RunCommand, |
| 173 'update', options, self.args) | 164 'update', options, self.args) |
| 174 | 165 |
| 175 def testRunCommandUnknown(self): | 166 def testRunCommandUnknown(self): |
| 176 # TODO(maruel): if ever used. | 167 # TODO(maruel): if ever used. |
| 177 pass | 168 pass |
| 178 | 169 |
| 179 def testRevertMissing(self): | 170 def testRevertMissing(self): |
| 180 options = self.Options(verbose=True) | 171 options = self.Options(verbose=True) |
| 181 gclient_scm.gclient_utils.FindCommandExecutable('svn').AndReturn("./svn") | |
| 182 gclient_scm.os.path.isdir(self.base_path).AndReturn(False) | 172 gclient_scm.os.path.isdir(self.base_path).AndReturn(False) |
| 183 gclient_scm.os.path.exists(self.base_path).AndReturn(False) | 173 gclient_scm.os.path.exists(self.base_path).AndReturn(False) |
| 184 gclient_scm.scm.SVN.Capture(['--version'], None | 174 gclient_scm.scm.SVN.Capture(['--version'], None |
| 185 ).AndReturn('svn, version 1.5.1 (r32289)') | 175 ).AndReturn('svn, version 1.5.1 (r32289)') |
| 186 # It'll to a checkout instead. | 176 # It'll to a checkout instead. |
| 187 gclient_scm.os.path.exists(join(self.base_path, '.git')).AndReturn(False) | 177 gclient_scm.os.path.exists(join(self.base_path, '.git')).AndReturn(False) |
| 188 gclient_scm.os.path.exists(join(self.base_path, '.hg')).AndReturn(False) | 178 gclient_scm.os.path.exists(join(self.base_path, '.hg')).AndReturn(False) |
| 189 # Checkout. | 179 # Checkout. |
| 190 gclient_scm.os.path.exists(self.base_path).AndReturn(False) | 180 gclient_scm.os.path.exists(self.base_path).AndReturn(False) |
| 191 parent = gclient_scm.os.path.dirname(self.base_path) | 181 parent = gclient_scm.os.path.dirname(self.base_path) |
| (...skipping 22 matching lines...) Expand all Loading... |
| 214 gclient_scm.os.path.isdir(join(self.base_path, '.hg')).AndReturn(False) | 204 gclient_scm.os.path.isdir(join(self.base_path, '.hg')).AndReturn(False) |
| 215 # Checkout. | 205 # Checkout. |
| 216 gclient_scm.os.path.exists(self.base_path).AndReturn(False) | 206 gclient_scm.os.path.exists(self.base_path).AndReturn(False) |
| 217 gclient_scm.os.path.exists(join(self.base_path, '.git')).AndReturn(False) | 207 gclient_scm.os.path.exists(join(self.base_path, '.git')).AndReturn(False) |
| 218 gclient_scm.os.path.exists(join(self.base_path, '.hg')).AndReturn(False) | 208 gclient_scm.os.path.exists(join(self.base_path, '.hg')).AndReturn(False) |
| 219 gclient_scm.os.path.exists(self.base_path).AndReturn(False) | 209 gclient_scm.os.path.exists(self.base_path).AndReturn(False) |
| 220 parent = gclient_scm.os.path.dirname(self.base_path) | 210 parent = gclient_scm.os.path.dirname(self.base_path) |
| 221 gclient_scm.os.path.exists(parent).AndReturn(False) | 211 gclient_scm.os.path.exists(parent).AndReturn(False) |
| 222 gclient_scm.os.makedirs(parent) | 212 gclient_scm.os.makedirs(parent) |
| 223 gclient_scm.os.path.exists(parent).AndReturn(True) | 213 gclient_scm.os.path.exists(parent).AndReturn(True) |
| 224 gclient_scm.gclient_utils.FindCommandExecutable('svn').AndReturn("./svn") | |
| 225 files_list = self.mox.CreateMockAnything() | 214 files_list = self.mox.CreateMockAnything() |
| 226 gclient_scm.scm.SVN.Capture(['--version'], None | 215 gclient_scm.scm.SVN.Capture(['--version'], None |
| 227 ).AndReturn('svn, version 1.6') | 216 ).AndReturn('svn, version 1.6') |
| 228 gclient_scm.scm.SVN.RunAndGetFileList( | 217 gclient_scm.scm.SVN.RunAndGetFileList( |
| 229 options.verbose, | 218 options.verbose, |
| 230 ['checkout', self.url, self.base_path, '--force', '--ignore-externals'], | 219 ['checkout', self.url, self.base_path, '--force', '--ignore-externals'], |
| 231 cwd=self.root_dir, | 220 cwd=self.root_dir, |
| 232 file_list=files_list) | 221 file_list=files_list) |
| 233 | 222 |
| 234 self.mox.ReplayAll() | 223 self.mox.ReplayAll() |
| 235 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, | 224 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, |
| 236 relpath=self.relpath) | 225 relpath=self.relpath) |
| 237 scm.revert(options, self.args, files_list) | 226 scm.revert(options, self.args, files_list) |
| 238 self.checkstdout( | 227 self.checkstdout( |
| 239 '\n_____ %s is not a valid svn checkout, synching instead\n' % | 228 '\n_____ %s is not a valid svn checkout, synching instead\n' % |
| 240 self.relpath) | 229 self.relpath) |
| 241 | 230 |
| 242 def testRevertNone(self): | 231 def testRevertNone(self): |
| 243 options = self.Options(verbose=True) | 232 options = self.Options(verbose=True) |
| 244 gclient_scm.gclient_utils.FindCommandExecutable('svn').AndReturn("./svn") | |
| 245 gclient_scm.os.path.isdir(self.base_path).AndReturn(True) | 233 gclient_scm.os.path.isdir(self.base_path).AndReturn(True) |
| 246 gclient_scm.os.path.isdir(join(self.base_path, '.svn')).AndReturn(True) | 234 gclient_scm.os.path.isdir(join(self.base_path, '.svn')).AndReturn(True) |
| 247 gclient_scm.scm.SVN.CaptureStatus(None, self.base_path).AndReturn([]) | 235 gclient_scm.scm.SVN.CaptureStatus(None, self.base_path).AndReturn([]) |
| 248 gclient_scm.os.path.isdir(self.base_path).AndReturn(True) | 236 gclient_scm.os.path.isdir(self.base_path).AndReturn(True) |
| 249 gclient_scm.scm.SVN.RunAndGetFileList( | 237 gclient_scm.scm.SVN.RunAndGetFileList( |
| 250 options.verbose, | 238 options.verbose, |
| 251 ['update', '--revision', 'BASE', '--ignore-externals'], | 239 ['update', '--revision', 'BASE', '--ignore-externals'], |
| 252 cwd=self.base_path, | 240 cwd=self.base_path, |
| 253 file_list=mox.IgnoreArg()) | 241 file_list=mox.IgnoreArg()) |
| 254 | 242 |
| 255 self.mox.ReplayAll() | 243 self.mox.ReplayAll() |
| 256 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, | 244 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, |
| 257 relpath=self.relpath) | 245 relpath=self.relpath) |
| 258 file_list = [] | 246 file_list = [] |
| 259 scm.revert(options, self.args, file_list) | 247 scm.revert(options, self.args, file_list) |
| 260 | 248 |
| 261 def testRevertDirectory(self): | 249 def testRevertDirectory(self): |
| 262 options = self.Options(verbose=True) | 250 options = self.Options(verbose=True) |
| 263 gclient_scm.os.path.isdir(self.base_path).AndReturn(True) | 251 gclient_scm.os.path.isdir(self.base_path).AndReturn(True) |
| 264 gclient_scm.os.path.isdir(join(self.base_path, '.svn')).AndReturn(True) | 252 gclient_scm.os.path.isdir(join(self.base_path, '.svn')).AndReturn(True) |
| 265 gclient_scm.gclient_utils.FindCommandExecutable('svn').AndReturn("./svn") | |
| 266 items = [ | 253 items = [ |
| 267 ('~ ', 'a'), | 254 ('~ ', 'a'), |
| 268 ] | 255 ] |
| 269 gclient_scm.scm.SVN.CaptureStatus(None, self.base_path).AndReturn(items) | 256 gclient_scm.scm.SVN.CaptureStatus(None, self.base_path).AndReturn(items) |
| 270 file_path = join(self.base_path, 'a') | 257 file_path = join(self.base_path, 'a') |
| 271 gclient_scm.os.path.exists(file_path).AndReturn(True) | 258 gclient_scm.os.path.exists(file_path).AndReturn(True) |
| 272 gclient_scm.os.path.isfile(file_path).AndReturn(False) | 259 gclient_scm.os.path.isfile(file_path).AndReturn(False) |
| 273 gclient_scm.os.path.islink(file_path).AndReturn(False) | 260 gclient_scm.os.path.islink(file_path).AndReturn(False) |
| 274 gclient_scm.os.path.isdir(file_path).AndReturn(True) | 261 gclient_scm.os.path.isdir(file_path).AndReturn(True) |
| 275 gclient_scm.gclient_utils.RemoveDirectory(file_path) | 262 gclient_scm.gclient_utils.RemoveDirectory(file_path) |
| 276 gclient_scm.os.path.isdir(self.base_path).AndReturn(True) | 263 gclient_scm.os.path.isdir(self.base_path).AndReturn(True) |
| 277 gclient_scm.scm.SVN.RunAndGetFileList( | 264 gclient_scm.scm.SVN.RunAndGetFileList( |
| 278 options.verbose, | 265 options.verbose, |
| 279 ['update', '--revision', 'BASE', '--ignore-externals'], | 266 ['update', '--revision', 'BASE', '--ignore-externals'], |
| 280 cwd=self.base_path, | 267 cwd=self.base_path, |
| 281 file_list=mox.IgnoreArg()) | 268 file_list=mox.IgnoreArg()) |
| 282 | 269 |
| 283 self.mox.ReplayAll() | 270 self.mox.ReplayAll() |
| 284 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, | 271 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, |
| 285 relpath=self.relpath) | 272 relpath=self.relpath) |
| 286 file_list2 = [] | 273 file_list2 = [] |
| 287 scm.revert(options, self.args, file_list2) | 274 scm.revert(options, self.args, file_list2) |
| 288 self.checkstdout(('%s\n' % file_path)) | 275 self.checkstdout(('%s\n' % file_path)) |
| 289 | 276 |
| 290 def testRevertDot(self): | 277 def testRevertDot(self): |
| 291 self.mox.StubOutWithMock(gclient_scm.SVNWrapper, 'update') | 278 self.mox.StubOutWithMock(gclient_scm.SVNWrapper, 'update') |
| 292 options = self.Options(verbose=True) | 279 options = self.Options(verbose=True) |
| 293 gclient_scm.os.path.isdir(self.base_path).AndReturn(True) | 280 gclient_scm.os.path.isdir(self.base_path).AndReturn(True) |
| 294 gclient_scm.os.path.isdir(join(self.base_path, '.svn')).AndReturn(True) | 281 gclient_scm.os.path.isdir(join(self.base_path, '.svn')).AndReturn(True) |
| 295 gclient_scm.gclient_utils.FindCommandExecutable('svn').AndReturn("./svn") | |
| 296 items = [ | 282 items = [ |
| 297 ('~ ', '.'), | 283 ('~ ', '.'), |
| 298 ] | 284 ] |
| 299 gclient_scm.scm.SVN.CaptureStatus(None, self.base_path).AndReturn(items) | 285 gclient_scm.scm.SVN.CaptureStatus(None, self.base_path).AndReturn(items) |
| 300 file_path = join(self.base_path, '.') | 286 file_path = join(self.base_path, '.') |
| 301 gclient_scm.os.path.exists(file_path).AndReturn(True) | 287 gclient_scm.os.path.exists(file_path).AndReturn(True) |
| 302 gclient_scm.os.path.isfile(file_path).AndReturn(False) | 288 gclient_scm.os.path.isfile(file_path).AndReturn(False) |
| 303 gclient_scm.os.path.islink(file_path).AndReturn(False) | 289 gclient_scm.os.path.islink(file_path).AndReturn(False) |
| 304 gclient_scm.os.path.isdir(file_path).AndReturn(True) | 290 gclient_scm.os.path.isdir(file_path).AndReturn(True) |
| 305 gclient_scm.gclient_utils.RemoveDirectory(file_path) | 291 gclient_scm.gclient_utils.RemoveDirectory(file_path) |
| 306 # pylint: disable=E1120 | 292 # pylint: disable=E1120 |
| 307 gclient_scm.os.path.isdir(self.base_path).AndReturn(False) | 293 gclient_scm.os.path.isdir(self.base_path).AndReturn(False) |
| 308 gclient_scm.SVNWrapper.update(options, [], ['.']) | 294 gclient_scm.SVNWrapper.update(options, [], ['.']) |
| 309 | 295 |
| 310 self.mox.ReplayAll() | 296 self.mox.ReplayAll() |
| 311 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, | 297 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, |
| 312 relpath=self.relpath) | 298 relpath=self.relpath) |
| 313 file_list2 = [] | 299 file_list2 = [] |
| 314 scm.revert(options, self.args, file_list2) | 300 scm.revert(options, self.args, file_list2) |
| 315 self.checkstdout(('%s\n' % file_path)) | 301 self.checkstdout(('%s\n' % file_path)) |
| 316 | 302 |
| 317 def testStatus(self): | 303 def testStatus(self): |
| 318 options = self.Options(verbose=True) | 304 options = self.Options(verbose=True) |
| 319 gclient_scm.gclient_utils.FindCommandExecutable('svn').AndReturn("./svn") | |
| 320 gclient_scm.os.path.isdir(self.base_path).AndReturn(True) | 305 gclient_scm.os.path.isdir(self.base_path).AndReturn(True) |
| 321 gclient_scm.scm.SVN.RunAndGetFileList( | 306 gclient_scm.scm.SVN.RunAndGetFileList( |
| 322 options.verbose, | 307 options.verbose, |
| 323 ['status'] + self.args + ['--ignore-externals'], | 308 ['status'] + self.args + ['--ignore-externals'], |
| 324 cwd=self.base_path, | 309 cwd=self.base_path, |
| 325 file_list=[]).AndReturn(None) | 310 file_list=[]).AndReturn(None) |
| 326 | 311 |
| 327 self.mox.ReplayAll() | 312 self.mox.ReplayAll() |
| 328 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, | 313 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, |
| 329 relpath=self.relpath) | 314 relpath=self.relpath) |
| 330 file_list = [] | 315 file_list = [] |
| 331 self.assertEqual(scm.status(options, self.args, file_list), None) | 316 self.assertEqual(scm.status(options, self.args, file_list), None) |
| 332 | 317 |
| 333 # TODO(maruel): TEST REVISIONS!!! | 318 # TODO(maruel): TEST REVISIONS!!! |
| 334 # TODO(maruel): TEST RELOCATE!!! | 319 # TODO(maruel): TEST RELOCATE!!! |
| 335 def testUpdateCheckout(self): | 320 def testUpdateCheckout(self): |
| 336 options = self.Options(verbose=True) | 321 options = self.Options(verbose=True) |
| 337 file_info = gclient_scm.gclient_utils.PrintableObject() | 322 file_info = gclient_scm.gclient_utils.PrintableObject() |
| 338 file_info.root = 'blah' | 323 file_info.root = 'blah' |
| 339 file_info.url = self.url | 324 file_info.url = self.url |
| 340 file_info.uuid = 'ABC' | 325 file_info.uuid = 'ABC' |
| 341 file_info.revision = 42 | 326 file_info.revision = 42 |
| 342 gclient_scm.gclient_utils.FindCommandExecutable('svn').AndReturn("./svn") | |
| 343 gclient_scm.os.path.exists(join(self.base_path, '.git')).AndReturn(False) | 327 gclient_scm.os.path.exists(join(self.base_path, '.git')).AndReturn(False) |
| 344 gclient_scm.os.path.exists(join(self.base_path, '.hg')).AndReturn(False) | 328 gclient_scm.os.path.exists(join(self.base_path, '.hg')).AndReturn(False) |
| 345 # Checkout. | 329 # Checkout. |
| 346 gclient_scm.os.path.exists(self.base_path).AndReturn(False) | 330 gclient_scm.os.path.exists(self.base_path).AndReturn(False) |
| 347 parent = gclient_scm.os.path.dirname(self.base_path) | 331 parent = gclient_scm.os.path.dirname(self.base_path) |
| 348 gclient_scm.os.path.exists(parent).AndReturn(False) | 332 gclient_scm.os.path.exists(parent).AndReturn(False) |
| 349 gclient_scm.os.makedirs(parent) | 333 gclient_scm.os.makedirs(parent) |
| 350 gclient_scm.os.path.exists(parent).AndReturn(True) | 334 gclient_scm.os.path.exists(parent).AndReturn(True) |
| 351 files_list = self.mox.CreateMockAnything() | 335 files_list = self.mox.CreateMockAnything() |
| 352 gclient_scm.scm.SVN.Capture(['--version'], None | 336 gclient_scm.scm.SVN.Capture(['--version'], None |
| (...skipping 14 matching lines...) Expand all Loading... |
| 367 options.nohooks = False | 351 options.nohooks = False |
| 368 file_info = { | 352 file_info = { |
| 369 'Repository Root': 'blah', | 353 'Repository Root': 'blah', |
| 370 'URL': self.url, | 354 'URL': self.url, |
| 371 'UUID': 'ABC', | 355 'UUID': 'ABC', |
| 372 'Revision': 42, | 356 'Revision': 42, |
| 373 } | 357 } |
| 374 gclient_scm.os.path.exists(join(self.base_path, '.git')).AndReturn(False) | 358 gclient_scm.os.path.exists(join(self.base_path, '.git')).AndReturn(False) |
| 375 gclient_scm.os.path.exists(join(self.base_path, '.hg')).AndReturn(False) | 359 gclient_scm.os.path.exists(join(self.base_path, '.hg')).AndReturn(False) |
| 376 gclient_scm.os.path.exists(self.base_path).AndReturn(True) | 360 gclient_scm.os.path.exists(self.base_path).AndReturn(True) |
| 377 gclient_scm.gclient_utils.FindCommandExecutable('svn').AndReturn("./svn") | |
| 378 | 361 |
| 379 # Checkout or update. | 362 # Checkout or update. |
| 380 dotted_path = join(self.base_path, '.') | 363 dotted_path = join(self.base_path, '.') |
| 381 gclient_scm.scm.SVN._CaptureInfo([], dotted_path).AndReturn(file_info) | 364 gclient_scm.scm.SVN._CaptureInfo([], dotted_path).AndReturn(file_info) |
| 382 | 365 |
| 383 # Verify no locked files. | 366 # Verify no locked files. |
| 384 gclient_scm.scm.SVN.CaptureStatus(None, dotted_path).AndReturn([]) | 367 gclient_scm.scm.SVN.CaptureStatus(None, dotted_path).AndReturn([]) |
| 385 | 368 |
| 386 # Cheat a bit here. | 369 # Cheat a bit here. |
| 387 gclient_scm.scm.SVN._CaptureInfo([file_info['URL']], None | 370 gclient_scm.scm.SVN._CaptureInfo([file_info['URL']], None |
| (...skipping 20 matching lines...) Expand all Loading... |
| 408 | 391 |
| 409 def testUpdateReset(self): | 392 def testUpdateReset(self): |
| 410 options = self.Options(verbose=True) | 393 options = self.Options(verbose=True) |
| 411 options.reset = True | 394 options.reset = True |
| 412 file_info = { | 395 file_info = { |
| 413 'Repository Root': 'blah', | 396 'Repository Root': 'blah', |
| 414 'URL': self.url, | 397 'URL': self.url, |
| 415 'UUID': 'ABC', | 398 'UUID': 'ABC', |
| 416 'Revision': 42, | 399 'Revision': 42, |
| 417 } | 400 } |
| 418 gclient_scm.gclient_utils.FindCommandExecutable('svn').AndReturn("./svn") | |
| 419 gclient_scm.os.path.exists(join(self.base_path, '.git')).AndReturn(False) | 401 gclient_scm.os.path.exists(join(self.base_path, '.git')).AndReturn(False) |
| 420 gclient_scm.os.path.exists(join(self.base_path, '.hg')).AndReturn(False) | 402 gclient_scm.os.path.exists(join(self.base_path, '.hg')).AndReturn(False) |
| 421 gclient_scm.os.path.exists(self.base_path).AndReturn(True) | 403 gclient_scm.os.path.exists(self.base_path).AndReturn(True) |
| 422 | 404 |
| 423 # Checkout or update. | 405 # Checkout or update. |
| 424 dotted_path = join(self.base_path, '.') | 406 dotted_path = join(self.base_path, '.') |
| 425 gclient_scm.scm.SVN._CaptureInfo([], dotted_path).AndReturn(file_info) | 407 gclient_scm.scm.SVN._CaptureInfo([], dotted_path).AndReturn(file_info) |
| 426 | 408 |
| 427 # Create an untracked file and directory. | 409 # Create an untracked file and directory. |
| 428 gclient_scm.scm.SVN.CaptureStatus(None, dotted_path | 410 gclient_scm.scm.SVN.CaptureStatus(None, dotted_path |
| (...skipping 13 matching lines...) Expand all Loading... |
| 442 options = self.Options(verbose=True) | 424 options = self.Options(verbose=True) |
| 443 options.reset = True | 425 options.reset = True |
| 444 options.delete_unversioned_trees = True | 426 options.delete_unversioned_trees = True |
| 445 | 427 |
| 446 file_info = { | 428 file_info = { |
| 447 'Repository Root': 'blah', | 429 'Repository Root': 'blah', |
| 448 'URL': self.url, | 430 'URL': self.url, |
| 449 'UUID': 'ABC', | 431 'UUID': 'ABC', |
| 450 'Revision': 42, | 432 'Revision': 42, |
| 451 } | 433 } |
| 452 gclient_scm.gclient_utils.FindCommandExecutable('svn').AndReturn("./svn") | |
| 453 gclient_scm.os.path.exists(join(self.base_path, '.git')).AndReturn(False) | 434 gclient_scm.os.path.exists(join(self.base_path, '.git')).AndReturn(False) |
| 454 gclient_scm.os.path.exists(join(self.base_path, '.hg')).AndReturn(False) | 435 gclient_scm.os.path.exists(join(self.base_path, '.hg')).AndReturn(False) |
| 455 gclient_scm.os.path.exists(self.base_path).AndReturn(True) | 436 gclient_scm.os.path.exists(self.base_path).AndReturn(True) |
| 456 | 437 |
| 457 # Checkout or update. | 438 # Checkout or update. |
| 458 dotted_path = join(self.base_path, '.') | 439 dotted_path = join(self.base_path, '.') |
| 459 gclient_scm.scm.SVN._CaptureInfo([], dotted_path).AndReturn(file_info) | 440 gclient_scm.scm.SVN._CaptureInfo([], dotted_path).AndReturn(file_info) |
| 460 | 441 |
| 461 # Create an untracked file and directory. | 442 # Create an untracked file and directory. |
| 462 gclient_scm.scm.SVN.CaptureStatus(None, dotted_path | 443 gclient_scm.scm.SVN.CaptureStatus(None, dotted_path |
| (...skipping 25 matching lines...) Expand all Loading... |
| 488 'URL': self.url, | 469 'URL': self.url, |
| 489 'Revision': 42, | 470 'Revision': 42, |
| 490 } | 471 } |
| 491 | 472 |
| 492 # Checks to make sure that we support svn co --depth. | 473 # Checks to make sure that we support svn co --depth. |
| 493 gclient_scm.scm.SVN.current_version = None | 474 gclient_scm.scm.SVN.current_version = None |
| 494 gclient_scm.scm.SVN.Capture(['--version'], None | 475 gclient_scm.scm.SVN.Capture(['--version'], None |
| 495 ).AndReturn('svn, version 1.5.1 (r32289)') | 476 ).AndReturn('svn, version 1.5.1 (r32289)') |
| 496 gclient_scm.os.path.exists(join(self.base_path, '.svn')).AndReturn(False) | 477 gclient_scm.os.path.exists(join(self.base_path, '.svn')).AndReturn(False) |
| 497 gclient_scm.os.path.exists(join(self.base_path, 'DEPS')).AndReturn(False) | 478 gclient_scm.os.path.exists(join(self.base_path, 'DEPS')).AndReturn(False) |
| 498 gclient_scm.gclient_utils.FindCommandExecutable('svn').AndReturn("./svn") | |
| 499 | 479 |
| 500 # Verify no locked files. | 480 # Verify no locked files. |
| 501 dotted_path = join(self.base_path, '.') | 481 dotted_path = join(self.base_path, '.') |
| 502 gclient_scm.scm.SVN.CaptureStatus(None, dotted_path).AndReturn([]) | 482 gclient_scm.scm.SVN.CaptureStatus(None, dotted_path).AndReturn([]) |
| 503 | 483 |
| 504 # When checking out a single file, we issue an svn checkout and svn update. | 484 # When checking out a single file, we issue an svn checkout and svn update. |
| 505 files_list = self.mox.CreateMockAnything() | 485 files_list = self.mox.CreateMockAnything() |
| 506 gclient_scm.gclient_utils.CheckCallAndFilterAndHeader( | 486 gclient_scm.gclient_utils.CheckCallAndFilterAndHeader( |
| 507 ['svn', 'checkout', '--depth', 'empty', self.url, self.base_path], | 487 ['svn', 'checkout', '--depth', 'empty', self.url, self.base_path], |
| 508 always=True, | 488 always=True, |
| (...skipping 19 matching lines...) Expand all Loading... |
| 528 self.checkstdout('\n_____ %s at 42\n' % self.relpath) | 508 self.checkstdout('\n_____ %s at 42\n' % self.relpath) |
| 529 | 509 |
| 530 def testUpdateSingleCheckoutSVN14(self): | 510 def testUpdateSingleCheckoutSVN14(self): |
| 531 options = self.Options(verbose=True) | 511 options = self.Options(verbose=True) |
| 532 | 512 |
| 533 # Checks to make sure that we support svn co --depth. | 513 # Checks to make sure that we support svn co --depth. |
| 534 gclient_scm.scm.SVN.current_version = None | 514 gclient_scm.scm.SVN.current_version = None |
| 535 gclient_scm.scm.SVN.Capture(['--version'], None | 515 gclient_scm.scm.SVN.Capture(['--version'], None |
| 536 ).AndReturn('svn, version 1.4.4 (r25188)') | 516 ).AndReturn('svn, version 1.4.4 (r25188)') |
| 537 gclient_scm.os.path.exists(self.base_path).AndReturn(True) | 517 gclient_scm.os.path.exists(self.base_path).AndReturn(True) |
| 538 gclient_scm.gclient_utils.FindCommandExecutable('svn').AndReturn("./svn") | |
| 539 | 518 |
| 540 # When checking out a single file with svn 1.4, we use svn export | 519 # When checking out a single file with svn 1.4, we use svn export |
| 541 files_list = self.mox.CreateMockAnything() | 520 files_list = self.mox.CreateMockAnything() |
| 542 gclient_scm.gclient_utils.CheckCallAndFilterAndHeader( | 521 gclient_scm.gclient_utils.CheckCallAndFilterAndHeader( |
| 543 ['svn', 'export', join(self.url, 'DEPS'), join(self.base_path, 'DEPS')], | 522 ['svn', 'export', join(self.url, 'DEPS'), join(self.base_path, 'DEPS')], |
| 544 always=True, cwd=self.root_dir) | 523 always=True, cwd=self.root_dir) |
| 545 | 524 |
| 546 self.mox.ReplayAll() | 525 self.mox.ReplayAll() |
| 547 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, | 526 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, |
| 548 relpath=self.relpath) | 527 relpath=self.relpath) |
| 549 scm.updatesingle(options, ['DEPS'], files_list) | 528 scm.updatesingle(options, ['DEPS'], files_list) |
| 550 | 529 |
| 551 def testUpdateSingleCheckoutSVNUpgrade(self): | 530 def testUpdateSingleCheckoutSVNUpgrade(self): |
| 552 options = self.Options(verbose=True) | 531 options = self.Options(verbose=True) |
| 553 file_info = { | 532 file_info = { |
| 554 'URL': self.url, | 533 'URL': self.url, |
| 555 'Revision': 42, | 534 'Revision': 42, |
| 556 } | 535 } |
| 557 | 536 |
| 558 # Checks to make sure that we support svn co --depth. | 537 # Checks to make sure that we support svn co --depth. |
| 559 gclient_scm.scm.SVN.current_version = None | 538 gclient_scm.scm.SVN.current_version = None |
| 560 gclient_scm.scm.SVN.Capture(['--version'], None | 539 gclient_scm.scm.SVN.Capture(['--version'], None |
| 561 ).AndReturn('svn, version 1.5.1 (r32289)') | 540 ).AndReturn('svn, version 1.5.1 (r32289)') |
| 562 gclient_scm.os.path.exists(join(self.base_path, '.svn')).AndReturn(False) | 541 gclient_scm.os.path.exists(join(self.base_path, '.svn')).AndReturn(False) |
| 563 # If DEPS already exists, assume we're upgrading from svn1.4, so delete | 542 # If DEPS already exists, assume we're upgrading from svn1.4, so delete |
| 564 # the old DEPS file. | 543 # the old DEPS file. |
| 565 gclient_scm.os.path.exists(join(self.base_path, 'DEPS')).AndReturn(True) | 544 gclient_scm.os.path.exists(join(self.base_path, 'DEPS')).AndReturn(True) |
| 566 gclient_scm.os.remove(join(self.base_path, 'DEPS')) | 545 gclient_scm.os.remove(join(self.base_path, 'DEPS')) |
| 567 gclient_scm.gclient_utils.FindCommandExecutable('svn').AndReturn("./svn") | |
| 568 | 546 |
| 569 # Verify no locked files. | 547 # Verify no locked files. |
| 570 gclient_scm.scm.SVN.CaptureStatus( | 548 gclient_scm.scm.SVN.CaptureStatus( |
| 571 None, join(self.base_path, '.')).AndReturn([]) | 549 None, join(self.base_path, '.')).AndReturn([]) |
| 572 | 550 |
| 573 # When checking out a single file, we issue an svn checkout and svn update. | 551 # When checking out a single file, we issue an svn checkout and svn update. |
| 574 files_list = self.mox.CreateMockAnything() | 552 files_list = self.mox.CreateMockAnything() |
| 575 gclient_scm.gclient_utils.CheckCallAndFilterAndHeader( | 553 gclient_scm.gclient_utils.CheckCallAndFilterAndHeader( |
| 576 ['svn', 'checkout', '--depth', 'empty', self.url, self.base_path], | 554 ['svn', 'checkout', '--depth', 'empty', self.url, self.base_path], |
| 577 always=True, | 555 always=True, |
| (...skipping 24 matching lines...) Expand all Loading... |
| 602 options = self.Options(verbose=True) | 580 options = self.Options(verbose=True) |
| 603 file_info = { | 581 file_info = { |
| 604 'URL': self.url, | 582 'URL': self.url, |
| 605 'Revision': 42, | 583 'Revision': 42, |
| 606 } | 584 } |
| 607 # Checks to make sure that we support svn co --depth. | 585 # Checks to make sure that we support svn co --depth. |
| 608 gclient_scm.scm.SVN.current_version = None | 586 gclient_scm.scm.SVN.current_version = None |
| 609 gclient_scm.scm.SVN.Capture(['--version'], None | 587 gclient_scm.scm.SVN.Capture(['--version'], None |
| 610 ).AndReturn('svn, version 1.5.1 (r32289)') | 588 ).AndReturn('svn, version 1.5.1 (r32289)') |
| 611 gclient_scm.os.path.exists(join(self.base_path, '.svn')).AndReturn(True) | 589 gclient_scm.os.path.exists(join(self.base_path, '.svn')).AndReturn(True) |
| 612 gclient_scm.gclient_utils.FindCommandExecutable('svn').AndReturn("./svn") | |
| 613 | 590 |
| 614 # Verify no locked files. | 591 # Verify no locked files. |
| 615 gclient_scm.scm.SVN.CaptureStatus(None, join(self.base_path, '.') | 592 gclient_scm.scm.SVN.CaptureStatus(None, join(self.base_path, '.') |
| 616 ).AndReturn([]) | 593 ).AndReturn([]) |
| 617 | 594 |
| 618 # Now we fall back on scm.update(). | 595 # Now we fall back on scm.update(). |
| 619 files_list = self.mox.CreateMockAnything() | 596 files_list = self.mox.CreateMockAnything() |
| 620 gclient_scm.os.path.exists(join(self.base_path, '.git')).AndReturn(False) | 597 gclient_scm.os.path.exists(join(self.base_path, '.git')).AndReturn(False) |
| 621 gclient_scm.os.path.exists(join(self.base_path, '.hg')).AndReturn(False) | 598 gclient_scm.os.path.exists(join(self.base_path, '.hg')).AndReturn(False) |
| 622 gclient_scm.os.path.exists(self.base_path).AndReturn(True) | 599 gclient_scm.os.path.exists(self.base_path).AndReturn(True) |
| 623 gclient_scm.scm.SVN._CaptureInfo( | 600 gclient_scm.scm.SVN._CaptureInfo( |
| 624 [], join(self.base_path, '.')).AndReturn(file_info) | 601 [], join(self.base_path, '.')).AndReturn(file_info) |
| 625 gclient_scm.scm.SVN._CaptureInfo([file_info['URL']], None | 602 gclient_scm.scm.SVN._CaptureInfo([file_info['URL']], None |
| 626 ).AndReturn(file_info) | 603 ).AndReturn(file_info) |
| 627 | 604 |
| 628 self.mox.ReplayAll() | 605 self.mox.ReplayAll() |
| 629 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, | 606 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, |
| 630 relpath=self.relpath) | 607 relpath=self.relpath) |
| 631 scm.updatesingle(options, ['DEPS'], files_list) | 608 scm.updatesingle(options, ['DEPS'], files_list) |
| 632 self.checkstdout('\n_____ %s at 42\n' % self.relpath) | 609 self.checkstdout('\n_____ %s at 42\n' % self.relpath) |
| 633 | 610 |
| 634 def testUpdateGit(self): | 611 def testUpdateGit(self): |
| 635 options = self.Options(verbose=True) | 612 options = self.Options(verbose=True) |
| 636 gclient_scm.gclient_utils.FindCommandExecutable('svn').AndReturn("./svn") | |
| 637 file_path = gclient_scm.os.path.join(self.root_dir, self.relpath, '.git') | 613 file_path = gclient_scm.os.path.join(self.root_dir, self.relpath, '.git') |
| 638 gclient_scm.os.path.exists(file_path).AndReturn(True) | 614 gclient_scm.os.path.exists(file_path).AndReturn(True) |
| 639 | 615 |
| 640 self.mox.ReplayAll() | 616 self.mox.ReplayAll() |
| 641 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, | 617 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, |
| 642 relpath=self.relpath) | 618 relpath=self.relpath) |
| 643 file_list = [] | 619 file_list = [] |
| 644 scm.update(options, self.args, file_list) | 620 scm.update(options, self.args, file_list) |
| 645 self.checkstdout( | 621 self.checkstdout( |
| 646 ('________ found .git directory; skipping %s\n' % self.relpath)) | 622 ('________ found .git directory; skipping %s\n' % self.relpath)) |
| 647 | 623 |
| 648 def testUpdateHg(self): | 624 def testUpdateHg(self): |
| 649 options = self.Options(verbose=True) | 625 options = self.Options(verbose=True) |
| 650 gclient_scm.gclient_utils.FindCommandExecutable('svn').AndReturn("./svn") | |
| 651 gclient_scm.os.path.exists(join(self.base_path, '.git')).AndReturn(False) | 626 gclient_scm.os.path.exists(join(self.base_path, '.git')).AndReturn(False) |
| 652 gclient_scm.os.path.exists(join(self.base_path, '.hg')).AndReturn(True) | 627 gclient_scm.os.path.exists(join(self.base_path, '.hg')).AndReturn(True) |
| 653 | 628 |
| 654 self.mox.ReplayAll() | 629 self.mox.ReplayAll() |
| 655 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, | 630 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, |
| 656 relpath=self.relpath) | 631 relpath=self.relpath) |
| 657 file_list = [] | 632 file_list = [] |
| 658 scm.update(options, self.args, file_list) | 633 scm.update(options, self.args, file_list) |
| 659 self.checkstdout( | 634 self.checkstdout( |
| 660 ('________ found .hg directory; skipping %s\n' % self.relpath)) | 635 ('________ found .hg directory; skipping %s\n' % self.relpath)) |
| 661 | 636 |
| 662 def testGetUsableRevSVN(self): | 637 def testGetUsableRevSVN(self): |
| 663 # pylint: disable=E1101 | 638 # pylint: disable=E1101 |
| 664 options = self.Options(verbose=True) | 639 options = self.Options(verbose=True) |
| 665 | 640 |
| 666 # Mock SVN revision validity checking. | 641 # Mock SVN revision validity checking. |
| 667 self.mox.StubOutWithMock( | 642 self.mox.StubOutWithMock( |
| 668 gclient_scm.scm.SVN, 'IsValidRevision', True) | 643 gclient_scm.scm.SVN, 'IsValidRevision', True) |
| 669 gclient_scm.scm.SVN.IsValidRevision(url='%s@%s' % (self.url, 1) | 644 gclient_scm.scm.SVN.IsValidRevision(url='%s@%s' % (self.url, 1) |
| 670 ).AndReturn(True) | 645 ).AndReturn(True) |
| 671 gclient_scm.scm.SVN.IsValidRevision(url='%s@%s' % (self.url, 'fake') | 646 gclient_scm.scm.SVN.IsValidRevision(url='%s@%s' % (self.url, 'fake') |
| 672 ).AndReturn(False) | 647 ).AndReturn(False) |
| 673 gclient_scm.gclient_utils.FindCommandExecutable('svn').AndReturn("./svn") | |
| 674 | 648 |
| 675 self.mox.ReplayAll() | 649 self.mox.ReplayAll() |
| 676 | 650 |
| 677 svn_scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir) | 651 svn_scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir) |
| 678 # With an SVN checkout, 1 an example of a valid usable rev. | 652 # With an SVN checkout, 1 an example of a valid usable rev. |
| 679 self.assertEquals(svn_scm.GetUsableRev(1, options), 1) | 653 self.assertEquals(svn_scm.GetUsableRev(1, options), 1) |
| 680 # With an SVN checkout, a fake or unknown rev should raise an excpetion. | 654 # With an SVN checkout, a fake or unknown rev should raise an excpetion. |
| 681 self.assertRaises(gclient_scm.gclient_utils.Error, | 655 self.assertRaises(gclient_scm.gclient_utils.Error, |
| 682 svn_scm.GetUsableRev, 'fake', options) | 656 svn_scm.GetUsableRev, 'fake', options) |
| 683 | 657 |
| (...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1123 | 1097 |
| 1124 self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'IsValidRevision', True) | 1098 self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'IsValidRevision', True) |
| 1125 gclient_scm.scm.GIT.IsValidRevision(cwd=self.base_path, rev=self.fake_hash_1 | 1099 gclient_scm.scm.GIT.IsValidRevision(cwd=self.base_path, rev=self.fake_hash_1 |
| 1126 ).AndReturn(True) | 1100 ).AndReturn(True) |
| 1127 | 1101 |
| 1128 self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'IsGitSvn', True) | 1102 self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'IsGitSvn', True) |
| 1129 gclient_scm.scm.GIT.IsGitSvn(cwd=self.base_path).MultipleTimes( | 1103 gclient_scm.scm.GIT.IsGitSvn(cwd=self.base_path).MultipleTimes( |
| 1130 ).AndReturn(False) | 1104 ).AndReturn(False) |
| 1131 | 1105 |
| 1132 gclient_scm.scm.os.path.isdir(self.base_path).AndReturn(True) | 1106 gclient_scm.scm.os.path.isdir(self.base_path).AndReturn(True) |
| 1133 gclient_scm.gclient_utils.FindCommandExecutable('git').AndReturn("./git") | |
| 1134 | 1107 |
| 1135 self.mox.ReplayAll() | 1108 self.mox.ReplayAll() |
| 1136 | 1109 |
| 1137 git_scm = gclient_scm.CreateSCM(url=self.url, root_dir=self.root_dir, | 1110 git_scm = gclient_scm.CreateSCM(url=self.url, root_dir=self.root_dir, |
| 1138 relpath=self.relpath) | 1111 relpath=self.relpath) |
| 1139 # A [fake] git sha1 with a git repo should work (this is in the case that | 1112 # A [fake] git sha1 with a git repo should work (this is in the case that |
| 1140 # the LKGR gets flipped to git sha1's some day). | 1113 # the LKGR gets flipped to git sha1's some day). |
| 1141 self.assertEquals(git_scm.GetUsableRev(self.fake_hash_1, options), | 1114 self.assertEquals(git_scm.GetUsableRev(self.fake_hash_1, options), |
| 1142 self.fake_hash_1) | 1115 self.fake_hash_1) |
| 1143 # An SVN rev with an existing purely git repo should raise an exception. | 1116 # An SVN rev with an existing purely git repo should raise an exception. |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1177 ).AndReturn(True) | 1150 ).AndReturn(True) |
| 1178 | 1151 |
| 1179 self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'IsValidRevision', True) | 1152 self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'IsValidRevision', True) |
| 1180 gclient_scm.scm.GIT.IsValidRevision(cwd=self.base_path, rev=self.fake_hash_1 | 1153 gclient_scm.scm.GIT.IsValidRevision(cwd=self.base_path, rev=self.fake_hash_1 |
| 1181 ).AndReturn(True) | 1154 ).AndReturn(True) |
| 1182 gclient_scm.scm.GIT.IsValidRevision(cwd=self.base_path, rev=too_big | 1155 gclient_scm.scm.GIT.IsValidRevision(cwd=self.base_path, rev=too_big |
| 1183 ).AndReturn(False) | 1156 ).AndReturn(False) |
| 1184 | 1157 |
| 1185 gclient_scm.os.path.isdir(self.base_path).AndReturn(False) | 1158 gclient_scm.os.path.isdir(self.base_path).AndReturn(False) |
| 1186 gclient_scm.os.path.isdir(self.base_path).MultipleTimes().AndReturn(True) | 1159 gclient_scm.os.path.isdir(self.base_path).MultipleTimes().AndReturn(True) |
| 1187 gclient_scm.gclient_utils.FindCommandExecutable('git').AndReturn("./git") | |
| 1188 | 1160 |
| 1189 self.mox.ReplayAll() | 1161 self.mox.ReplayAll() |
| 1190 | 1162 |
| 1191 git_svn_scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, | 1163 git_svn_scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, |
| 1192 relpath=self.relpath) | 1164 relpath=self.relpath) |
| 1193 # Without an existing checkout, this should fail. | 1165 # Without an existing checkout, this should fail. |
| 1194 # TODO(dbeam) Fix this. http://crbug.com/109184 | 1166 # TODO(dbeam) Fix this. http://crbug.com/109184 |
| 1195 self.assertRaises(gclient_scm.gclient_utils.Error, | 1167 self.assertRaises(gclient_scm.gclient_utils.Error, |
| 1196 git_svn_scm.GetUsableRev, '1', options) | 1168 git_svn_scm.GetUsableRev, '1', options) |
| 1197 # Given an SVN revision with a git-svn checkout, it should be translated to | 1169 # Given an SVN revision with a git-svn checkout, it should be translated to |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1234 | 1206 |
| 1235 if __name__ == '__main__': | 1207 if __name__ == '__main__': |
| 1236 if '-v' in sys.argv: | 1208 if '-v' in sys.argv: |
| 1237 logging.basicConfig( | 1209 logging.basicConfig( |
| 1238 level=logging.DEBUG, | 1210 level=logging.DEBUG, |
| 1239 format='%(asctime).19s %(levelname)s %(filename)s:' | 1211 format='%(asctime).19s %(levelname)s %(filename)s:' |
| 1240 '%(lineno)s %(message)s') | 1212 '%(lineno)s %(message)s') |
| 1241 unittest.main() | 1213 unittest.main() |
| 1242 | 1214 |
| 1243 # vim: ts=2:sw=2:tw=80:et: | 1215 # vim: ts=2:sw=2:tw=80:et: |
| OLD | NEW |