| 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 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 def testGITFakeHttpsUrl(self): | 154 def testGITFakeHttpsUrl(self): |
| 155 self.url = 'git+https://foo' | 155 self.url = 'git+https://foo' |
| 156 | 156 |
| 157 self.mox.ReplayAll() | 157 self.mox.ReplayAll() |
| 158 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, |
| 159 relpath=self.relpath) | 159 relpath=self.relpath) |
| 160 self.assertEqual(scm.url, 'https://foo') | 160 self.assertEqual(scm.url, 'https://foo') |
| 161 | 161 |
| 162 def testRunCommandException(self): | 162 def testRunCommandException(self): |
| 163 options = self.Options(verbose=False) | 163 options = self.Options(verbose=False) |
| 164 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) |
| 164 | 166 |
| 165 self.mox.ReplayAll() | 167 self.mox.ReplayAll() |
| 166 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, | 168 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, |
| 167 relpath=self.relpath) | 169 relpath=self.relpath) |
| 168 exception = "Unsupported argument(s): %s" % ','.join(self.args) | 170 exception = "Unsupported argument(s): %s" % ','.join(self.args) |
| 169 self.assertRaisesError(exception, scm.RunCommand, | 171 self.assertRaisesError(exception, scm.RunCommand, |
| 170 'update', options, self.args) | 172 'update', options, self.args) |
| 171 | 173 |
| 172 def testRunCommandUnknown(self): | 174 def testRunCommandUnknown(self): |
| 173 # TODO(maruel): if ever used. | 175 # TODO(maruel): if ever used. |
| 174 pass | 176 pass |
| 175 | 177 |
| 176 def testRevertMissing(self): | 178 def testRevertMissing(self): |
| 177 options = self.Options(verbose=True) | 179 options = self.Options(verbose=True) |
| 178 gclient_scm.os.path.isdir(self.base_path).AndReturn(False) | 180 gclient_scm.os.path.isdir(self.base_path).AndReturn(False) |
| 179 gclient_scm.os.path.exists(self.base_path).AndReturn(False) | 181 gclient_scm.os.path.exists(self.base_path).AndReturn(False) |
| 180 gclient_scm.scm.SVN.Capture(['--version', '--quiet'], None | 182 gclient_scm.scm.SVN.Capture(['--version', '--quiet'], None |
| 181 ).AndReturn('1.5.1') | 183 ).AndReturn('1.5.1') |
| 182 # It'll to a checkout instead. | 184 # It'll to a checkout instead. |
| 185 gclient_scm.os.path.exists(join(self.base_path, '.git')).AndReturn(False) |
| 186 gclient_scm.os.path.exists(join(self.base_path, '.hg')).AndReturn(False) |
| 183 # Checkout. | 187 # Checkout. |
| 184 gclient_scm.os.path.exists(self.base_path).AndReturn(False) | 188 gclient_scm.os.path.exists(self.base_path).AndReturn(False) |
| 185 parent = gclient_scm.os.path.dirname(self.base_path) | 189 parent = gclient_scm.os.path.dirname(self.base_path) |
| 186 gclient_scm.os.path.exists(parent).AndReturn(False) | 190 gclient_scm.os.path.exists(parent).AndReturn(False) |
| 187 gclient_scm.os.makedirs(parent) | 191 gclient_scm.os.makedirs(parent) |
| 188 gclient_scm.os.path.exists(parent).AndReturn(True) | 192 gclient_scm.os.path.exists(parent).AndReturn(True) |
| 189 files_list = self.mox.CreateMockAnything() | 193 files_list = self.mox.CreateMockAnything() |
| 190 gclient_scm.scm.SVN.RunAndGetFileList( | 194 gclient_scm.scm.SVN.RunAndGetFileList( |
| 191 options.verbose, | 195 options.verbose, |
| 192 ['checkout', self.url, self.base_path, '--force', '--ignore-externals'], | 196 ['checkout', self.url, self.base_path, '--force', '--ignore-externals'], |
| 193 cwd=self.root_dir, | 197 cwd=self.root_dir, |
| 194 file_list=files_list) | 198 file_list=files_list) |
| 195 | 199 |
| 196 gclient_scm.scm.SVN._CaptureInfo([], self.base_path+'/.' | 200 gclient_scm.scm.SVN._CaptureInfo([], self.base_path+'/.' |
| 197 ).AndReturn({'Revision': 100}) | 201 ).AndReturn({'Revision': 100}) |
| 198 | 202 |
| 199 self.mox.ReplayAll() | 203 self.mox.ReplayAll() |
| 200 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, | 204 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, |
| 201 relpath=self.relpath) | 205 relpath=self.relpath) |
| 202 scm.revert(options, self.args, files_list) | 206 scm.revert(options, self.args, files_list) |
| 203 self.checkstdout( | 207 self.checkstdout( |
| 204 ('\n_____ %s is missing, synching instead\n' % self.relpath)) | 208 ('\n_____ %s is missing, synching instead\n' % self.relpath)) |
| 205 | 209 |
| 206 def testRevertNoDotSvn(self): | 210 def testRevertNoDotSvn(self): |
| 207 options = self.Options(verbose=True, force=True) | 211 options = self.Options(verbose=True, force=True) |
| 208 gclient_scm.os.path.isdir(self.base_path).AndReturn(True) | 212 gclient_scm.os.path.isdir(self.base_path).AndReturn(True) |
| 209 gclient_scm.os.path.isdir(join(self.base_path, '.svn')).AndReturn(False) | 213 gclient_scm.os.path.isdir(join(self.base_path, '.svn')).AndReturn(False) |
| 210 gclient_scm.os.path.isdir(join(self.base_path, '.git')).AndReturn(False) | 214 gclient_scm.os.path.isdir(join(self.base_path, '.git')).AndReturn(False) |
| 215 gclient_scm.os.path.isdir(join(self.base_path, '.hg')).AndReturn(False) |
| 211 # Checkout. | 216 # Checkout. |
| 217 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) |
| 212 gclient_scm.os.path.exists(self.base_path).AndReturn(False) | 219 gclient_scm.os.path.exists(self.base_path).AndReturn(False) |
| 213 parent = gclient_scm.os.path.dirname(self.base_path) | 220 parent = gclient_scm.os.path.dirname(self.base_path) |
| 214 gclient_scm.os.path.exists(parent).AndReturn(False) | 221 gclient_scm.os.path.exists(parent).AndReturn(False) |
| 215 gclient_scm.os.makedirs(parent) | 222 gclient_scm.os.makedirs(parent) |
| 216 gclient_scm.os.path.exists(parent).AndReturn(True) | 223 gclient_scm.os.path.exists(parent).AndReturn(True) |
| 217 files_list = self.mox.CreateMockAnything() | 224 files_list = self.mox.CreateMockAnything() |
| 218 gclient_scm.scm.SVN.Capture(['--version', '--quiet'], None | 225 gclient_scm.scm.SVN.Capture(['--version', '--quiet'], None |
| 219 ).AndReturn('1.6') | 226 ).AndReturn('1.6') |
| 220 gclient_scm.scm.SVN.RunAndGetFileList( | 227 gclient_scm.scm.SVN.RunAndGetFileList( |
| 221 options.verbose, | 228 options.verbose, |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 | 333 |
| 327 # TODO(maruel): TEST REVISIONS!!! | 334 # TODO(maruel): TEST REVISIONS!!! |
| 328 # TODO(maruel): TEST RELOCATE!!! | 335 # TODO(maruel): TEST RELOCATE!!! |
| 329 def testUpdateCheckout(self): | 336 def testUpdateCheckout(self): |
| 330 options = self.Options(verbose=True) | 337 options = self.Options(verbose=True) |
| 331 file_info = gclient_scm.gclient_utils.PrintableObject() | 338 file_info = gclient_scm.gclient_utils.PrintableObject() |
| 332 file_info.root = 'blah' | 339 file_info.root = 'blah' |
| 333 file_info.url = self.url | 340 file_info.url = self.url |
| 334 file_info.uuid = 'ABC' | 341 file_info.uuid = 'ABC' |
| 335 file_info.revision = 42 | 342 file_info.revision = 42 |
| 343 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) |
| 336 # Checkout. | 345 # Checkout. |
| 337 gclient_scm.os.path.exists(self.base_path).AndReturn(False) | 346 gclient_scm.os.path.exists(self.base_path).AndReturn(False) |
| 338 parent = gclient_scm.os.path.dirname(self.base_path) | 347 parent = gclient_scm.os.path.dirname(self.base_path) |
| 339 gclient_scm.os.path.exists(parent).AndReturn(False) | 348 gclient_scm.os.path.exists(parent).AndReturn(False) |
| 340 gclient_scm.os.makedirs(parent) | 349 gclient_scm.os.makedirs(parent) |
| 341 gclient_scm.os.path.exists(parent).AndReturn(True) | 350 gclient_scm.os.path.exists(parent).AndReturn(True) |
| 342 files_list = self.mox.CreateMockAnything() | 351 files_list = self.mox.CreateMockAnything() |
| 343 gclient_scm.scm.SVN.Capture(['--version', '--quiet'], None | 352 gclient_scm.scm.SVN.Capture(['--version', '--quiet'], None |
| 344 ).AndReturn('1.5.1') | 353 ).AndReturn('1.5.1') |
| 345 gclient_scm.scm.SVN.RunAndGetFileList( | 354 gclient_scm.scm.SVN.RunAndGetFileList( |
| (...skipping 11 matching lines...) Expand all Loading... |
| 357 def testUpdateUpdate(self): | 366 def testUpdateUpdate(self): |
| 358 options = self.Options(verbose=True) | 367 options = self.Options(verbose=True) |
| 359 options.force = True | 368 options.force = True |
| 360 options.nohooks = False | 369 options.nohooks = False |
| 361 file_info = { | 370 file_info = { |
| 362 'Repository Root': 'blah', | 371 'Repository Root': 'blah', |
| 363 'URL': self.url, | 372 'URL': self.url, |
| 364 'UUID': 'ABC', | 373 'UUID': 'ABC', |
| 365 'Revision': 42, | 374 'Revision': 42, |
| 366 } | 375 } |
| 367 self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'IsGitSvn', True) | 376 gclient_scm.os.path.exists(join(self.base_path, '.git')).AndReturn(False) |
| 368 gclient_scm.scm.GIT.IsGitSvn(self.base_path).AndReturn(False) | 377 gclient_scm.os.path.exists(join(self.base_path, '.hg')).AndReturn(False) |
| 369 gclient_scm.os.path.exists(self.base_path).AndReturn(True) | 378 gclient_scm.os.path.exists(self.base_path).AndReturn(True) |
| 370 | 379 |
| 371 # Checkout or update. | 380 # Checkout or update. |
| 372 dotted_path = join(self.base_path, '.') | 381 dotted_path = join(self.base_path, '.') |
| 373 gclient_scm.scm.SVN._CaptureInfo([], dotted_path).AndReturn(file_info) | 382 gclient_scm.scm.SVN._CaptureInfo([], dotted_path).AndReturn(file_info) |
| 374 | 383 |
| 375 # Verify no locked files. | 384 # Verify no locked files. |
| 376 gclient_scm.scm.SVN.CaptureStatus(None, dotted_path).AndReturn([]) | 385 gclient_scm.scm.SVN.CaptureStatus(None, dotted_path).AndReturn([]) |
| 377 | 386 |
| 378 # Cheat a bit here. | 387 # Cheat a bit here. |
| (...skipping 24 matching lines...) Expand all Loading... |
| 403 | 412 |
| 404 def testUpdateReset(self): | 413 def testUpdateReset(self): |
| 405 options = self.Options(verbose=True) | 414 options = self.Options(verbose=True) |
| 406 options.reset = True | 415 options.reset = True |
| 407 file_info = { | 416 file_info = { |
| 408 'Repository Root': 'blah', | 417 'Repository Root': 'blah', |
| 409 'URL': self.url, | 418 'URL': self.url, |
| 410 'UUID': 'ABC', | 419 'UUID': 'ABC', |
| 411 'Revision': 42, | 420 'Revision': 42, |
| 412 } | 421 } |
| 413 self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'IsGitSvn', True) | 422 gclient_scm.os.path.exists(join(self.base_path, '.git')).AndReturn(False) |
| 414 gclient_scm.scm.GIT.IsGitSvn(self.base_path).AndReturn(False) | 423 gclient_scm.os.path.exists(join(self.base_path, '.hg')).AndReturn(False) |
| 415 gclient_scm.os.path.exists(self.base_path).AndReturn(True) | 424 gclient_scm.os.path.exists(self.base_path).AndReturn(True) |
| 416 | 425 |
| 417 # Checkout or update. | 426 # Checkout or update. |
| 418 dotted_path = join(self.base_path, '.') | 427 dotted_path = join(self.base_path, '.') |
| 419 gclient_scm.scm.SVN._CaptureInfo([], dotted_path).AndReturn(file_info) | 428 gclient_scm.scm.SVN._CaptureInfo([], dotted_path).AndReturn(file_info) |
| 420 | 429 |
| 421 # Create an untracked file and directory. | 430 # Create an untracked file and directory. |
| 422 gclient_scm.scm.SVN.CaptureStatus(None, dotted_path | 431 gclient_scm.scm.SVN.CaptureStatus(None, dotted_path |
| 423 ).AndReturn([['? ', 'dir'], ['? ', 'file']]) | 432 ).AndReturn([['? ', 'dir'], ['? ', 'file']]) |
| 424 | 433 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 439 options = self.Options(verbose=True) | 448 options = self.Options(verbose=True) |
| 440 options.reset = True | 449 options.reset = True |
| 441 options.delete_unversioned_trees = True | 450 options.delete_unversioned_trees = True |
| 442 | 451 |
| 443 file_info = { | 452 file_info = { |
| 444 'Repository Root': 'blah', | 453 'Repository Root': 'blah', |
| 445 'URL': self.url, | 454 'URL': self.url, |
| 446 'UUID': 'ABC', | 455 'UUID': 'ABC', |
| 447 'Revision': 42, | 456 'Revision': 42, |
| 448 } | 457 } |
| 449 self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'IsGitSvn', True) | 458 gclient_scm.os.path.exists(join(self.base_path, '.git')).AndReturn(False) |
| 450 gclient_scm.scm.GIT.IsGitSvn(self.base_path).AndReturn(False) | 459 gclient_scm.os.path.exists(join(self.base_path, '.hg')).AndReturn(False) |
| 451 gclient_scm.os.path.exists(self.base_path).AndReturn(True) | 460 gclient_scm.os.path.exists(self.base_path).AndReturn(True) |
| 452 | 461 |
| 453 # Checkout or update. | 462 # Checkout or update. |
| 454 dotted_path = join(self.base_path, '.') | 463 dotted_path = join(self.base_path, '.') |
| 455 gclient_scm.scm.SVN._CaptureInfo([], dotted_path).AndReturn(file_info) | 464 gclient_scm.scm.SVN._CaptureInfo([], dotted_path).AndReturn(file_info) |
| 456 | 465 |
| 457 # Create an untracked file and directory. | 466 # Create an untracked file and directory. |
| 458 gclient_scm.scm.SVN.CaptureStatus(None, dotted_path | 467 gclient_scm.scm.SVN.CaptureStatus(None, dotted_path |
| 459 ).AndReturn([['? ', 'dir'], ['? ', 'file']]) | 468 ).AndReturn([['? ', 'dir'], ['? ', 'file']]) |
| 460 | 469 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 505 ['svn', 'checkout', '--depth', 'empty', self.url, self.base_path], | 514 ['svn', 'checkout', '--depth', 'empty', self.url, self.base_path], |
| 506 always=True, | 515 always=True, |
| 507 cwd=self.root_dir) | 516 cwd=self.root_dir) |
| 508 gclient_scm.scm.SVN.RunAndGetFileList( | 517 gclient_scm.scm.SVN.RunAndGetFileList( |
| 509 options.verbose, | 518 options.verbose, |
| 510 ['update', 'DEPS', '--ignore-externals'], | 519 ['update', 'DEPS', '--ignore-externals'], |
| 511 cwd=self.base_path, | 520 cwd=self.base_path, |
| 512 file_list=files_list) | 521 file_list=files_list) |
| 513 | 522 |
| 514 # Now we fall back on scm.update(). | 523 # Now we fall back on scm.update(). |
| 515 self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'IsGitSvn', True) | 524 gclient_scm.os.path.exists(join(self.base_path, '.git')).AndReturn(False) |
| 516 gclient_scm.scm.GIT.IsGitSvn(self.base_path).AndReturn(False) | 525 gclient_scm.os.path.exists(join(self.base_path, '.hg')).AndReturn(False) |
| 517 gclient_scm.os.path.exists(self.base_path).AndReturn(True) | 526 gclient_scm.os.path.exists(self.base_path).AndReturn(True) |
| 518 gclient_scm.scm.SVN._CaptureInfo([], dotted_path).AndReturn(file_info) | 527 gclient_scm.scm.SVN._CaptureInfo([], dotted_path).AndReturn(file_info) |
| 519 gclient_scm.scm.SVN._CaptureInfo([file_info['URL']], None | 528 gclient_scm.scm.SVN._CaptureInfo([file_info['URL']], None |
| 520 ).AndReturn(file_info) | 529 ).AndReturn(file_info) |
| 521 | 530 |
| 522 gclient_scm.scm.SVN._CaptureInfo([], self.base_path+'/.' | 531 gclient_scm.scm.SVN._CaptureInfo([], self.base_path+'/.' |
| 523 ).AndReturn({'Revision': 100}) | 532 ).AndReturn({'Revision': 100}) |
| 524 | 533 |
| 525 self.mox.ReplayAll() | 534 self.mox.ReplayAll() |
| 526 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, | 535 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 575 ['svn', 'checkout', '--depth', 'empty', self.url, self.base_path], | 584 ['svn', 'checkout', '--depth', 'empty', self.url, self.base_path], |
| 576 always=True, | 585 always=True, |
| 577 cwd=self.root_dir) | 586 cwd=self.root_dir) |
| 578 gclient_scm.scm.SVN.RunAndGetFileList( | 587 gclient_scm.scm.SVN.RunAndGetFileList( |
| 579 options.verbose, | 588 options.verbose, |
| 580 ['update', 'DEPS', '--ignore-externals'], | 589 ['update', 'DEPS', '--ignore-externals'], |
| 581 cwd=self.base_path, | 590 cwd=self.base_path, |
| 582 file_list=files_list) | 591 file_list=files_list) |
| 583 | 592 |
| 584 # Now we fall back on scm.update(). | 593 # Now we fall back on scm.update(). |
| 585 self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'IsGitSvn', True) | 594 gclient_scm.os.path.exists(join(self.base_path, '.git')).AndReturn(False) |
| 586 gclient_scm.scm.GIT.IsGitSvn(self.base_path).AndReturn(False) | 595 gclient_scm.os.path.exists(join(self.base_path, '.hg')).AndReturn(False) |
| 587 gclient_scm.os.path.exists(self.base_path).AndReturn(True) | 596 gclient_scm.os.path.exists(self.base_path).AndReturn(True) |
| 588 gclient_scm.scm.SVN._CaptureInfo( | 597 gclient_scm.scm.SVN._CaptureInfo( |
| 589 [], join(self.base_path, ".")).AndReturn(file_info) | 598 [], join(self.base_path, ".")).AndReturn(file_info) |
| 590 gclient_scm.scm.SVN._CaptureInfo([file_info['URL']], None | 599 gclient_scm.scm.SVN._CaptureInfo([file_info['URL']], None |
| 591 ).AndReturn(file_info) | 600 ).AndReturn(file_info) |
| 592 | 601 |
| 593 gclient_scm.scm.SVN._CaptureInfo([], self.base_path+'/.' | 602 gclient_scm.scm.SVN._CaptureInfo([], self.base_path+'/.' |
| 594 ).AndReturn({'Revision': 100}) | 603 ).AndReturn({'Revision': 100}) |
| 595 | 604 |
| 596 self.mox.ReplayAll() | 605 self.mox.ReplayAll() |
| (...skipping 14 matching lines...) Expand all Loading... |
| 611 gclient_scm.scm.SVN.Capture(['--version', '--quiet'], None | 620 gclient_scm.scm.SVN.Capture(['--version', '--quiet'], None |
| 612 ).AndReturn('1.5.1') | 621 ).AndReturn('1.5.1') |
| 613 gclient_scm.os.path.exists(join(self.base_path, '.svn')).AndReturn(True) | 622 gclient_scm.os.path.exists(join(self.base_path, '.svn')).AndReturn(True) |
| 614 | 623 |
| 615 # Verify no locked files. | 624 # Verify no locked files. |
| 616 gclient_scm.scm.SVN.CaptureStatus(None, join(self.base_path, '.') | 625 gclient_scm.scm.SVN.CaptureStatus(None, join(self.base_path, '.') |
| 617 ).AndReturn([]) | 626 ).AndReturn([]) |
| 618 | 627 |
| 619 # Now we fall back on scm.update(). | 628 # Now we fall back on scm.update(). |
| 620 files_list = self.mox.CreateMockAnything() | 629 files_list = self.mox.CreateMockAnything() |
| 621 self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'IsGitSvn', True) | 630 gclient_scm.os.path.exists(join(self.base_path, '.git')).AndReturn(False) |
| 622 gclient_scm.scm.GIT.IsGitSvn(self.base_path).AndReturn(False) | 631 gclient_scm.os.path.exists(join(self.base_path, '.hg')).AndReturn(False) |
| 623 gclient_scm.os.path.exists(self.base_path).AndReturn(True) | 632 gclient_scm.os.path.exists(self.base_path).AndReturn(True) |
| 624 gclient_scm.scm.SVN._CaptureInfo( | 633 gclient_scm.scm.SVN._CaptureInfo( |
| 625 [], join(self.base_path, '.')).AndReturn(file_info) | 634 [], join(self.base_path, '.')).AndReturn(file_info) |
| 626 gclient_scm.scm.SVN._CaptureInfo([file_info['URL']], None | 635 gclient_scm.scm.SVN._CaptureInfo([file_info['URL']], None |
| 627 ).AndReturn(file_info) | 636 ).AndReturn(file_info) |
| 628 | 637 |
| 629 gclient_scm.scm.SVN._CaptureInfo([], self.base_path+'/.' | 638 gclient_scm.scm.SVN._CaptureInfo([], self.base_path+'/.' |
| 630 ).AndReturn({'Revision': 100}) | 639 ).AndReturn({'Revision': 100}) |
| 631 | 640 |
| 632 self.mox.ReplayAll() | 641 self.mox.ReplayAll() |
| 633 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, | 642 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, |
| 634 relpath=self.relpath) | 643 relpath=self.relpath) |
| 635 scm.updatesingle(options, ['DEPS'], files_list) | 644 scm.updatesingle(options, ['DEPS'], files_list) |
| 636 self.checkstdout('\n_____ %s at 42\n' % self.relpath) | 645 self.checkstdout('\n_____ %s at 42\n' % self.relpath) |
| 637 | 646 |
| 638 def testUpdateGitSvn(self): | 647 def testUpdateGit(self): |
| 639 options = self.Options(verbose=True) | 648 options = self.Options(verbose=True) |
| 640 gclient_scm.os.path.exists(self.base_path).AndReturn(True) | 649 file_path = gclient_scm.os.path.join(self.root_dir, self.relpath, '.git') |
| 641 self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'IsGitSvn', True) | 650 gclient_scm.os.path.exists(file_path).AndReturn(True) |
| 642 gclient_scm.scm.GIT.IsGitSvn(self.base_path).AndReturn(True) | 651 |
| 643 self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'Capture', True) | |
| 644 gclient_scm.scm.GIT.Capture(['config', '--local', '--get', | |
| 645 'svn-remote.svn.url'], | |
| 646 cwd=self.base_path).AndReturn(self.url) | |
| 647 self.mox.ReplayAll() | 652 self.mox.ReplayAll() |
| 648 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, | 653 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, |
| 649 relpath=self.relpath) | 654 relpath=self.relpath) |
| 650 file_list = [] | 655 file_list = [] |
| 651 scm.update(options, [], file_list) | 656 scm.update(options, self.args, file_list) |
| 652 self.checkstdout( | 657 self.checkstdout( |
| 653 ('\n_____ %s looks like a git-svn checkout. Skipping.\n' % self.relpath) | 658 ('________ found .git directory; skipping %s\n' % self.relpath)) |
| 654 ) | 659 |
| 660 def testUpdateHg(self): |
| 661 options = self.Options(verbose=True) |
| 662 gclient_scm.os.path.exists(join(self.base_path, '.git')).AndReturn(False) |
| 663 gclient_scm.os.path.exists(join(self.base_path, '.hg')).AndReturn(True) |
| 664 |
| 665 self.mox.ReplayAll() |
| 666 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, |
| 667 relpath=self.relpath) |
| 668 file_list = [] |
| 669 scm.update(options, self.args, file_list) |
| 670 self.checkstdout( |
| 671 ('________ found .hg directory; skipping %s\n' % self.relpath)) |
| 655 | 672 |
| 656 def testGetUsableRevSVN(self): | 673 def testGetUsableRevSVN(self): |
| 657 # pylint: disable=E1101 | 674 # pylint: disable=E1101 |
| 658 options = self.Options(verbose=True) | 675 options = self.Options(verbose=True) |
| 659 | 676 |
| 660 # Mock SVN revision validity checking. | 677 # Mock SVN revision validity checking. |
| 661 self.mox.StubOutWithMock( | 678 self.mox.StubOutWithMock( |
| 662 gclient_scm.scm.SVN, 'IsValidRevision', True) | 679 gclient_scm.scm.SVN, 'IsValidRevision', True) |
| 663 gclient_scm.scm.SVN.IsValidRevision(url='%s@%s' % (self.url, 1) | 680 gclient_scm.scm.SVN.IsValidRevision(url='%s@%s' % (self.url, 1) |
| 664 ).AndReturn(True) | 681 ).AndReturn(True) |
| (...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1138 | 1155 |
| 1139 def testGetUsableRevGit(self): | 1156 def testGetUsableRevGit(self): |
| 1140 # pylint: disable=E1101 | 1157 # pylint: disable=E1101 |
| 1141 options = self.Options(verbose=True) | 1158 options = self.Options(verbose=True) |
| 1142 | 1159 |
| 1143 self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'IsValidRevision', True) | 1160 self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'IsValidRevision', True) |
| 1144 gclient_scm.scm.GIT.IsValidRevision(cwd=self.base_path, rev=self.fake_hash_1 | 1161 gclient_scm.scm.GIT.IsValidRevision(cwd=self.base_path, rev=self.fake_hash_1 |
| 1145 ).AndReturn(True) | 1162 ).AndReturn(True) |
| 1146 | 1163 |
| 1147 self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'IsGitSvn', True) | 1164 self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'IsGitSvn', True) |
| 1148 gclient_scm.scm.GIT.IsGitSvn(self.base_path).MultipleTimes( | 1165 gclient_scm.scm.GIT.IsGitSvn(cwd=self.base_path).MultipleTimes( |
| 1149 ).AndReturn(False) | 1166 ).AndReturn(False) |
| 1150 | 1167 |
| 1151 gclient_scm.scm.os.path.isdir(self.base_path).AndReturn(True) | 1168 gclient_scm.scm.os.path.isdir(self.base_path).AndReturn(True) |
| 1152 gclient_scm.os.path.isdir(self.base_path).AndReturn(True) | 1169 gclient_scm.os.path.isdir(self.base_path).AndReturn(True) |
| 1153 | 1170 |
| 1154 self.mox.ReplayAll() | 1171 self.mox.ReplayAll() |
| 1155 | 1172 |
| 1156 git_scm = gclient_scm.CreateSCM(url=self.url, root_dir=self.root_dir, | 1173 git_scm = gclient_scm.CreateSCM(url=self.url, root_dir=self.root_dir, |
| 1157 relpath=self.relpath) | 1174 relpath=self.relpath) |
| 1158 # A [fake] git sha1 with a git repo should work (this is in the case that | 1175 # A [fake] git sha1 with a git repo should work (this is in the case that |
| (...skipping 28 matching lines...) Expand all Loading... |
| 1187 cwd=self.base_path).AndReturn('blah') | 1204 cwd=self.base_path).AndReturn('blah') |
| 1188 gclient_scm.scm.GIT.Capture(['fetch'], cwd=self.base_path) | 1205 gclient_scm.scm.GIT.Capture(['fetch'], cwd=self.base_path) |
| 1189 gclient_scm.scm.GIT.Capture(['svn', 'fetch'], cwd=self.base_path) | 1206 gclient_scm.scm.GIT.Capture(['svn', 'fetch'], cwd=self.base_path) |
| 1190 error = subprocess2.CalledProcessError(1, 'cmd', '/cwd', 'stdout', 'stderr') | 1207 error = subprocess2.CalledProcessError(1, 'cmd', '/cwd', 'stdout', 'stderr') |
| 1191 gclient_scm.scm.GIT.Capture(['config', '--get', 'svn-remote.svn.fetch'], | 1208 gclient_scm.scm.GIT.Capture(['config', '--get', 'svn-remote.svn.fetch'], |
| 1192 cwd=self.base_path).AndRaise(error) | 1209 cwd=self.base_path).AndRaise(error) |
| 1193 gclient_scm.scm.GIT.Capture(['svn', 'fetch'], cwd=self.base_path) | 1210 gclient_scm.scm.GIT.Capture(['svn', 'fetch'], cwd=self.base_path) |
| 1194 gclient_scm.scm.GIT.Capture(['fetch', 'origin'], cwd=self.base_path) | 1211 gclient_scm.scm.GIT.Capture(['fetch', 'origin'], cwd=self.base_path) |
| 1195 | 1212 |
| 1196 self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'IsGitSvn', True) | 1213 self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'IsGitSvn', True) |
| 1197 gclient_scm.scm.GIT.IsGitSvn(self.base_path).MultipleTimes( | 1214 gclient_scm.scm.GIT.IsGitSvn(cwd=self.base_path).MultipleTimes( |
| 1198 ).AndReturn(True) | 1215 ).AndReturn(True) |
| 1199 | 1216 |
| 1200 self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'IsValidRevision', True) | 1217 self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'IsValidRevision', True) |
| 1201 gclient_scm.scm.GIT.IsValidRevision(cwd=self.base_path, rev=self.fake_hash_1 | 1218 gclient_scm.scm.GIT.IsValidRevision(cwd=self.base_path, rev=self.fake_hash_1 |
| 1202 ).AndReturn(True) | 1219 ).AndReturn(True) |
| 1203 gclient_scm.scm.GIT.IsValidRevision(cwd=self.base_path, rev=too_big | 1220 gclient_scm.scm.GIT.IsValidRevision(cwd=self.base_path, rev=too_big |
| 1204 ).MultipleTimes(2).AndReturn(False) | 1221 ).MultipleTimes(2).AndReturn(False) |
| 1205 | 1222 |
| 1206 gclient_scm.os.path.isdir(self.base_path).AndReturn(False) | 1223 gclient_scm.os.path.isdir(self.base_path).AndReturn(False) |
| 1207 gclient_scm.os.path.isdir(self.base_path).MultipleTimes().AndReturn(True) | 1224 gclient_scm.os.path.isdir(self.base_path).MultipleTimes().AndReturn(True) |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1254 | 1271 |
| 1255 if __name__ == '__main__': | 1272 if __name__ == '__main__': |
| 1256 if '-v' in sys.argv: | 1273 if '-v' in sys.argv: |
| 1257 logging.basicConfig( | 1274 logging.basicConfig( |
| 1258 level=logging.DEBUG, | 1275 level=logging.DEBUG, |
| 1259 format='%(asctime).19s %(levelname)s %(filename)s:' | 1276 format='%(asctime).19s %(levelname)s %(filename)s:' |
| 1260 '%(lineno)s %(message)s') | 1277 '%(lineno)s %(message)s') |
| 1261 unittest.main() | 1278 unittest.main() |
| 1262 | 1279 |
| 1263 # vim: ts=2:sw=2:tw=80:et: | 1280 # vim: ts=2:sw=2:tw=80:et: |
| OLD | NEW |