| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # | 2 # |
| 3 # Copyright 2008-2009 Google Inc. All Rights Reserved. | 3 # Copyright 2008-2009 Google Inc. All Rights Reserved. |
| 4 # | 4 # |
| 5 # Licensed under the Apache License, Version 2.0 (the "License"); | 5 # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 # you may not use this file except in compliance with the License. | 6 # you may not use this file except in compliance with the License. |
| 7 # You may obtain a copy of the License at | 7 # You may obtain a copy of the License at |
| 8 # | 8 # |
| 9 # http://www.apache.org/licenses/LICENSE-2.0 | 9 # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 # | 10 # |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 BaseTestCase.setUp(self) | 63 BaseTestCase.setUp(self) |
| 64 # Mock them to be sure nothing bad happens. | 64 # Mock them to be sure nothing bad happens. |
| 65 self.mox.StubOutWithMock(gclient_scm, 'CaptureSVN') | 65 self.mox.StubOutWithMock(gclient_scm, 'CaptureSVN') |
| 66 self._CaptureSVNInfo = gclient_scm.CaptureSVNInfo | 66 self._CaptureSVNInfo = gclient_scm.CaptureSVNInfo |
| 67 self.mox.StubOutWithMock(gclient_scm, 'CaptureSVNInfo') | 67 self.mox.StubOutWithMock(gclient_scm, 'CaptureSVNInfo') |
| 68 self.mox.StubOutWithMock(gclient_scm, 'CaptureSVNStatus') | 68 self.mox.StubOutWithMock(gclient_scm, 'CaptureSVNStatus') |
| 69 self.mox.StubOutWithMock(gclient_scm, 'RunSVN') | 69 self.mox.StubOutWithMock(gclient_scm, 'RunSVN') |
| 70 self.mox.StubOutWithMock(gclient_scm, 'RunSVNAndGetFileList') | 70 self.mox.StubOutWithMock(gclient_scm, 'RunSVNAndGetFileList') |
| 71 self._gclient_gclient = gclient.GClient | 71 self._gclient_gclient = gclient.GClient |
| 72 gclient.GClient = self.mox.CreateMockAnything() | 72 gclient.GClient = self.mox.CreateMockAnything() |
| 73 self._scm_wrapper = gclient_scm.create_scm | 73 self._scm_wrapper = gclient_scm.SCMWrapper |
| 74 gclient_scm.create_scm = self.mox.CreateMockAnything() | 74 gclient_scm.SCMWrapper = self.mox.CreateMockAnything() |
| 75 | 75 |
| 76 def tearDown(self): | 76 def tearDown(self): |
| 77 gclient.GClient = self._gclient_gclient | 77 gclient.GClient = self._gclient_gclient |
| 78 gclient_scm.create_scm = self._scm_wrapper | 78 gclient_scm.SCMWrapper = self._scm_wrapper |
| 79 BaseTestCase.tearDown(self) | 79 BaseTestCase.tearDown(self) |
| 80 | 80 |
| 81 | 81 |
| 82 class GclientTestCase(GClientBaseTestCase): | 82 class GclientTestCase(GClientBaseTestCase): |
| 83 class OptionsObject(object): | 83 class OptionsObject(object): |
| 84 def __init__(self, test_case, verbose=False, spec=None, | 84 def __init__(self, test_case, verbose=False, spec=None, |
| 85 config_filename='a_file_name', | 85 config_filename='a_file_name', |
| 86 entries_filename='a_entry_file_name', | 86 entries_filename='a_entry_file_name', |
| 87 deps_file='a_deps_file_name', force=False, nohooks=False): | 87 deps_file='a_deps_file_name', force=False, nohooks=False): |
| 88 self.verbose = verbose | 88 self.verbose = verbose |
| (...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 401 options = self.Options() | 401 options = self.Options() |
| 402 | 402 |
| 403 checkout_path = os.path.join(self.root_dir, solution_name) | 403 checkout_path = os.path.join(self.root_dir, solution_name) |
| 404 gclient.os.path.exists(os.path.join(checkout_path, '.git')).AndReturn(False) | 404 gclient.os.path.exists(os.path.join(checkout_path, '.git')).AndReturn(False) |
| 405 # Expect a check for the entries file and we say there is not one. | 405 # Expect a check for the entries file and we say there is not one. |
| 406 gclient.os.path.exists(os.path.join(self.root_dir, options.entries_filename) | 406 gclient.os.path.exists(os.path.join(self.root_dir, options.entries_filename) |
| 407 ).AndReturn(False) | 407 ).AndReturn(False) |
| 408 | 408 |
| 409 # An scm will be requested for the solution. | 409 # An scm will be requested for the solution. |
| 410 scm_wrapper_sol = self.mox.CreateMockAnything() | 410 scm_wrapper_sol = self.mox.CreateMockAnything() |
| 411 gclient_scm.create_scm(self.url, self.root_dir, solution_name | 411 gclient_scm.SCMWrapper(self.url, self.root_dir, solution_name |
| 412 ).AndReturn(scm_wrapper_sol) | 412 ).AndReturn(scm_wrapper_sol) |
| 413 # Then an update will be performed. | 413 # Then an update will be performed. |
| 414 scm_wrapper_sol.RunCommand('update', options, self.args, []) | 414 scm_wrapper_sol.RunCommand('update', options, self.args, []) |
| 415 # Then an attempt will be made to read its DEPS file. | 415 # Then an attempt will be made to read its DEPS file. |
| 416 gclient.FileRead(os.path.join(self.root_dir, | 416 gclient.FileRead(os.path.join(self.root_dir, |
| 417 solution_name, | 417 solution_name, |
| 418 options.deps_file)).AndRaise(IOError(2, 'No DEPS file')) | 418 options.deps_file)).AndRaise(IOError(2, 'No DEPS file')) |
| 419 | 419 |
| 420 # After everything is done, an attempt is made to write an entries | 420 # After everything is done, an attempt is made to write an entries |
| 421 # file. | 421 # file. |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 458 gclient.os.path.exists(os.path.join(self.root_dir, solution_name, 'src', | 458 gclient.os.path.exists(os.path.join(self.root_dir, solution_name, 'src', |
| 459 't', '.git') | 459 't', '.git') |
| 460 ).AndReturn(False) | 460 ).AndReturn(False) |
| 461 gclient.os.path.exists(os.path.join(self.root_dir, solution_name, '.git') | 461 gclient.os.path.exists(os.path.join(self.root_dir, solution_name, '.git') |
| 462 ).AndReturn(False) | 462 ).AndReturn(False) |
| 463 # Expect a check for the entries file and we say there is not one. | 463 # Expect a check for the entries file and we say there is not one. |
| 464 gclient.os.path.exists(os.path.join(self.root_dir, options.entries_filename) | 464 gclient.os.path.exists(os.path.join(self.root_dir, options.entries_filename) |
| 465 ).AndReturn(False) | 465 ).AndReturn(False) |
| 466 | 466 |
| 467 # An scm will be requested for the solution. | 467 # An scm will be requested for the solution. |
| 468 gclient_scm.create_scm(self.url, self.root_dir, solution_name | 468 gclient_scm.SCMWrapper(self.url, self.root_dir, solution_name |
| 469 ).AndReturn(scm_wrapper_sol) | 469 ).AndReturn(scm_wrapper_sol) |
| 470 # Then an update will be performed. | 470 # Then an update will be performed. |
| 471 scm_wrapper_sol.RunCommand('update', options, self.args, []) | 471 scm_wrapper_sol.RunCommand('update', options, self.args, []) |
| 472 # Then an attempt will be made to read its DEPS file. | 472 # Then an attempt will be made to read its DEPS file. |
| 473 gclient.FileRead(os.path.join(self.root_dir, | 473 gclient.FileRead(os.path.join(self.root_dir, |
| 474 solution_name, | 474 solution_name, |
| 475 options.deps_file)).AndReturn(deps) | 475 options.deps_file)).AndReturn(deps) |
| 476 | 476 |
| 477 # Next we expect an scm to be request for dep src/t but it should | 477 # Next we expect an scm to be request for dep src/t but it should |
| 478 # use the url specified in deps and the relative path should now | 478 # use the url specified in deps and the relative path should now |
| 479 # be relative to the DEPS file. | 479 # be relative to the DEPS file. |
| 480 gclient_scm.create_scm( | 480 gclient_scm.SCMWrapper( |
| 481 'svn://scm.t/trunk', | 481 'svn://scm.t/trunk', |
| 482 self.root_dir, | 482 self.root_dir, |
| 483 os.path.join(solution_name, "src", "t")).AndReturn(scm_wrapper_t) | 483 os.path.join(solution_name, "src", "t")).AndReturn(scm_wrapper_t) |
| 484 scm_wrapper_t.RunCommand('update', options, self.args, []) | 484 scm_wrapper_t.RunCommand('update', options, self.args, []) |
| 485 | 485 |
| 486 # After everything is done, an attempt is made to write an entries | 486 # After everything is done, an attempt is made to write an entries |
| 487 # file. | 487 # file. |
| 488 gclient.FileWrite(os.path.join(self.root_dir, options.entries_filename), | 488 gclient.FileWrite(os.path.join(self.root_dir, options.entries_filename), |
| 489 entries_content) | 489 entries_content) |
| 490 | 490 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 532 gclient.os.path.exists(os.path.join(self.root_dir, 'src/n', '.git') | 532 gclient.os.path.exists(os.path.join(self.root_dir, 'src/n', '.git') |
| 533 ).AndReturn(False) | 533 ).AndReturn(False) |
| 534 gclient.os.path.exists(os.path.join(self.root_dir, 'src/t', '.git') | 534 gclient.os.path.exists(os.path.join(self.root_dir, 'src/t', '.git') |
| 535 ).AndReturn(False) | 535 ).AndReturn(False) |
| 536 | 536 |
| 537 # Expect a check for the entries file and we say there is not one. | 537 # Expect a check for the entries file and we say there is not one. |
| 538 gclient.os.path.exists(os.path.join(self.root_dir, options.entries_filename) | 538 gclient.os.path.exists(os.path.join(self.root_dir, options.entries_filename) |
| 539 ).AndReturn(False) | 539 ).AndReturn(False) |
| 540 | 540 |
| 541 # An scm will be requested for the solution. | 541 # An scm will be requested for the solution. |
| 542 gclient_scm.create_scm(self.url, self.root_dir, solution_name | 542 gclient_scm.SCMWrapper(self.url, self.root_dir, solution_name |
| 543 ).AndReturn(scm_wrapper_sol) | 543 ).AndReturn(scm_wrapper_sol) |
| 544 # Then an update will be performed. | 544 # Then an update will be performed. |
| 545 scm_wrapper_sol.RunCommand('update', options, self.args, []) | 545 scm_wrapper_sol.RunCommand('update', options, self.args, []) |
| 546 # Then an attempt will be made to read its DEPS file. | 546 # Then an attempt will be made to read its DEPS file. |
| 547 gclient.FileRead(os.path.join(checkout_path, options.deps_file) | 547 gclient.FileRead(os.path.join(checkout_path, options.deps_file) |
| 548 ).AndReturn(deps) | 548 ).AndReturn(deps) |
| 549 | 549 |
| 550 # Next we expect an scm to be request for dep src/n even though it does not | 550 # Next we expect an scm to be request for dep src/n even though it does not |
| 551 # exist in the DEPS file. | 551 # exist in the DEPS file. |
| 552 gclient_scm.create_scm('svn://custom.n/trunk', | 552 gclient_scm.SCMWrapper('svn://custom.n/trunk', |
| 553 self.root_dir, | 553 self.root_dir, |
| 554 "src/n").AndReturn(scm_wrapper_n) | 554 "src/n").AndReturn(scm_wrapper_n) |
| 555 | 555 |
| 556 # Next we expect an scm to be request for dep src/t but it should | 556 # Next we expect an scm to be request for dep src/t but it should |
| 557 # use the url specified in custom_deps. | 557 # use the url specified in custom_deps. |
| 558 gclient_scm.create_scm('svn://custom.t/trunk', | 558 gclient_scm.SCMWrapper('svn://custom.t/trunk', |
| 559 self.root_dir, | 559 self.root_dir, |
| 560 "src/t").AndReturn(scm_wrapper_t) | 560 "src/t").AndReturn(scm_wrapper_t) |
| 561 | 561 |
| 562 scm_wrapper_n.RunCommand('update', options, self.args, []) | 562 scm_wrapper_n.RunCommand('update', options, self.args, []) |
| 563 scm_wrapper_t.RunCommand('update', options, self.args, []) | 563 scm_wrapper_t.RunCommand('update', options, self.args, []) |
| 564 | 564 |
| 565 # NOTE: the dep src/b should not create an scm at all. | 565 # NOTE: the dep src/b should not create an scm at all. |
| 566 | 566 |
| 567 # After everything is done, an attempt is made to write an entries | 567 # After everything is done, an attempt is made to write an entries |
| 568 # file. | 568 # file. |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 618 gclient.os.path.exists(os.path.join(self.root_dir, name_b, '.git') | 618 gclient.os.path.exists(os.path.join(self.root_dir, name_b, '.git') |
| 619 ).AndReturn(False) | 619 ).AndReturn(False) |
| 620 gclient.os.path.exists(os.path.join(self.root_dir, 'src/t', '.git') | 620 gclient.os.path.exists(os.path.join(self.root_dir, 'src/t', '.git') |
| 621 ).AndReturn(False) | 621 ).AndReturn(False) |
| 622 | 622 |
| 623 # Expect a check for the entries file and we say there is not one. | 623 # Expect a check for the entries file and we say there is not one. |
| 624 gclient.os.path.exists(os.path.join(self.root_dir, options.entries_filename) | 624 gclient.os.path.exists(os.path.join(self.root_dir, options.entries_filename) |
| 625 ).AndReturn(False) | 625 ).AndReturn(False) |
| 626 | 626 |
| 627 # An scm will be requested for the first solution. | 627 # An scm will be requested for the first solution. |
| 628 gclient_scm.create_scm(url_a, self.root_dir, name_a).AndReturn( | 628 gclient_scm.SCMWrapper(url_a, self.root_dir, name_a).AndReturn( |
| 629 scm_wrapper_a) | 629 scm_wrapper_a) |
| 630 # Then an attempt will be made to read it's DEPS file. | 630 # Then an attempt will be made to read it's DEPS file. |
| 631 gclient.FileRead(os.path.join(self.root_dir, name_a, options.deps_file) | 631 gclient.FileRead(os.path.join(self.root_dir, name_a, options.deps_file) |
| 632 ).AndReturn(deps_a) | 632 ).AndReturn(deps_a) |
| 633 # Then an update will be performed. | 633 # Then an update will be performed. |
| 634 scm_wrapper_a.RunCommand('update', options, self.args, []) | 634 scm_wrapper_a.RunCommand('update', options, self.args, []) |
| 635 | 635 |
| 636 # An scm will be requested for the second solution. | 636 # An scm will be requested for the second solution. |
| 637 gclient_scm.create_scm(url_b, self.root_dir, name_b).AndReturn( | 637 gclient_scm.SCMWrapper(url_b, self.root_dir, name_b).AndReturn( |
| 638 scm_wrapper_b) | 638 scm_wrapper_b) |
| 639 # Then an attempt will be made to read its DEPS file. | 639 # Then an attempt will be made to read its DEPS file. |
| 640 gclient.FileRead(os.path.join(self.root_dir, name_b, options.deps_file) | 640 gclient.FileRead(os.path.join(self.root_dir, name_b, options.deps_file) |
| 641 ).AndReturn(deps_b) | 641 ).AndReturn(deps_b) |
| 642 # Then an update will be performed. | 642 # Then an update will be performed. |
| 643 scm_wrapper_b.RunCommand('update', options, self.args, []) | 643 scm_wrapper_b.RunCommand('update', options, self.args, []) |
| 644 | 644 |
| 645 # Finally, an scm is requested for the shared dep. | 645 # Finally, an scm is requested for the shared dep. |
| 646 gclient_scm.create_scm('http://svn.t/trunk', self.root_dir, 'src/t' | 646 gclient_scm.SCMWrapper('http://svn.t/trunk', self.root_dir, 'src/t' |
| 647 ).AndReturn(scm_wrapper_dep) | 647 ).AndReturn(scm_wrapper_dep) |
| 648 # And an update is run on it. | 648 # And an update is run on it. |
| 649 scm_wrapper_dep.RunCommand('update', options, self.args, []) | 649 scm_wrapper_dep.RunCommand('update', options, self.args, []) |
| 650 | 650 |
| 651 # After everything is done, an attempt is made to write an entries file. | 651 # After everything is done, an attempt is made to write an entries file. |
| 652 gclient.FileWrite(os.path.join(self.root_dir, options.entries_filename), | 652 gclient.FileWrite(os.path.join(self.root_dir, options.entries_filename), |
| 653 entries_content) | 653 entries_content) |
| 654 | 654 |
| 655 self.mox.ReplayAll() | 655 self.mox.ReplayAll() |
| 656 client = self._gclient_gclient(self.root_dir, options) | 656 client = self._gclient_gclient(self.root_dir, options) |
| 657 client.SetConfig(gclient_config) | 657 client.SetConfig(gclient_config) |
| 658 client.RunOnDeps('update', self.args) | 658 client.RunOnDeps('update', self.args) |
| 659 | 659 |
| 660 def testRunOnDepsSuccess(self): | 660 def testRunOnDepsSuccess(self): |
| 661 # Fake .gclient file. | 661 # Fake .gclient file. |
| 662 name = 'testRunOnDepsSuccess_solution_name' | 662 name = 'testRunOnDepsSuccess_solution_name' |
| 663 gclient_config = """solutions = [ { | 663 gclient_config = """solutions = [ { |
| 664 'name': '%s', | 664 'name': '%s', |
| 665 'url': '%s', | 665 'url': '%s', |
| 666 'custom_deps': {}, | 666 'custom_deps': {}, |
| 667 }, ]""" % (name, self.url) | 667 }, ]""" % (name, self.url) |
| 668 | 668 |
| 669 options = self.Options() | 669 options = self.Options() |
| 670 gclient.os.path.exists(os.path.join(self.root_dir, name, '.git') | 670 gclient.os.path.exists(os.path.join(self.root_dir, name, '.git') |
| 671 ).AndReturn(False) | 671 ).AndReturn(False) |
| 672 gclient.os.path.exists(os.path.join(self.root_dir, options.entries_filename) | 672 gclient.os.path.exists(os.path.join(self.root_dir, options.entries_filename) |
| 673 ).AndReturn(False) | 673 ).AndReturn(False) |
| 674 gclient_scm.create_scm(self.url, self.root_dir, name).AndReturn( | 674 gclient_scm.SCMWrapper(self.url, self.root_dir, name).AndReturn( |
| 675 gclient_scm.create_scm) | 675 gclient_scm.SCMWrapper) |
| 676 gclient_scm.create_scm.RunCommand('update', options, self.args, []) | 676 gclient_scm.SCMWrapper.RunCommand('update', options, self.args, []) |
| 677 gclient.FileRead(os.path.join(self.root_dir, name, options.deps_file) | 677 gclient.FileRead(os.path.join(self.root_dir, name, options.deps_file) |
| 678 ).AndReturn("Boo = 'a'") | 678 ).AndReturn("Boo = 'a'") |
| 679 gclient.FileWrite(os.path.join(self.root_dir, options.entries_filename), | 679 gclient.FileWrite(os.path.join(self.root_dir, options.entries_filename), |
| 680 'entries = [\n "%s",\n]\n' % name) | 680 'entries = [\n "%s",\n]\n' % name) |
| 681 | 681 |
| 682 self.mox.ReplayAll() | 682 self.mox.ReplayAll() |
| 683 client = self._gclient_gclient(self.root_dir, options) | 683 client = self._gclient_gclient(self.root_dir, options) |
| 684 client.SetConfig(gclient_config) | 684 client.SetConfig(gclient_config) |
| 685 client.RunOnDeps('update', self.args) | 685 client.RunOnDeps('update', self.args) |
| 686 | 686 |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 758 ).AndReturn(False) | 758 ).AndReturn(False) |
| 759 gclient.os.path.exists(os.path.join(self.root_dir, | 759 gclient.os.path.exists(os.path.join(self.root_dir, |
| 760 'src/third_party/python_24', '.git') | 760 'src/third_party/python_24', '.git') |
| 761 ).AndReturn(False) | 761 ).AndReturn(False) |
| 762 gclient.os.path.exists(os.path.join(self.root_dir, 'src/breakpad/bar', | 762 gclient.os.path.exists(os.path.join(self.root_dir, 'src/breakpad/bar', |
| 763 '.git') | 763 '.git') |
| 764 ).AndReturn(False) | 764 ).AndReturn(False) |
| 765 gclient.os.path.exists(os.path.join(self.root_dir, options.entries_filename) | 765 gclient.os.path.exists(os.path.join(self.root_dir, options.entries_filename) |
| 766 ).AndReturn(False) | 766 ).AndReturn(False) |
| 767 | 767 |
| 768 gclient_scm.create_scm(self.url, self.root_dir, 'src').AndReturn( | 768 gclient_scm.SCMWrapper(self.url, self.root_dir, 'src').AndReturn( |
| 769 scm_wrapper_src) | 769 scm_wrapper_src) |
| 770 scm_wrapper_src.RunCommand('update', mox.Func(OptIsRev123), self.args, []) | 770 scm_wrapper_src.RunCommand('update', mox.Func(OptIsRev123), self.args, []) |
| 771 | 771 |
| 772 gclient_scm.create_scm(self.url, self.root_dir, | 772 gclient_scm.SCMWrapper(self.url, self.root_dir, |
| 773 None).AndReturn(scm_wrapper_src2) | 773 None).AndReturn(scm_wrapper_src2) |
| 774 scm_wrapper_src2.FullUrlForRelativeUrl('/trunk/deps/third_party/cygwin@3248' | 774 scm_wrapper_src2.FullUrlForRelativeUrl('/trunk/deps/third_party/cygwin@3248' |
| 775 ).AndReturn(cygwin_path) | 775 ).AndReturn(cygwin_path) |
| 776 | 776 |
| 777 gclient_scm.create_scm(self.url, self.root_dir, | 777 gclient_scm.SCMWrapper(self.url, self.root_dir, |
| 778 None).AndReturn(scm_wrapper_src2) | 778 None).AndReturn(scm_wrapper_src2) |
| 779 scm_wrapper_src2.FullUrlForRelativeUrl('/trunk/deps/third_party/WebKit' | 779 scm_wrapper_src2.FullUrlForRelativeUrl('/trunk/deps/third_party/WebKit' |
| 780 ).AndReturn(webkit_path) | 780 ).AndReturn(webkit_path) |
| 781 | 781 |
| 782 gclient_scm.create_scm(webkit_path, self.root_dir, | 782 gclient_scm.SCMWrapper(webkit_path, self.root_dir, |
| 783 'foo/third_party/WebKit').AndReturn(scm_wrapper_webkit) | 783 'foo/third_party/WebKit').AndReturn(scm_wrapper_webkit) |
| 784 scm_wrapper_webkit.RunCommand('update', mox.Func(OptIsRev42), self.args, []) | 784 scm_wrapper_webkit.RunCommand('update', mox.Func(OptIsRev42), self.args, []) |
| 785 | 785 |
| 786 gclient_scm.create_scm( | 786 gclient_scm.SCMWrapper( |
| 787 'http://google-breakpad.googlecode.com/svn/trunk/src@285', | 787 'http://google-breakpad.googlecode.com/svn/trunk/src@285', |
| 788 self.root_dir, 'src/breakpad/bar').AndReturn(scm_wrapper_breakpad) | 788 self.root_dir, 'src/breakpad/bar').AndReturn(scm_wrapper_breakpad) |
| 789 scm_wrapper_breakpad.RunCommand('update', mox.Func(OptIsRevNone), | 789 scm_wrapper_breakpad.RunCommand('update', mox.Func(OptIsRevNone), |
| 790 self.args, []) | 790 self.args, []) |
| 791 | 791 |
| 792 gclient_scm.create_scm(cygwin_path, self.root_dir, | 792 gclient_scm.SCMWrapper(cygwin_path, self.root_dir, |
| 793 'src/third_party/cygwin').AndReturn(scm_wrapper_cygwin) | 793 'src/third_party/cygwin').AndReturn(scm_wrapper_cygwin) |
| 794 scm_wrapper_cygwin.RunCommand('update', mox.Func(OptIsRev333), self.args, | 794 scm_wrapper_cygwin.RunCommand('update', mox.Func(OptIsRev333), self.args, |
| 795 []) | 795 []) |
| 796 | 796 |
| 797 gclient_scm.create_scm('svn://random_server:123/trunk/python_24@5580', | 797 gclient_scm.SCMWrapper('svn://random_server:123/trunk/python_24@5580', |
| 798 self.root_dir, | 798 self.root_dir, |
| 799 'src/third_party/python_24').AndReturn( | 799 'src/third_party/python_24').AndReturn( |
| 800 scm_wrapper_python) | 800 scm_wrapper_python) |
| 801 scm_wrapper_python.RunCommand('update', mox.Func(OptIsRevNone), self.args, | 801 scm_wrapper_python.RunCommand('update', mox.Func(OptIsRevNone), self.args, |
| 802 []) | 802 []) |
| 803 | 803 |
| 804 self.mox.ReplayAll() | 804 self.mox.ReplayAll() |
| 805 client = self._gclient_gclient(self.root_dir, options) | 805 client = self._gclient_gclient(self.root_dir, options) |
| 806 client.SetConfig(gclient_config) | 806 client.SetConfig(gclient_config) |
| 807 client.RunOnDeps('update', self.args) | 807 client.RunOnDeps('update', self.args) |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 863 ).AndReturn(deps_content) | 863 ).AndReturn(deps_content) |
| 864 gclient.FileWrite(os.path.join(self.root_dir, options.entries_filename), | 864 gclient.FileWrite(os.path.join(self.root_dir, options.entries_filename), |
| 865 entries_content) | 865 entries_content) |
| 866 | 866 |
| 867 gclient.os.path.exists(os.path.join(self.root_dir, 'foo/third_party/WebKit', | 867 gclient.os.path.exists(os.path.join(self.root_dir, 'foo/third_party/WebKit', |
| 868 '.git')).AndReturn(False) | 868 '.git')).AndReturn(False) |
| 869 gclient.os.path.exists(os.path.join(self.root_dir, name, '.git') | 869 gclient.os.path.exists(os.path.join(self.root_dir, name, '.git') |
| 870 ).AndReturn(False) | 870 ).AndReturn(False) |
| 871 gclient.os.path.exists(os.path.join(self.root_dir, options.entries_filename) | 871 gclient.os.path.exists(os.path.join(self.root_dir, options.entries_filename) |
| 872 ).AndReturn(False) | 872 ).AndReturn(False) |
| 873 gclient_scm.create_scm(self.url, self.root_dir, name).AndReturn( | 873 gclient_scm.SCMWrapper(self.url, self.root_dir, name).AndReturn( |
| 874 gclient_scm.create_scm) | 874 gclient_scm.SCMWrapper) |
| 875 gclient_scm.create_scm.RunCommand('update', options, self.args, []) | 875 gclient_scm.SCMWrapper.RunCommand('update', options, self.args, []) |
| 876 | 876 |
| 877 gclient_scm.create_scm(self.url, self.root_dir, | 877 gclient_scm.SCMWrapper(self.url, self.root_dir, |
| 878 None).AndReturn(scm_wrapper_src) | 878 None).AndReturn(scm_wrapper_src) |
| 879 scm_wrapper_src.FullUrlForRelativeUrl('/trunk/bar/WebKit' | 879 scm_wrapper_src.FullUrlForRelativeUrl('/trunk/bar/WebKit' |
| 880 ).AndReturn(webkit_path) | 880 ).AndReturn(webkit_path) |
| 881 | 881 |
| 882 gclient_scm.create_scm(webkit_path, self.root_dir, | 882 gclient_scm.SCMWrapper(webkit_path, self.root_dir, |
| 883 'foo/third_party/WebKit').AndReturn(gclient_scm.create_scm) | 883 'foo/third_party/WebKit').AndReturn(gclient_scm.SCMWrapper) |
| 884 gclient_scm.create_scm.RunCommand('update', options, self.args, []) | 884 gclient_scm.SCMWrapper.RunCommand('update', options, self.args, []) |
| 885 | 885 |
| 886 self.mox.ReplayAll() | 886 self.mox.ReplayAll() |
| 887 client = self._gclient_gclient(self.root_dir, options) | 887 client = self._gclient_gclient(self.root_dir, options) |
| 888 client.SetConfig(gclient_config) | 888 client.SetConfig(gclient_config) |
| 889 client.RunOnDeps('update', self.args) | 889 client.RunOnDeps('update', self.args) |
| 890 | 890 |
| 891 def testRunOnDepsSuccessCustomVars(self): | 891 def testRunOnDepsSuccessCustomVars(self): |
| 892 # Fake .gclient file. | 892 # Fake .gclient file. |
| 893 name = 'testRunOnDepsSuccessCustomVars_solution_name' | 893 name = 'testRunOnDepsSuccessCustomVars_solution_name' |
| 894 gclient_config = """solutions = [ { | 894 gclient_config = """solutions = [ { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 919 gclient.FileWrite(os.path.join(self.root_dir, options.entries_filename), | 919 gclient.FileWrite(os.path.join(self.root_dir, options.entries_filename), |
| 920 entries_content) | 920 entries_content) |
| 921 | 921 |
| 922 gclient.os.path.exists(os.path.join(self.root_dir, 'foo/third_party/WebKit', | 922 gclient.os.path.exists(os.path.join(self.root_dir, 'foo/third_party/WebKit', |
| 923 '.git') | 923 '.git') |
| 924 ).AndReturn(False) | 924 ).AndReturn(False) |
| 925 gclient.os.path.exists(os.path.join(self.root_dir, name, '.git') | 925 gclient.os.path.exists(os.path.join(self.root_dir, name, '.git') |
| 926 ).AndReturn(False) | 926 ).AndReturn(False) |
| 927 gclient.os.path.exists(os.path.join(self.root_dir, options.entries_filename) | 927 gclient.os.path.exists(os.path.join(self.root_dir, options.entries_filename) |
| 928 ).AndReturn(False) | 928 ).AndReturn(False) |
| 929 gclient_scm.create_scm(self.url, self.root_dir, name).AndReturn( | 929 gclient_scm.SCMWrapper(self.url, self.root_dir, name).AndReturn( |
| 930 gclient_scm.create_scm) | 930 gclient_scm.SCMWrapper) |
| 931 gclient_scm.create_scm.RunCommand('update', options, self.args, []) | 931 gclient_scm.SCMWrapper.RunCommand('update', options, self.args, []) |
| 932 | 932 |
| 933 gclient_scm.create_scm(self.url, self.root_dir, | 933 gclient_scm.SCMWrapper(self.url, self.root_dir, |
| 934 None).AndReturn(scm_wrapper_src) | 934 None).AndReturn(scm_wrapper_src) |
| 935 scm_wrapper_src.FullUrlForRelativeUrl('/trunk/bar_custom/WebKit' | 935 scm_wrapper_src.FullUrlForRelativeUrl('/trunk/bar_custom/WebKit' |
| 936 ).AndReturn(webkit_path) | 936 ).AndReturn(webkit_path) |
| 937 | 937 |
| 938 gclient_scm.create_scm(webkit_path, self.root_dir, | 938 gclient_scm.SCMWrapper(webkit_path, self.root_dir, |
| 939 'foo/third_party/WebKit').AndReturn(gclient_scm.create_scm) | 939 'foo/third_party/WebKit').AndReturn(gclient_scm.SCMWrapper) |
| 940 gclient_scm.create_scm.RunCommand('update', options, self.args, []) | 940 gclient_scm.SCMWrapper.RunCommand('update', options, self.args, []) |
| 941 | 941 |
| 942 self.mox.ReplayAll() | 942 self.mox.ReplayAll() |
| 943 client = self._gclient_gclient(self.root_dir, options) | 943 client = self._gclient_gclient(self.root_dir, options) |
| 944 client.SetConfig(gclient_config) | 944 client.SetConfig(gclient_config) |
| 945 client.RunOnDeps('update', self.args) | 945 client.RunOnDeps('update', self.args) |
| 946 | 946 |
| 947 def testRunOnDepsFailureVars(self): | 947 def testRunOnDepsFailureVars(self): |
| 948 # Fake .gclient file. | 948 # Fake .gclient file. |
| 949 name = 'testRunOnDepsFailureVars_solution_name' | 949 name = 'testRunOnDepsFailureVars_solution_name' |
| 950 gclient_config = """solutions = [ { | 950 gclient_config = """solutions = [ { |
| 951 'name': '%s', | 951 'name': '%s', |
| 952 'url': '%s', | 952 'url': '%s', |
| 953 'custom_deps': {}, | 953 'custom_deps': {}, |
| 954 'custom_vars': {}, | 954 'custom_vars': {}, |
| 955 }, ]""" % (name, self.url) | 955 }, ]""" % (name, self.url) |
| 956 # Fake DEPS file. | 956 # Fake DEPS file. |
| 957 deps_content = """deps = { | 957 deps_content = """deps = { |
| 958 'foo/third_party/WebKit': Var('webkit') + 'WebKit', | 958 'foo/third_party/WebKit': Var('webkit') + 'WebKit', |
| 959 }""" | 959 }""" |
| 960 | 960 |
| 961 options = self.Options() | 961 options = self.Options() |
| 962 gclient.FileRead(os.path.join(self.root_dir, name, options.deps_file) | 962 gclient.FileRead(os.path.join(self.root_dir, name, options.deps_file) |
| 963 ).AndReturn(deps_content) | 963 ).AndReturn(deps_content) |
| 964 gclient_scm.create_scm(self.url, self.root_dir, name).AndReturn( | 964 gclient_scm.SCMWrapper(self.url, self.root_dir, name).AndReturn( |
| 965 gclient_scm.create_scm) | 965 gclient_scm.SCMWrapper) |
| 966 gclient_scm.create_scm.RunCommand('update', options, self.args, []) | 966 gclient_scm.SCMWrapper.RunCommand('update', options, self.args, []) |
| 967 | 967 |
| 968 self.mox.ReplayAll() | 968 self.mox.ReplayAll() |
| 969 client = self._gclient_gclient(self.root_dir, options) | 969 client = self._gclient_gclient(self.root_dir, options) |
| 970 client.SetConfig(gclient_config) | 970 client.SetConfig(gclient_config) |
| 971 exception = "Var is not defined: webkit" | 971 exception = "Var is not defined: webkit" |
| 972 try: | 972 try: |
| 973 client.RunOnDeps('update', self.args) | 973 client.RunOnDeps('update', self.args) |
| 974 except gclient.Error, e: | 974 except gclient.Error, e: |
| 975 self.assertEquals(e.args[0], exception) | 975 self.assertEquals(e.args[0], exception) |
| 976 else: | 976 else: |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1031 def setUp(self): | 1031 def setUp(self): |
| 1032 GClientBaseTestCase.setUp(self) | 1032 GClientBaseTestCase.setUp(self) |
| 1033 self.root_dir = self.Dir() | 1033 self.root_dir = self.Dir() |
| 1034 self.args = self.Args() | 1034 self.args = self.Args() |
| 1035 self.url = self.Url() | 1035 self.url = self.Url() |
| 1036 self.relpath = 'asf' | 1036 self.relpath = 'asf' |
| 1037 | 1037 |
| 1038 def testDir(self): | 1038 def testDir(self): |
| 1039 members = [ | 1039 members = [ |
| 1040 'FullUrlForRelativeUrl', 'RunCommand', 'cleanup', 'diff', 'export', | 1040 'FullUrlForRelativeUrl', 'RunCommand', 'cleanup', 'diff', 'export', |
| 1041 'pack', 'relpath', 'revert', 'runhooks', 'scm_name', 'status', | 1041 'pack', 'relpath', 'revert', 'scm_name', 'status', 'update', 'url', |
| 1042 'update', 'url', | |
| 1043 ] | 1042 ] |
| 1044 | 1043 |
| 1045 # If you add a member, be sure to add the relevant test! | 1044 # If you add a member, be sure to add the relevant test! |
| 1046 self.compareMembers(self._scm_wrapper(self.url, | 1045 self.compareMembers(self._scm_wrapper(), members) |
| 1047 self.root_dir, | |
| 1048 self.relpath), | |
| 1049 members) | |
| 1050 | |
| 1051 def testUnsupportedSCM(self): | |
| 1052 args = [self.url, self.root_dir, self.relpath] | |
| 1053 kwargs = {'scm_name' : 'foo'} | |
| 1054 exception_msg = 'Unsupported scm %(scm_name)s' % kwargs | |
| 1055 self.assertRaisesError(exception_msg, self._scm_wrapper, *args, **kwargs) | |
| 1056 | 1046 |
| 1057 def testFullUrlForRelativeUrl(self): | 1047 def testFullUrlForRelativeUrl(self): |
| 1058 self.url = 'svn://a/b/c/d' | 1048 self.url = 'svn://a/b/c/d' |
| 1059 | 1049 |
| 1060 self.mox.ReplayAll() | 1050 self.mox.ReplayAll() |
| 1061 scm = self._scm_wrapper(self.url, self.root_dir, self.relpath) | 1051 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, |
| 1052 relpath=self.relpath) |
| 1062 self.assertEqual(scm.FullUrlForRelativeUrl('/crap'), 'svn://a/b/crap') | 1053 self.assertEqual(scm.FullUrlForRelativeUrl('/crap'), 'svn://a/b/crap') |
| 1063 | 1054 |
| 1064 def testRunCommandException(self): | 1055 def testRunCommandException(self): |
| 1065 options = self.Options(verbose=False) | 1056 options = self.Options(verbose=False) |
| 1066 gclient.os.path.exists(os.path.join(self.root_dir, self.relpath, '.git') | 1057 gclient.os.path.exists(os.path.join(self.root_dir, self.relpath, '.git') |
| 1067 ).AndReturn(False) | 1058 ).AndReturn(False) |
| 1068 | 1059 |
| 1069 self.mox.ReplayAll() | 1060 self.mox.ReplayAll() |
| 1070 scm = self._scm_wrapper(self.url, self.root_dir, self.relpath) | 1061 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, |
| 1062 relpath=self.relpath) |
| 1071 exception = "Unsupported argument(s): %s" % ','.join(self.args) | 1063 exception = "Unsupported argument(s): %s" % ','.join(self.args) |
| 1072 self.assertRaisesError(exception, scm.RunCommand, | 1064 self.assertRaisesError(exception, self._scm_wrapper.RunCommand, |
| 1073 'update', options, self.args) | 1065 scm, 'update', options, self.args) |
| 1074 | 1066 |
| 1075 def testRunCommandUnknown(self): | 1067 def testRunCommandUnknown(self): |
| 1076 # TODO(maruel): if ever used. | 1068 # TODO(maruel): if ever used. |
| 1077 pass | 1069 pass |
| 1078 | 1070 |
| 1079 def testRevertMissing(self): | 1071 def testRevertMissing(self): |
| 1080 options = self.Options(verbose=True) | 1072 options = self.Options(verbose=True) |
| 1081 base_path = os.path.join(self.root_dir, self.relpath) | 1073 base_path = os.path.join(self.root_dir, self.relpath) |
| 1082 gclient.os.path.isdir(base_path).AndReturn(False) | 1074 gclient.os.path.isdir(base_path).AndReturn(False) |
| 1083 # It'll to a checkout instead. | 1075 # It'll to a checkout instead. |
| 1084 gclient.os.path.exists(os.path.join(base_path, '.git')).AndReturn(False) | 1076 gclient.os.path.exists(os.path.join(base_path, '.git')).AndReturn(False) |
| 1085 print("\n_____ %s is missing, synching instead" % self.relpath) | 1077 print("\n_____ %s is missing, synching instead" % self.relpath) |
| 1086 # Checkout. | 1078 # Checkout. |
| 1087 gclient.os.path.exists(base_path).AndReturn(False) | 1079 gclient.os.path.exists(base_path).AndReturn(False) |
| 1088 files_list = self.mox.CreateMockAnything() | 1080 files_list = self.mox.CreateMockAnything() |
| 1089 gclient_scm.RunSVNAndGetFileList(['checkout', self.url, base_path], | 1081 gclient_scm.RunSVNAndGetFileList(['checkout', self.url, base_path], |
| 1090 self.root_dir, files_list) | 1082 self.root_dir, files_list) |
| 1091 | 1083 |
| 1092 self.mox.ReplayAll() | 1084 self.mox.ReplayAll() |
| 1093 scm = self._scm_wrapper(self.url, self.root_dir, self.relpath) | 1085 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, |
| 1086 relpath=self.relpath) |
| 1094 scm.revert(options, self.args, files_list) | 1087 scm.revert(options, self.args, files_list) |
| 1095 | 1088 |
| 1096 def testRevertNone(self): | 1089 def testRevertNone(self): |
| 1097 options = self.Options(verbose=True) | 1090 options = self.Options(verbose=True) |
| 1098 base_path = os.path.join(self.root_dir, self.relpath) | 1091 base_path = os.path.join(self.root_dir, self.relpath) |
| 1099 gclient.os.path.isdir(base_path).AndReturn(True) | 1092 gclient.os.path.isdir(base_path).AndReturn(True) |
| 1100 gclient_scm.CaptureSVNStatus(base_path).AndReturn([]) | 1093 gclient_scm.CaptureSVNStatus(base_path).AndReturn([]) |
| 1101 | 1094 |
| 1102 self.mox.ReplayAll() | 1095 self.mox.ReplayAll() |
| 1103 scm = self._scm_wrapper(self.url, self.root_dir, self.relpath) | 1096 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, |
| 1097 relpath=self.relpath) |
| 1104 file_list = [] | 1098 file_list = [] |
| 1105 scm.revert(options, self.args, file_list) | 1099 scm.revert(options, self.args, file_list) |
| 1106 | 1100 |
| 1107 def testRevert2Files(self): | 1101 def testRevert2Files(self): |
| 1108 options = self.Options(verbose=True) | 1102 options = self.Options(verbose=True) |
| 1109 base_path = os.path.join(self.root_dir, self.relpath) | 1103 base_path = os.path.join(self.root_dir, self.relpath) |
| 1110 gclient.os.path.isdir(base_path).AndReturn(True) | 1104 gclient.os.path.isdir(base_path).AndReturn(True) |
| 1111 items = [ | 1105 items = [ |
| 1112 ('M ', 'a'), | 1106 ('M ', 'a'), |
| 1113 ('A ', 'b'), | 1107 ('A ', 'b'), |
| 1114 ] | 1108 ] |
| 1115 gclient_scm.CaptureSVNStatus(base_path).AndReturn(items) | 1109 gclient_scm.CaptureSVNStatus(base_path).AndReturn(items) |
| 1116 | 1110 |
| 1117 print(os.path.join(base_path, 'a')) | 1111 print(os.path.join(base_path, 'a')) |
| 1118 print(os.path.join(base_path, 'b')) | 1112 print(os.path.join(base_path, 'b')) |
| 1119 gclient_scm.RunSVN(['revert', 'a', 'b'], base_path) | 1113 gclient_scm.RunSVN(['revert', 'a', 'b'], base_path) |
| 1120 | 1114 |
| 1121 self.mox.ReplayAll() | 1115 self.mox.ReplayAll() |
| 1122 scm = self._scm_wrapper(self.url, self.root_dir, self.relpath) | 1116 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, |
| 1117 relpath=self.relpath) |
| 1123 file_list = [] | 1118 file_list = [] |
| 1124 scm.revert(options, self.args, file_list) | 1119 scm.revert(options, self.args, file_list) |
| 1125 self.assertEquals(sorted(file_list), sorted([os.path.join(base_path, 'a'), | 1120 self.assertEquals(sorted(file_list), sorted([os.path.join(base_path, 'a'), |
| 1126 os.path.join(base_path, 'b')])) | 1121 os.path.join(base_path, 'b')])) |
| 1127 | 1122 |
| 1128 def testRevertUnversionedUnexpectedFile(self): | 1123 def testRevertUnversionedUnexpectedFile(self): |
| 1129 options = self.Options(verbose=True) | 1124 options = self.Options(verbose=True) |
| 1130 base_path = os.path.join(self.root_dir, self.relpath) | 1125 base_path = os.path.join(self.root_dir, self.relpath) |
| 1131 gclient.os.path.isdir(base_path).AndReturn(True) | 1126 gclient.os.path.isdir(base_path).AndReturn(True) |
| 1132 items = [ | 1127 items = [ |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1148 #self.assertEquals(file_list, [os.path.join(base_path, 'a')]) | 1143 #self.assertEquals(file_list, [os.path.join(base_path, 'a')]) |
| 1149 | 1144 |
| 1150 def testStatus(self): | 1145 def testStatus(self): |
| 1151 options = self.Options(verbose=True) | 1146 options = self.Options(verbose=True) |
| 1152 base_path = os.path.join(self.root_dir, self.relpath) | 1147 base_path = os.path.join(self.root_dir, self.relpath) |
| 1153 gclient.os.path.isdir(base_path).AndReturn(True) | 1148 gclient.os.path.isdir(base_path).AndReturn(True) |
| 1154 gclient_scm.RunSVNAndGetFileList(['status'] + self.args, base_path, | 1149 gclient_scm.RunSVNAndGetFileList(['status'] + self.args, base_path, |
| 1155 []).AndReturn(None) | 1150 []).AndReturn(None) |
| 1156 | 1151 |
| 1157 self.mox.ReplayAll() | 1152 self.mox.ReplayAll() |
| 1158 scm = self._scm_wrapper(self.url, self.root_dir, self.relpath) | 1153 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, |
| 1154 relpath=self.relpath) |
| 1159 file_list = [] | 1155 file_list = [] |
| 1160 self.assertEqual(scm.status(options, self.args, file_list), None) | 1156 self.assertEqual(scm.status(options, self.args, file_list), None) |
| 1161 | 1157 |
| 1162 | 1158 |
| 1163 # TODO(maruel): TEST REVISIONS!!! | 1159 # TODO(maruel): TEST REVISIONS!!! |
| 1164 # TODO(maruel): TEST RELOCATE!!! | 1160 # TODO(maruel): TEST RELOCATE!!! |
| 1165 def testUpdateCheckout(self): | 1161 def testUpdateCheckout(self): |
| 1166 options = self.Options(verbose=True) | 1162 options = self.Options(verbose=True) |
| 1167 base_path = os.path.join(self.root_dir, self.relpath) | 1163 base_path = os.path.join(self.root_dir, self.relpath) |
| 1168 file_info = gclient_utils.PrintableObject() | 1164 file_info = gclient_utils.PrintableObject() |
| 1169 file_info.root = 'blah' | 1165 file_info.root = 'blah' |
| 1170 file_info.url = self.url | 1166 file_info.url = self.url |
| 1171 file_info.uuid = 'ABC' | 1167 file_info.uuid = 'ABC' |
| 1172 file_info.revision = 42 | 1168 file_info.revision = 42 |
| 1173 gclient.os.path.exists(os.path.join(base_path, '.git')).AndReturn(False) | 1169 gclient.os.path.exists(os.path.join(base_path, '.git')).AndReturn(False) |
| 1174 # Checkout. | 1170 # Checkout. |
| 1175 gclient.os.path.exists(base_path).AndReturn(False) | 1171 gclient.os.path.exists(base_path).AndReturn(False) |
| 1176 files_list = self.mox.CreateMockAnything() | 1172 files_list = self.mox.CreateMockAnything() |
| 1177 gclient_scm.RunSVNAndGetFileList(['checkout', self.url, base_path], | 1173 gclient_scm.RunSVNAndGetFileList(['checkout', self.url, base_path], |
| 1178 self.root_dir, files_list) | 1174 self.root_dir, files_list) |
| 1179 self.mox.ReplayAll() | 1175 self.mox.ReplayAll() |
| 1180 scm = self._scm_wrapper(self.url, self.root_dir, self.relpath) | 1176 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, |
| 1177 relpath=self.relpath) |
| 1181 scm.update(options, (), files_list) | 1178 scm.update(options, (), files_list) |
| 1182 | 1179 |
| 1183 def testUpdateUpdate(self): | 1180 def testUpdateUpdate(self): |
| 1184 options = self.Options(verbose=True) | 1181 options = self.Options(verbose=True) |
| 1185 base_path = os.path.join(self.root_dir, self.relpath) | 1182 base_path = os.path.join(self.root_dir, self.relpath) |
| 1186 options.force = True | 1183 options.force = True |
| 1187 options.nohooks = False | 1184 options.nohooks = False |
| 1188 file_info = { | 1185 file_info = { |
| 1189 'Repository Root': 'blah', | 1186 'Repository Root': 'blah', |
| 1190 'URL': self.url, | 1187 'URL': self.url, |
| 1191 'UUID': 'ABC', | 1188 'UUID': 'ABC', |
| 1192 'Revision': 42, | 1189 'Revision': 42, |
| 1193 } | 1190 } |
| 1194 gclient.os.path.exists(os.path.join(base_path, '.git')).AndReturn(False) | 1191 gclient.os.path.exists(os.path.join(base_path, '.git')).AndReturn(False) |
| 1195 # Checkout or update. | 1192 # Checkout or update. |
| 1196 gclient.os.path.exists(base_path).AndReturn(True) | 1193 gclient.os.path.exists(base_path).AndReturn(True) |
| 1197 gclient_scm.CaptureSVNInfo(os.path.join(base_path, "."), '.' | 1194 gclient_scm.CaptureSVNInfo(os.path.join(base_path, "."), '.' |
| 1198 ).AndReturn(file_info) | 1195 ).AndReturn(file_info) |
| 1199 # Cheat a bit here. | 1196 # Cheat a bit here. |
| 1200 gclient_scm.CaptureSVNInfo(file_info['URL'], '.').AndReturn(file_info) | 1197 gclient_scm.CaptureSVNInfo(file_info['URL'], '.').AndReturn(file_info) |
| 1201 additional_args = [] | 1198 additional_args = [] |
| 1202 if options.manually_grab_svn_rev: | 1199 if options.manually_grab_svn_rev: |
| 1203 additional_args = ['--revision', str(file_info['Revision'])] | 1200 additional_args = ['--revision', str(file_info['Revision'])] |
| 1204 files_list = [] | 1201 files_list = [] |
| 1205 gclient_scm.RunSVNAndGetFileList(['update', base_path] + additional_args, | 1202 gclient_scm.RunSVNAndGetFileList(['update', base_path] + additional_args, |
| 1206 self.root_dir, files_list) | 1203 self.root_dir, files_list) |
| 1207 | 1204 |
| 1208 self.mox.ReplayAll() | 1205 self.mox.ReplayAll() |
| 1209 scm = self._scm_wrapper(self.url, self.root_dir, self.relpath) | 1206 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, |
| 1207 relpath=self.relpath) |
| 1210 scm.update(options, (), files_list) | 1208 scm.update(options, (), files_list) |
| 1211 | 1209 |
| 1212 def testUpdateGit(self): | 1210 def testUpdateGit(self): |
| 1213 options = self.Options(verbose=True) | 1211 options = self.Options(verbose=True) |
| 1214 gclient.os.path.exists(os.path.join(self.root_dir, self.relpath, '.git') | 1212 gclient.os.path.exists(os.path.join(self.root_dir, self.relpath, '.git') |
| 1215 ).AndReturn(True) | 1213 ).AndReturn(True) |
| 1216 print("________ found .git directory; skipping %s" % self.relpath) | 1214 print("________ found .git directory; skipping %s" % self.relpath) |
| 1217 | 1215 |
| 1218 self.mox.ReplayAll() | 1216 self.mox.ReplayAll() |
| 1219 scm = self._scm_wrapper(self.url, self.root_dir, self.relpath) | 1217 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, |
| 1218 relpath=self.relpath) |
| 1220 file_list = [] | 1219 file_list = [] |
| 1221 scm.update(options, self.args, file_list) | 1220 scm.update(options, self.args, file_list) |
| 1222 | 1221 |
| 1223 def testGetSVNFileInfo(self): | 1222 def testGetSVNFileInfo(self): |
| 1224 xml_text = r"""<?xml version="1.0"?> | 1223 xml_text = r"""<?xml version="1.0"?> |
| 1225 <info> | 1224 <info> |
| 1226 <entry kind="file" path="%s" revision="14628"> | 1225 <entry kind="file" path="%s" revision="14628"> |
| 1227 <url>http://src.chromium.org/svn/trunk/src/chrome/app/d</url> | 1226 <url>http://src.chromium.org/svn/trunk/src/chrome/app/d</url> |
| 1228 <repository><root>http://src.chromium.org/svn</root></repository> | 1227 <repository><root>http://src.chromium.org/svn</root></repository> |
| 1229 <wc-info> | 1228 <wc-info> |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1408 """ | 1407 """ |
| 1409 gclient_scm.CaptureSVN = CaptureSVNMock | 1408 gclient_scm.CaptureSVN = CaptureSVNMock |
| 1410 info = gclient_scm.CaptureSVNStatus(None) | 1409 info = gclient_scm.CaptureSVNStatus(None) |
| 1411 self.assertEquals(info, []) | 1410 self.assertEquals(info, []) |
| 1412 | 1411 |
| 1413 | 1412 |
| 1414 if __name__ == '__main__': | 1413 if __name__ == '__main__': |
| 1415 unittest.main() | 1414 unittest.main() |
| 1416 | 1415 |
| 1417 # vim: ts=2:sw=2:tw=80:et: | 1416 # vim: ts=2:sw=2:tw=80:et: |
| OLD | NEW |