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.SCMWrapper | 73 self._scm_wrapper = gclient_scm.CreateSCM |
74 gclient_scm.SCMWrapper = self.mox.CreateMockAnything() | 74 gclient_scm.CreateSCM = 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.SCMWrapper = self._scm_wrapper | 78 gclient_scm.CreateSCM = 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.SCMWrapper(self.url, self.root_dir, solution_name | 411 gclient_scm.CreateSCM(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.SCMWrapper(self.url, self.root_dir, solution_name | 468 gclient_scm.CreateSCM(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.SCMWrapper( | 480 gclient_scm.CreateSCM( |
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.SCMWrapper(self.url, self.root_dir, solution_name | 542 gclient_scm.CreateSCM(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.SCMWrapper('svn://custom.n/trunk', | 552 gclient_scm.CreateSCM('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.SCMWrapper('svn://custom.t/trunk', | 558 gclient_scm.CreateSCM('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.SCMWrapper(url_a, self.root_dir, name_a).AndReturn( | 628 gclient_scm.CreateSCM(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.SCMWrapper(url_b, self.root_dir, name_b).AndReturn( | 637 gclient_scm.CreateSCM(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.SCMWrapper('http://svn.t/trunk', self.root_dir, 'src/t' | 646 gclient_scm.CreateSCM('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.SCMWrapper(self.url, self.root_dir, name).AndReturn( | 674 gclient_scm.CreateSCM(self.url, self.root_dir, name).AndReturn( |
675 gclient_scm.SCMWrapper) | 675 gclient_scm.CreateSCM) |
676 gclient_scm.SCMWrapper.RunCommand('update', options, self.args, []) | 676 gclient_scm.CreateSCM.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.SCMWrapper(self.url, self.root_dir, 'src').AndReturn( | 768 gclient_scm.CreateSCM(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.SCMWrapper(self.url, self.root_dir, | 772 gclient_scm.CreateSCM(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.SCMWrapper(self.url, self.root_dir, | 777 gclient_scm.CreateSCM(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.SCMWrapper(webkit_path, self.root_dir, | 782 gclient_scm.CreateSCM(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.SCMWrapper( | 786 gclient_scm.CreateSCM( |
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.SCMWrapper(cygwin_path, self.root_dir, | 792 gclient_scm.CreateSCM(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.SCMWrapper('svn://random_server:123/trunk/python_24@5580', | 797 gclient_scm.CreateSCM('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.SCMWrapper(self.url, self.root_dir, name).AndReturn( | 873 gclient_scm.CreateSCM(self.url, self.root_dir, name).AndReturn( |
874 gclient_scm.SCMWrapper) | 874 gclient_scm.CreateSCM) |
875 gclient_scm.SCMWrapper.RunCommand('update', options, self.args, []) | 875 gclient_scm.CreateSCM.RunCommand('update', options, self.args, []) |
876 | 876 |
877 gclient_scm.SCMWrapper(self.url, self.root_dir, | 877 gclient_scm.CreateSCM(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.SCMWrapper(webkit_path, self.root_dir, | 882 gclient_scm.CreateSCM(webkit_path, self.root_dir, |
883 'foo/third_party/WebKit').AndReturn(gclient_scm.SCMWrapper) | 883 'foo/third_party/WebKit').AndReturn(gclient_scm.CreateSCM) |
884 gclient_scm.SCMWrapper.RunCommand('update', options, self.args, []) | 884 gclient_scm.CreateSCM.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.SCMWrapper(self.url, self.root_dir, name).AndReturn( | 929 gclient_scm.CreateSCM(self.url, self.root_dir, name).AndReturn( |
930 gclient_scm.SCMWrapper) | 930 gclient_scm.CreateSCM) |
931 gclient_scm.SCMWrapper.RunCommand('update', options, self.args, []) | 931 gclient_scm.CreateSCM.RunCommand('update', options, self.args, []) |
932 | 932 |
933 gclient_scm.SCMWrapper(self.url, self.root_dir, | 933 gclient_scm.CreateSCM(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.SCMWrapper(webkit_path, self.root_dir, | 938 gclient_scm.CreateSCM(webkit_path, self.root_dir, |
939 'foo/third_party/WebKit').AndReturn(gclient_scm.SCMWrapper) | 939 'foo/third_party/WebKit').AndReturn(gclient_scm.CreateSCM) |
940 gclient_scm.SCMWrapper.RunCommand('update', options, self.args, []) | 940 gclient_scm.CreateSCM.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.SCMWrapper(self.url, self.root_dir, name).AndReturn( | 964 gclient_scm.CreateSCM(self.url, self.root_dir, name).AndReturn( |
965 gclient_scm.SCMWrapper) | 965 gclient_scm.CreateSCM) |
966 gclient_scm.SCMWrapper.RunCommand('update', options, self.args, []) | 966 gclient_scm.CreateSCM.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', 'scm_name', 'status', 'update', 'url', | 1041 'pack', 'relpath', 'revert', 'runhooks', 'scm_name', 'status', |
| 1042 'update', 'url', |
1042 ] | 1043 ] |
1043 | 1044 |
1044 # If you add a member, be sure to add the relevant test! | 1045 # If you add a member, be sure to add the relevant test! |
1045 self.compareMembers(self._scm_wrapper(), members) | 1046 self.compareMembers(self._scm_wrapper(), members) |
1046 | 1047 |
| 1048 def testUnsupportedSCM(self): |
| 1049 args = [self.url, self.root_dir, self.relpath] |
| 1050 kwargs = {'scm_name' : 'foo'} |
| 1051 exception_msg = 'Unsupported scm %(scm_name)s' % kwargs |
| 1052 self.assertRaisesError(exception_msg, self._scm_wrapper, *args, **kwargs) |
| 1053 |
1047 def testFullUrlForRelativeUrl(self): | 1054 def testFullUrlForRelativeUrl(self): |
1048 self.url = 'svn://a/b/c/d' | 1055 self.url = 'svn://a/b/c/d' |
1049 | 1056 |
1050 self.mox.ReplayAll() | 1057 self.mox.ReplayAll() |
1051 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, | 1058 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, |
1052 relpath=self.relpath) | 1059 relpath=self.relpath) |
1053 self.assertEqual(scm.FullUrlForRelativeUrl('/crap'), 'svn://a/b/crap') | 1060 self.assertEqual(scm.FullUrlForRelativeUrl('/crap'), 'svn://a/b/crap') |
1054 | 1061 |
1055 def testRunCommandException(self): | 1062 def testRunCommandException(self): |
1056 options = self.Options(verbose=False) | 1063 options = self.Options(verbose=False) |
1057 gclient.os.path.exists(os.path.join(self.root_dir, self.relpath, '.git') | 1064 gclient.os.path.exists(os.path.join(self.root_dir, self.relpath, '.git') |
1058 ).AndReturn(False) | 1065 ).AndReturn(False) |
1059 | 1066 |
1060 self.mox.ReplayAll() | 1067 self.mox.ReplayAll() |
1061 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, | 1068 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, |
1062 relpath=self.relpath) | 1069 relpath=self.relpath) |
1063 exception = "Unsupported argument(s): %s" % ','.join(self.args) | 1070 exception = "Unsupported argument(s): %s" % ','.join(self.args) |
1064 self.assertRaisesError(exception, self._scm_wrapper.RunCommand, | 1071 self.assertRaisesError(exception, scm.RunCommand, |
1065 scm, 'update', options, self.args) | 1072 'update', options, self.args) |
1066 | 1073 |
1067 def testRunCommandUnknown(self): | 1074 def testRunCommandUnknown(self): |
1068 # TODO(maruel): if ever used. | 1075 # TODO(maruel): if ever used. |
1069 pass | 1076 pass |
1070 | 1077 |
1071 def testRevertMissing(self): | 1078 def testRevertMissing(self): |
1072 options = self.Options(verbose=True) | 1079 options = self.Options(verbose=True) |
1073 base_path = os.path.join(self.root_dir, self.relpath) | 1080 base_path = os.path.join(self.root_dir, self.relpath) |
1074 gclient.os.path.isdir(base_path).AndReturn(False) | 1081 gclient.os.path.isdir(base_path).AndReturn(False) |
1075 # It'll to a checkout instead. | 1082 # It'll to a checkout instead. |
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1407 """ | 1414 """ |
1408 gclient_scm.CaptureSVN = CaptureSVNMock | 1415 gclient_scm.CaptureSVN = CaptureSVNMock |
1409 info = gclient_scm.CaptureSVNStatus(None) | 1416 info = gclient_scm.CaptureSVNStatus(None) |
1410 self.assertEquals(info, []) | 1417 self.assertEquals(info, []) |
1411 | 1418 |
1412 | 1419 |
1413 if __name__ == '__main__': | 1420 if __name__ == '__main__': |
1414 unittest.main() | 1421 unittest.main() |
1415 | 1422 |
1416 # vim: ts=2:sw=2:tw=80:et: | 1423 # vim: ts=2:sw=2:tw=80:et: |
OLD | NEW |