Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(188)

Side by Side Diff: tests/gclient_test.py

Issue 254012: gclient: fix unittests (Closed)
Patch Set: Remove old code Created 11 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 solution_name = 'testRunOnDepsNoDeps_solution_name' 387 solution_name = 'testRunOnDepsNoDeps_solution_name'
388 gclient_config = ( 388 gclient_config = (
389 "solutions = [ {\n" 389 "solutions = [ {\n"
390 " 'name': '%s',\n" 390 " 'name': '%s',\n"
391 " 'url': '%s',\n" 391 " 'url': '%s',\n"
392 " 'custom_deps': {},\n" 392 " 'custom_deps': {},\n"
393 "} ]\n" 393 "} ]\n"
394 ) % (solution_name, self.url) 394 ) % (solution_name, self.url)
395 395
396 entries_content = ( 396 entries_content = (
397 'entries = [\n' 397 "entries = \\\n"
398 ' "%s",\n' 398 "{ '%s': '%s'}\n"
399 ']\n' 399 ) % (solution_name, self.url)
400 ) % solution_name
401 400
402 options = self.Options() 401 options = self.Options()
403 402
404 checkout_path = os.path.join(self.root_dir, solution_name) 403 checkout_path = os.path.join(self.root_dir, solution_name)
405 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)
406 # 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.
407 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)
408 ).AndReturn(False) 407 ).AndReturn(False)
409 408
410 # An scm will be requested for the solution. 409 # An scm will be requested for the solution.
(...skipping 27 matching lines...) Expand all
438 "} ]\n" 437 "} ]\n"
439 ) % (solution_name, self.url) 438 ) % (solution_name, self.url)
440 439
441 deps = ( 440 deps = (
442 "use_relative_paths = True\n" 441 "use_relative_paths = True\n"
443 "deps = {\n" 442 "deps = {\n"
444 " 'src/t': 'svn://scm.t/trunk',\n" 443 " 'src/t': 'svn://scm.t/trunk',\n"
445 "}\n") 444 "}\n")
446 445
447 entries_content = ( 446 entries_content = (
448 'entries = [\n' 447 "entries = \\\n"
449 ' "%s",\n' 448 "{ '%s': '%s',\n"
450 ' "%s",\n' 449 " '%s': 'svn://scm.t/trunk'}\n"
451 ']\n' 450 ) % (solution_name, self.url, os.path.join(solution_name, 'src', 't'))
452 ) % (os.path.join(solution_name, 'src', 't'), solution_name)
453 451
454 scm_wrapper_sol = self.mox.CreateMockAnything() 452 scm_wrapper_sol = self.mox.CreateMockAnything()
455 scm_wrapper_t = self.mox.CreateMockAnything() 453 scm_wrapper_t = self.mox.CreateMockAnything()
456 454
457 options = self.Options() 455 options = self.Options()
458 456
459 gclient.os.path.exists(os.path.join(self.root_dir, solution_name, 'src', 457 gclient.os.path.exists(os.path.join(self.root_dir, solution_name, 'src',
460 't', '.git') 458 't', '.git')
461 ).AndReturn(False) 459 ).AndReturn(False)
462 gclient.os.path.exists(os.path.join(self.root_dir, solution_name, '.git') 460 gclient.os.path.exists(os.path.join(self.root_dir, solution_name, '.git')
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 ) % (solution_name, self.url) 506 ) % (solution_name, self.url)
509 507
510 deps = ( 508 deps = (
511 "deps = {\n" 509 "deps = {\n"
512 " 'src/b': 'svn://original.b/trunk',\n" 510 " 'src/b': 'svn://original.b/trunk',\n"
513 " 'src/t': 'svn://original.t/trunk',\n" 511 " 'src/t': 'svn://original.t/trunk',\n"
514 "}\n" 512 "}\n"
515 ) 513 )
516 514
517 entries_content = ( 515 entries_content = (
518 'entries = [\n' 516 "entries = \\\n"
519 ' "%s",\n' 517 "{ 'src/n': 'svn://custom.n/trunk',\n"
520 ' "src/n",\n' 518 " 'src/t': 'svn://custom.t/trunk',\n"
521 ' "src/t",\n' 519 " '%s': '%s'}\n"
522 ']\n' 520 ) % (solution_name, self.url)
523 ) % solution_name
524 521
525 scm_wrapper_sol = self.mox.CreateMockAnything() 522 scm_wrapper_sol = self.mox.CreateMockAnything()
526 scm_wrapper_t = self.mox.CreateMockAnything() 523 scm_wrapper_t = self.mox.CreateMockAnything()
527 scm_wrapper_n = self.mox.CreateMockAnything() 524 scm_wrapper_n = self.mox.CreateMockAnything()
528 525
529 options = self.Options() 526 options = self.Options()
530 527
531 checkout_path = os.path.join(self.root_dir, solution_name) 528 checkout_path = os.path.join(self.root_dir, solution_name)
532 gclient.os.path.exists(os.path.join(checkout_path, '.git')).AndReturn(False) 529 gclient.os.path.exists(os.path.join(checkout_path, '.git')).AndReturn(False)
533 gclient.os.path.exists(os.path.join(self.root_dir, 'src/n', '.git') 530 gclient.os.path.exists(os.path.join(self.root_dir, 'src/n', '.git')
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
596 " 'url': '%s',\n" 593 " 'url': '%s',\n"
597 " 'custom_deps': {},\n" 594 " 'custom_deps': {},\n"
598 "}\n]\n") % (name_a, url_a, name_b, url_b) 595 "}\n]\n") % (name_a, url_a, name_b, url_b)
599 596
600 deps_b = deps_a = ( 597 deps_b = deps_a = (
601 "deps = {\n" 598 "deps = {\n"
602 " 'src/t' : 'http://svn.t/trunk',\n" 599 " 'src/t' : 'http://svn.t/trunk',\n"
603 "}\n") 600 "}\n")
604 601
605 entries_content = ( 602 entries_content = (
606 'entries = [\n "%s",\n' 603 "entries = \\\n"
607 ' "%s",\n' 604 "{ 'src/t': 'http://svn.t/trunk',\n"
608 ' "src/t",\n' 605 " '%s': '%s',\n"
609 ']\n') % (name_a, name_b) 606 " '%s': '%s'}\n"
607 ) % (name_a, url_a, name_b, url_b)
610 608
611 scm_wrapper_a = self.mox.CreateMockAnything() 609 scm_wrapper_a = self.mox.CreateMockAnything()
612 scm_wrapper_b = self.mox.CreateMockAnything() 610 scm_wrapper_b = self.mox.CreateMockAnything()
613 scm_wrapper_dep = self.mox.CreateMockAnything() 611 scm_wrapper_dep = self.mox.CreateMockAnything()
614 612
615 options = self.Options() 613 options = self.Options()
616 614
617 gclient.os.path.exists(os.path.join(self.root_dir, name_a, '.git') 615 gclient.os.path.exists(os.path.join(self.root_dir, name_a, '.git')
618 ).AndReturn(False) 616 ).AndReturn(False)
619 gclient.os.path.exists(os.path.join(self.root_dir, name_b, '.git') 617 gclient.os.path.exists(os.path.join(self.root_dir, name_b, '.git')
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
660 658
661 def testRunOnDepsSuccess(self): 659 def testRunOnDepsSuccess(self):
662 # Fake .gclient file. 660 # Fake .gclient file.
663 name = 'testRunOnDepsSuccess_solution_name' 661 name = 'testRunOnDepsSuccess_solution_name'
664 gclient_config = """solutions = [ { 662 gclient_config = """solutions = [ {
665 'name': '%s', 663 'name': '%s',
666 'url': '%s', 664 'url': '%s',
667 'custom_deps': {}, 665 'custom_deps': {},
668 }, ]""" % (name, self.url) 666 }, ]""" % (name, self.url)
669 667
668 entries_content = (
669 "entries = \\\n"
670 "{ '%s': '%s'}\n"
671 ) % (name, self.url)
672
670 options = self.Options() 673 options = self.Options()
671 gclient.os.path.exists(os.path.join(self.root_dir, name, '.git') 674 gclient.os.path.exists(os.path.join(self.root_dir, name, '.git')
672 ).AndReturn(False) 675 ).AndReturn(False)
673 gclient.os.path.exists(os.path.join(self.root_dir, options.entries_filename) 676 gclient.os.path.exists(os.path.join(self.root_dir, options.entries_filename)
674 ).AndReturn(False) 677 ).AndReturn(False)
675 gclient_scm.CreateSCM(self.url, self.root_dir, name).AndReturn( 678 gclient_scm.CreateSCM(self.url, self.root_dir, name).AndReturn(
676 gclient_scm.CreateSCM) 679 gclient_scm.CreateSCM)
677 gclient_scm.CreateSCM.RunCommand('update', options, self.args, []) 680 gclient_scm.CreateSCM.RunCommand('update', options, self.args, [])
678 gclient.FileRead(os.path.join(self.root_dir, name, options.deps_file) 681 gclient.FileRead(os.path.join(self.root_dir, name, options.deps_file)
679 ).AndReturn("Boo = 'a'") 682 ).AndReturn("Boo = 'a'")
680 gclient.FileWrite(os.path.join(self.root_dir, options.entries_filename), 683 gclient.FileWrite(os.path.join(self.root_dir, options.entries_filename),
681 'entries = [\n "%s",\n]\n' % name) 684 entries_content)
682 685
683 self.mox.ReplayAll() 686 self.mox.ReplayAll()
684 client = self._gclient_gclient(self.root_dir, options) 687 client = self._gclient_gclient(self.root_dir, options)
685 client.SetConfig(gclient_config) 688 client.SetConfig(gclient_config)
686 client.RunOnDeps('update', self.args) 689 client.RunOnDeps('update', self.args)
687 690
688 def testRunOnDepsRevisions(self): 691 def testRunOnDepsRevisions(self):
689 def OptIsRev(options, rev): 692 def OptIsRev(options, rev):
690 if not options.revision == str(rev): 693 if not options.revision == str(rev):
691 print("options.revision = %s" % options.revision) 694 print("options.revision = %s" % options.revision)
(...skipping 22 matching lines...) Expand all
714 'src/third_party/cygwin': '/trunk/deps/third_party/cygwin@3248', 717 'src/third_party/cygwin': '/trunk/deps/third_party/cygwin@3248',
715 } 718 }
716 deps_os = { 719 deps_os = {
717 'win': { 720 'win': {
718 'src/foosad/asdf': 'svn://random_server:123/asd/python_24@5580', 721 'src/foosad/asdf': 'svn://random_server:123/asd/python_24@5580',
719 }, 722 },
720 'mac': { 723 'mac': {
721 'src/third_party/python_24': 'svn://random_server:123/trunk/python_24@5580', 724 'src/third_party/python_24': 'svn://random_server:123/trunk/python_24@5580',
722 }, 725 },
723 }""" 726 }"""
724 entries_content = ( 727
725 'entries = [\n "src",\n'
726 ' "foo/third_party/WebKit",\n'
727 ' "src/third_party/cygwin",\n'
728 ' "src/third_party/python_24",\n'
729 ' "src/breakpad/bar",\n'
730 ']\n')
731 cygwin_path = 'dummy path cygwin' 728 cygwin_path = 'dummy path cygwin'
732 webkit_path = 'dummy path webkit' 729 webkit_path = 'dummy path webkit'
733 730
731 entries_content = (
732 "entries = \\\n"
733 "{ 'foo/third_party/WebKit': '%s',\n"
734 " 'src': '%s',\n"
735 " 'src/breakpad/bar':"
736 " 'http://google-breakpad.googlecode.com/svn/trunk/src@285',\n"
737 " 'src/third_party/cygwin': '%s',\n"
738 " 'src/third_party/python_24':"
739 " 'svn://random_server:123/trunk/python_24@5580'}\n"
740 ) % (webkit_path, self.url, cygwin_path)
741
734 scm_wrapper_bleh = self.mox.CreateMockAnything() 742 scm_wrapper_bleh = self.mox.CreateMockAnything()
735 scm_wrapper_src = self.mox.CreateMockAnything() 743 scm_wrapper_src = self.mox.CreateMockAnything()
736 scm_wrapper_src2 = self.mox.CreateMockAnything() 744 scm_wrapper_src2 = self.mox.CreateMockAnything()
737 scm_wrapper_webkit = self.mox.CreateMockAnything() 745 scm_wrapper_webkit = self.mox.CreateMockAnything()
738 scm_wrapper_breakpad = self.mox.CreateMockAnything() 746 scm_wrapper_breakpad = self.mox.CreateMockAnything()
739 scm_wrapper_cygwin = self.mox.CreateMockAnything() 747 scm_wrapper_cygwin = self.mox.CreateMockAnything()
740 scm_wrapper_python = self.mox.CreateMockAnything() 748 scm_wrapper_python = self.mox.CreateMockAnything()
741 options = self.Options() 749 options = self.Options()
742 options.revisions = [ 'src@123', 'foo/third_party/WebKit@42', 750 options.revisions = [ 'src@123', 'foo/third_party/WebKit@42',
743 'src/third_party/cygwin@333' ] 751 'src/third_party/cygwin@333' ]
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
843 'custom_deps': {}, 851 'custom_deps': {},
844 'custom_vars': {}, 852 'custom_vars': {},
845 }, ]""" % (name, self.url) 853 }, ]""" % (name, self.url)
846 # Fake DEPS file. 854 # Fake DEPS file.
847 deps_content = """vars = { 855 deps_content = """vars = {
848 'webkit': '/trunk/bar/', 856 'webkit': '/trunk/bar/',
849 } 857 }
850 deps = { 858 deps = {
851 'foo/third_party/WebKit': Var('webkit') + 'WebKit', 859 'foo/third_party/WebKit': Var('webkit') + 'WebKit',
852 }""" 860 }"""
861
862 webkit_path = 'dummy path webkit'
863
853 entries_content = ( 864 entries_content = (
854 'entries = [\n "foo/third_party/WebKit",\n' 865 "entries = \\\n"
855 ' "%s",\n' 866 "{ 'foo/third_party/WebKit': '%s',\n"
856 ']\n') % name 867 " '%s': '%s'}\n"
857 webkit_path = 'dummy path webkit' 868 ) % (webkit_path, name, self.url)
858 869
859 scm_wrapper_webkit = self.mox.CreateMockAnything() 870 scm_wrapper_webkit = self.mox.CreateMockAnything()
860 scm_wrapper_src = self.mox.CreateMockAnything() 871 scm_wrapper_src = self.mox.CreateMockAnything()
861 872
862 options = self.Options() 873 options = self.Options()
863 gclient.FileRead(os.path.join(self.root_dir, name, options.deps_file) 874 gclient.FileRead(os.path.join(self.root_dir, name, options.deps_file)
864 ).AndReturn(deps_content) 875 ).AndReturn(deps_content)
865 gclient.FileWrite(os.path.join(self.root_dir, options.entries_filename), 876 gclient.FileWrite(os.path.join(self.root_dir, options.entries_filename),
866 entries_content) 877 entries_content)
867 878
(...skipping 30 matching lines...) Expand all
898 'custom_deps': {}, 909 'custom_deps': {},
899 'custom_vars': {'webkit': '/trunk/bar_custom/'}, 910 'custom_vars': {'webkit': '/trunk/bar_custom/'},
900 }, ]""" % (name, self.url) 911 }, ]""" % (name, self.url)
901 # Fake DEPS file. 912 # Fake DEPS file.
902 deps_content = """vars = { 913 deps_content = """vars = {
903 'webkit': '/trunk/bar/', 914 'webkit': '/trunk/bar/',
904 } 915 }
905 deps = { 916 deps = {
906 'foo/third_party/WebKit': Var('webkit') + 'WebKit', 917 'foo/third_party/WebKit': Var('webkit') + 'WebKit',
907 }""" 918 }"""
919
920 webkit_path = 'dummy path webkit'
921
908 entries_content = ( 922 entries_content = (
909 'entries = [\n "foo/third_party/WebKit",\n' 923 "entries = \\\n"
910 ' "%s",\n' 924 "{ 'foo/third_party/WebKit': '%s',\n"
911 ']\n') % name 925 " '%s': '%s'}\n"
912 webkit_path = 'dummy path webkit' 926 ) % (webkit_path, name, self.url)
913 927
914 scm_wrapper_webkit = self.mox.CreateMockAnything() 928 scm_wrapper_webkit = self.mox.CreateMockAnything()
915 scm_wrapper_src = self.mox.CreateMockAnything() 929 scm_wrapper_src = self.mox.CreateMockAnything()
916 930
917 options = self.Options() 931 options = self.Options()
918 gclient.FileRead(os.path.join(self.root_dir, name, options.deps_file) 932 gclient.FileRead(os.path.join(self.root_dir, name, options.deps_file)
919 ).AndReturn(deps_content) 933 ).AndReturn(deps_content)
920 gclient.FileWrite(os.path.join(self.root_dir, options.entries_filename), 934 gclient.FileWrite(os.path.join(self.root_dir, options.entries_filename),
921 entries_content) 935 entries_content)
922 936
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
1125 """ 1139 """
1126 gclient_scm.CaptureSVN = CaptureSVNMock 1140 gclient_scm.CaptureSVN = CaptureSVNMock
1127 info = gclient_scm.CaptureSVNStatus(None) 1141 info = gclient_scm.CaptureSVNStatus(None)
1128 self.assertEquals(info, []) 1142 self.assertEquals(info, [])
1129 1143
1130 1144
1131 if __name__ == '__main__': 1145 if __name__ == '__main__':
1132 unittest.main() 1146 unittest.main()
1133 1147
1134 # vim: ts=2:sw=2:tw=80:et: 1148 # vim: ts=2:sw=2:tw=80:et:
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698