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