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

Side by Side Diff: tests/gclient_test.py

Issue 1730014: Revert r45652 and r45653. It broke the single file export... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools/
Patch Set: Created 10 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « gclient_utils.py ('k') | 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 # Copyright (c) 2010 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2010 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """Unit tests for gclient.py.""" 6 """Unit tests for gclient.py."""
7 7
8 # Fixes include path. 8 # Fixes include path.
9 from super_mox import mox, SuperMoxTestBase 9 from super_mox import mox, SuperMoxTestBase
10 10
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 gclient.GClient = self._gclient_gclient 48 gclient.GClient = self._gclient_gclient
49 gclient.gclient_scm.CreateSCM = self._scm_wrapper 49 gclient.gclient_scm.CreateSCM = self._scm_wrapper
50 BaseTestCase.tearDown(self) 50 BaseTestCase.tearDown(self)
51 51
52 52
53 class GclientTestCase(GClientBaseTestCase): 53 class GclientTestCase(GClientBaseTestCase):
54 class OptionsObject(object): 54 class OptionsObject(object):
55 def __init__(self, test_case, verbose=False, spec=None, 55 def __init__(self, test_case, verbose=False, spec=None,
56 config_filename='a_file_name', 56 config_filename='a_file_name',
57 entries_filename='a_entry_file_name', 57 entries_filename='a_entry_file_name',
58 deps_file='a_deps_file_name', force=False, nohooks=False, 58 deps_file='a_deps_file_name', force=False, nohooks=False):
59 jobs=1):
60 self.verbose = verbose 59 self.verbose = verbose
61 self.spec = spec 60 self.spec = spec
62 self.name = None 61 self.name = None
63 self.config_filename = config_filename 62 self.config_filename = config_filename
64 self.entries_filename = entries_filename 63 self.entries_filename = entries_filename
65 self.deps_file = deps_file 64 self.deps_file = deps_file
66 self.force = force 65 self.force = force
67 self.nohooks = nohooks 66 self.nohooks = nohooks
68 self.jobs = jobs
69 self.revision = None
70 self.revisions = [] 67 self.revisions = []
71 self.manually_grab_svn_rev = True 68 self.manually_grab_svn_rev = True
72 self.deps_os = None 69 self.deps_os = None
73 self.head = False 70 self.head = False
74 71
75 # Mox 72 # Mox
76 self.platform = test_case.platform 73 self.platform = test_case.platform
77 74
78 def setUp(self): 75 def setUp(self):
79 GClientBaseTestCase.setUp(self) 76 GClientBaseTestCase.setUp(self)
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 289
293 class TestDoRevert(GenericCommandTestCase): 290 class TestDoRevert(GenericCommandTestCase):
294 def testBasic(self): 291 def testBasic(self):
295 self.ReturnValue('revert', gclient.DoRevert, 0) 292 self.ReturnValue('revert', gclient.DoRevert, 0)
296 def testError(self): 293 def testError(self):
297 self.ReturnValue('revert', gclient.DoRevert, 42) 294 self.ReturnValue('revert', gclient.DoRevert, 42)
298 def testBadClient(self): 295 def testBadClient(self):
299 self.BadClient(gclient.DoRevert) 296 self.BadClient(gclient.DoRevert)
300 297
301 298
302 def CompareOptions(options):
303 def _Compare(other):
304 options_keys = [i for i in dir(options) if not i.startswith('_')]
305 other_keys = [i for i in dir(other) if not i.startswith('_')]
306 if set(options_keys) != set(other_keys):
307 return False
308 try:
309 for key in options_keys:
310 if getattr(options, key) != getattr(other, key):
311 return False
312 return True
313 except AttributeError:
314 return False
315 return _Compare
316
317 class GClientClassTestCase(GclientTestCase): 299 class GClientClassTestCase(GclientTestCase):
318 def testDir(self): 300 def testDir(self):
319 members = [ 301 members = [
320 'ConfigContent', 'FileImpl', 'FromImpl', 'GetVar', 'LoadCurrentConfig', 302 'ConfigContent', 'FileImpl', 'FromImpl', 'GetVar', 'LoadCurrentConfig',
321 'RunOnDeps', 'SaveConfig', 'SetConfig', 'SetDefaultConfig', 303 'RunOnDeps', 'SaveConfig', 'SetConfig', 'SetDefaultConfig',
322 'supported_commands', 'PrintRevInfo', 'GetSCMCommandClosure', 304 'supported_commands', 'PrintRevInfo',
323 ] 305 ]
324 306
325 # If you add a member, be sure to add the relevant test! 307 # If you add a member, be sure to add the relevant test!
326 self.compareMembers(self._gclient_gclient('root_dir', 'options'), members) 308 self.compareMembers(self._gclient_gclient('root_dir', 'options'), members)
327 309
328 def testSetConfig_ConfigContent_GetVar_SaveConfig_SetDefaultConfig(self): 310 def testSetConfig_ConfigContent_GetVar_SaveConfig_SetDefaultConfig(self):
329 options = self.Options() 311 options = self.Options()
330 text = "# Dummy content\nclient = 'my client'" 312 text = "# Dummy content\nclient = 'my client'"
331 gclient.gclient_utils.FileWrite( 313 gclient.gclient_utils.FileWrite(
332 gclient.os.path.join(self.root_dir, options.config_filename), 314 gclient.os.path.join(self.root_dir, options.config_filename),
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 # Expect a check for the entries file and we say there is not one. 377 # Expect a check for the entries file and we say there is not one.
396 gclient.os.path.exists( 378 gclient.os.path.exists(
397 gclient.os.path.join(self.root_dir, options.entries_filename) 379 gclient.os.path.join(self.root_dir, options.entries_filename)
398 ).AndReturn(False) 380 ).AndReturn(False)
399 381
400 # An scm will be requested for the solution. 382 # An scm will be requested for the solution.
401 scm_wrapper_sol = self.mox.CreateMockAnything() 383 scm_wrapper_sol = self.mox.CreateMockAnything()
402 gclient.gclient_scm.CreateSCM(self.url, self.root_dir, solution_name 384 gclient.gclient_scm.CreateSCM(self.url, self.root_dir, solution_name
403 ).AndReturn(scm_wrapper_sol) 385 ).AndReturn(scm_wrapper_sol)
404 # Then an update will be performed. 386 # Then an update will be performed.
405 scm_wrapper_sol.RunCommand('update', mox.Func(CompareOptions(options)), 387 scm_wrapper_sol.RunCommand('update', options, self.args, [])
406 self.args, [])
407 # Then an attempt will be made to read its DEPS file. 388 # Then an attempt will be made to read its DEPS file.
408 gclient.gclient_utils.FileRead( 389 gclient.gclient_utils.FileRead(
409 gclient.os.path.join(self.root_dir, solution_name, options.deps_file) 390 gclient.os.path.join(self.root_dir, solution_name, options.deps_file)
410 ).AndRaise(IOError(2, 'No DEPS file')) 391 ).AndRaise(IOError(2, 'No DEPS file'))
411 392
412 # After everything is done, an attempt is made to write an entries 393 # After everything is done, an attempt is made to write an entries
413 # file. 394 # file.
414 gclient.gclient_utils.FileWrite( 395 gclient.gclient_utils.FileWrite(
415 gclient.os.path.join(self.root_dir, options.entries_filename), 396 gclient.os.path.join(self.root_dir, options.entries_filename),
416 entries_content) 397 entries_content)
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 ).AndReturn(False) 437 ).AndReturn(False)
457 # Expect a check for the entries file and we say there is not one. 438 # Expect a check for the entries file and we say there is not one.
458 gclient.os.path.exists( 439 gclient.os.path.exists(
459 gclient.os.path.join(self.root_dir, options.entries_filename) 440 gclient.os.path.join(self.root_dir, options.entries_filename)
460 ).AndReturn(False) 441 ).AndReturn(False)
461 442
462 # An scm will be requested for the solution. 443 # An scm will be requested for the solution.
463 gclient.gclient_scm.CreateSCM(self.url, self.root_dir, solution_name 444 gclient.gclient_scm.CreateSCM(self.url, self.root_dir, solution_name
464 ).AndReturn(scm_wrapper_sol) 445 ).AndReturn(scm_wrapper_sol)
465 # Then an update will be performed. 446 # Then an update will be performed.
466 scm_wrapper_sol.RunCommand('update', mox.Func(CompareOptions(options)), 447 scm_wrapper_sol.RunCommand('update', options, self.args, [])
467 self.args, [])
468 # Then an attempt will be made to read its DEPS file. 448 # Then an attempt will be made to read its DEPS file.
469 gclient.gclient_utils.FileRead( 449 gclient.gclient_utils.FileRead(
470 gclient.os.path.join(self.root_dir, solution_name, options.deps_file) 450 gclient.os.path.join(self.root_dir, solution_name, options.deps_file)
471 ).AndReturn(deps) 451 ).AndReturn(deps)
472 452
473 # Next we expect an scm to be request for dep src/t but it should 453 # Next we expect an scm to be request for dep src/t but it should
474 # use the url specified in deps and the relative path should now 454 # use the url specified in deps and the relative path should now
475 # be relative to the DEPS file. 455 # be relative to the DEPS file.
476 gclient.gclient_scm.CreateSCM( 456 gclient.gclient_scm.CreateSCM(
477 'svn://scm.t/trunk', 457 'svn://scm.t/trunk',
478 self.root_dir, 458 self.root_dir,
479 gclient.os.path.join(solution_name, "src", "t") 459 gclient.os.path.join(solution_name, "src", "t")
480 ).AndReturn(scm_wrapper_t) 460 ).AndReturn(scm_wrapper_t)
481 scm_wrapper_t.RunCommand('update', mox.Func(CompareOptions(options)), 461 scm_wrapper_t.RunCommand('update', options, self.args, [])
482 self.args, [])
483 462
484 # After everything is done, an attempt is made to write an entries 463 # After everything is done, an attempt is made to write an entries
485 # file. 464 # file.
486 gclient.gclient_utils.FileWrite( 465 gclient.gclient_utils.FileWrite(
487 gclient.os.path.join(self.root_dir, options.entries_filename), 466 gclient.os.path.join(self.root_dir, options.entries_filename),
488 entries_content) 467 entries_content)
489 468
490 self.mox.ReplayAll() 469 self.mox.ReplayAll()
491 client = self._gclient_gclient(self.root_dir, options) 470 client = self._gclient_gclient(self.root_dir, options)
492 client.SetConfig(gclient_config) 471 client.SetConfig(gclient_config)
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
535 514
536 # Expect a check for the entries file and we say there is not one. 515 # Expect a check for the entries file and we say there is not one.
537 gclient.os.path.exists( 516 gclient.os.path.exists(
538 gclient.os.path.join(self.root_dir, options.entries_filename) 517 gclient.os.path.join(self.root_dir, options.entries_filename)
539 ).AndReturn(False) 518 ).AndReturn(False)
540 519
541 # An scm will be requested for the solution. 520 # An scm will be requested for the solution.
542 gclient.gclient_scm.CreateSCM(self.url, self.root_dir, solution_name 521 gclient.gclient_scm.CreateSCM(self.url, self.root_dir, solution_name
543 ).AndReturn(scm_wrapper_sol) 522 ).AndReturn(scm_wrapper_sol)
544 # Then an update will be performed. 523 # Then an update will be performed.
545 scm_wrapper_sol.RunCommand('update', mox.Func(CompareOptions(options)), 524 scm_wrapper_sol.RunCommand('update', options, self.args, [])
546 self.args, [])
547 # Then an attempt will be made to read its DEPS file. 525 # Then an attempt will be made to read its DEPS file.
548 gclient.gclient_utils.FileRead( 526 gclient.gclient_utils.FileRead(
549 gclient.os.path.join(checkout_path, options.deps_file) 527 gclient.os.path.join(checkout_path, options.deps_file)
550 ).AndReturn(deps) 528 ).AndReturn(deps)
551 529
552 # Next we expect an scm to be request for dep src/n even though it does not 530 # Next we expect an scm to be request for dep src/n even though it does not
553 # exist in the DEPS file. 531 # exist in the DEPS file.
554 gclient.gclient_scm.CreateSCM('svn://custom.n/trunk', 532 gclient.gclient_scm.CreateSCM('svn://custom.n/trunk',
555 self.root_dir, 533 self.root_dir,
556 "src/n").AndReturn(scm_wrapper_n) 534 "src/n").AndReturn(scm_wrapper_n)
557 535
558 # Next we expect an scm to be request for dep src/t but it should 536 # Next we expect an scm to be request for dep src/t but it should
559 # use the url specified in custom_deps. 537 # use the url specified in custom_deps.
560 gclient.gclient_scm.CreateSCM('svn://custom.t/trunk', 538 gclient.gclient_scm.CreateSCM('svn://custom.t/trunk',
561 self.root_dir, 539 self.root_dir,
562 "src/t").AndReturn(scm_wrapper_t) 540 "src/t").AndReturn(scm_wrapper_t)
563 541
564 scm_wrapper_n.RunCommand('update', mox.Func(CompareOptions(options)), 542 scm_wrapper_n.RunCommand('update', options, self.args, [])
565 self.args, []) 543 scm_wrapper_t.RunCommand('update', options, self.args, [])
566 scm_wrapper_t.RunCommand('update', mox.Func(CompareOptions(options)),
567 self.args, [])
568 544
569 # NOTE: the dep src/b should not create an scm at all. 545 # NOTE: the dep src/b should not create an scm at all.
570 546
571 # After everything is done, an attempt is made to write an entries 547 # After everything is done, an attempt is made to write an entries
572 # file. 548 # file.
573 gclient.gclient_utils.FileWrite( 549 gclient.gclient_utils.FileWrite(
574 gclient.os.path.join(self.root_dir, options.entries_filename), 550 gclient.os.path.join(self.root_dir, options.entries_filename),
575 entries_content) 551 entries_content)
576 552
577 self.mox.ReplayAll() 553 self.mox.ReplayAll()
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
632 ).AndReturn(False) 608 ).AndReturn(False)
633 609
634 # An scm will be requested for the first solution. 610 # An scm will be requested for the first solution.
635 gclient.gclient_scm.CreateSCM(url_a, self.root_dir, name_a).AndReturn( 611 gclient.gclient_scm.CreateSCM(url_a, self.root_dir, name_a).AndReturn(
636 scm_wrapper_a) 612 scm_wrapper_a)
637 # Then an attempt will be made to read it's DEPS file. 613 # Then an attempt will be made to read it's DEPS file.
638 gclient.gclient_utils.FileRead( 614 gclient.gclient_utils.FileRead(
639 gclient.os.path.join(self.root_dir, name_a, options.deps_file) 615 gclient.os.path.join(self.root_dir, name_a, options.deps_file)
640 ).AndReturn(deps_a) 616 ).AndReturn(deps_a)
641 # Then an update will be performed. 617 # Then an update will be performed.
642 scm_wrapper_a.RunCommand('update', mox.Func(CompareOptions(options)), 618 scm_wrapper_a.RunCommand('update', options, self.args, [])
643 self.args, [])
644 619
645 # An scm will be requested for the second solution. 620 # An scm will be requested for the second solution.
646 gclient.gclient_scm.CreateSCM(url_b, self.root_dir, name_b).AndReturn( 621 gclient.gclient_scm.CreateSCM(url_b, self.root_dir, name_b).AndReturn(
647 scm_wrapper_b) 622 scm_wrapper_b)
648 # Then an attempt will be made to read its DEPS file. 623 # Then an attempt will be made to read its DEPS file.
649 gclient.gclient_utils.FileRead( 624 gclient.gclient_utils.FileRead(
650 gclient.os.path.join(self.root_dir, name_b, options.deps_file) 625 gclient.os.path.join(self.root_dir, name_b, options.deps_file)
651 ).AndReturn(deps_b) 626 ).AndReturn(deps_b)
652 # Then an update will be performed. 627 # Then an update will be performed.
653 scm_wrapper_b.RunCommand('update', mox.Func(CompareOptions(options)), 628 scm_wrapper_b.RunCommand('update', options, self.args, [])
654 self.args, [])
655 629
656 # Finally, an scm is requested for the shared dep. 630 # Finally, an scm is requested for the shared dep.
657 gclient.gclient_scm.CreateSCM('http://svn.t/trunk', self.root_dir, 'src/t' 631 gclient.gclient_scm.CreateSCM('http://svn.t/trunk', self.root_dir, 'src/t'
658 ).AndReturn(scm_wrapper_dep) 632 ).AndReturn(scm_wrapper_dep)
659 # And an update is run on it. 633 # And an update is run on it.
660 scm_wrapper_dep.RunCommand('update', mox.Func(CompareOptions(options)), 634 scm_wrapper_dep.RunCommand('update', options, self.args, [])
661 self.args, [])
662 635
663 # After everything is done, an attempt is made to write an entries file. 636 # After everything is done, an attempt is made to write an entries file.
664 gclient.gclient_utils.FileWrite( 637 gclient.gclient_utils.FileWrite(
665 gclient.os.path.join(self.root_dir, options.entries_filename), 638 gclient.os.path.join(self.root_dir, options.entries_filename),
666 entries_content) 639 entries_content)
667 640
668 self.mox.ReplayAll() 641 self.mox.ReplayAll()
669 client = self._gclient_gclient(self.root_dir, options) 642 client = self._gclient_gclient(self.root_dir, options)
670 client.SetConfig(gclient_config) 643 client.SetConfig(gclient_config)
671 client.RunOnDeps('update', self.args) 644 client.RunOnDeps('update', self.args)
(...skipping 14 matching lines...) Expand all
686 ) % (name, self.url) 659 ) % (name, self.url)
687 660
688 options = self.Options() 661 options = self.Options()
689 gclient.os.path.exists(gclient.os.path.join(self.root_dir, name, '.git') 662 gclient.os.path.exists(gclient.os.path.join(self.root_dir, name, '.git')
690 ).AndReturn(False) 663 ).AndReturn(False)
691 gclient.os.path.exists( 664 gclient.os.path.exists(
692 gclient.os.path.join(self.root_dir, options.entries_filename) 665 gclient.os.path.join(self.root_dir, options.entries_filename)
693 ).AndReturn(False) 666 ).AndReturn(False)
694 gclient.gclient_scm.CreateSCM(self.url, self.root_dir, name).AndReturn( 667 gclient.gclient_scm.CreateSCM(self.url, self.root_dir, name).AndReturn(
695 gclient.gclient_scm.CreateSCM) 668 gclient.gclient_scm.CreateSCM)
696 gclient.gclient_scm.CreateSCM.RunCommand( 669 gclient.gclient_scm.CreateSCM.RunCommand('update', options, self.args, [])
697 'update', mox.Func(CompareOptions(options)), self.args, [])
698 gclient.gclient_utils.FileRead( 670 gclient.gclient_utils.FileRead(
699 gclient.os.path.join(self.root_dir, name, options.deps_file) 671 gclient.os.path.join(self.root_dir, name, options.deps_file)
700 ).AndReturn("Boo = 'a'") 672 ).AndReturn("Boo = 'a'")
701 gclient.gclient_utils.FileWrite( 673 gclient.gclient_utils.FileWrite(
702 gclient.os.path.join(self.root_dir, options.entries_filename), 674 gclient.os.path.join(self.root_dir, options.entries_filename),
703 entries_content) 675 entries_content)
704 676
705 self.mox.ReplayAll() 677 self.mox.ReplayAll()
706 client = self._gclient_gclient(self.root_dir, options) 678 client = self._gclient_gclient(self.root_dir, options)
707 client.SetConfig(gclient_config) 679 client.SetConfig(gclient_config)
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
907 gclient.os.path.join(self.root_dir, 'foo/third_party/WebKit', '.git') 879 gclient.os.path.join(self.root_dir, 'foo/third_party/WebKit', '.git')
908 ).AndReturn(False) 880 ).AndReturn(False)
909 gclient.os.path.exists( 881 gclient.os.path.exists(
910 gclient.os.path.join(self.root_dir, name, '.git') 882 gclient.os.path.join(self.root_dir, name, '.git')
911 ).AndReturn(False) 883 ).AndReturn(False)
912 gclient.os.path.exists( 884 gclient.os.path.exists(
913 gclient.os.path.join(self.root_dir, options.entries_filename) 885 gclient.os.path.join(self.root_dir, options.entries_filename)
914 ).AndReturn(False) 886 ).AndReturn(False)
915 gclient.gclient_scm.CreateSCM(self.url, self.root_dir, name).AndReturn( 887 gclient.gclient_scm.CreateSCM(self.url, self.root_dir, name).AndReturn(
916 gclient.gclient_scm.CreateSCM) 888 gclient.gclient_scm.CreateSCM)
917 gclient.gclient_scm.CreateSCM.RunCommand( 889 gclient.gclient_scm.CreateSCM.RunCommand('update', options, self.args, [])
918 'update', mox.Func(CompareOptions(options)), self.args, [])
919 890
920 gclient.gclient_scm.CreateSCM(self.url, self.root_dir, None 891 gclient.gclient_scm.CreateSCM(self.url, self.root_dir, None
921 ).AndReturn(scm_wrapper_src) 892 ).AndReturn(scm_wrapper_src)
922 scm_wrapper_src.FullUrlForRelativeUrl('/trunk/bar/WebKit' 893 scm_wrapper_src.FullUrlForRelativeUrl('/trunk/bar/WebKit'
923 ).AndReturn(webkit_path) 894 ).AndReturn(webkit_path)
924 895
925 gclient.gclient_scm.CreateSCM( 896 gclient.gclient_scm.CreateSCM(
926 webkit_path, self.root_dir, 'foo/third_party/WebKit' 897 webkit_path, self.root_dir, 'foo/third_party/WebKit'
927 ).AndReturn(gclient.gclient_scm.CreateSCM) 898 ).AndReturn(gclient.gclient_scm.CreateSCM)
928 gclient.gclient_scm.CreateSCM.RunCommand( 899 gclient.gclient_scm.CreateSCM.RunCommand('update', options, self.args, [])
929 'update', mox.Func(CompareOptions(options)), self.args, [])
930 900
931 self.mox.ReplayAll() 901 self.mox.ReplayAll()
932 client = self._gclient_gclient(self.root_dir, options) 902 client = self._gclient_gclient(self.root_dir, options)
933 client.SetConfig(gclient_config) 903 client.SetConfig(gclient_config)
934 client.RunOnDeps('update', self.args) 904 client.RunOnDeps('update', self.args)
935 905
936 def testRunOnDepsSuccessCustomVars(self): 906 def testRunOnDepsSuccessCustomVars(self):
937 # Fake .gclient file. 907 # Fake .gclient file.
938 name = 'testRunOnDepsSuccessCustomVars_solution_name' 908 name = 'testRunOnDepsSuccessCustomVars_solution_name'
939 gclient_config = """solutions = [ { 909 gclient_config = """solutions = [ {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
973 gclient.os.path.join(self.root_dir, 'foo/third_party/WebKit', '.git') 943 gclient.os.path.join(self.root_dir, 'foo/third_party/WebKit', '.git')
974 ).AndReturn(False) 944 ).AndReturn(False)
975 gclient.os.path.exists( 945 gclient.os.path.exists(
976 gclient.os.path.join(self.root_dir, name, '.git') 946 gclient.os.path.join(self.root_dir, name, '.git')
977 ).AndReturn(False) 947 ).AndReturn(False)
978 gclient.os.path.exists( 948 gclient.os.path.exists(
979 gclient.os.path.join(self.root_dir, options.entries_filename) 949 gclient.os.path.join(self.root_dir, options.entries_filename)
980 ).AndReturn(False) 950 ).AndReturn(False)
981 gclient.gclient_scm.CreateSCM(self.url, self.root_dir, name).AndReturn( 951 gclient.gclient_scm.CreateSCM(self.url, self.root_dir, name).AndReturn(
982 gclient.gclient_scm.CreateSCM) 952 gclient.gclient_scm.CreateSCM)
983 gclient.gclient_scm.CreateSCM.RunCommand( 953 gclient.gclient_scm.CreateSCM.RunCommand('update', options, self.args, [])
984 'update', mox.Func(CompareOptions(options)), self.args, [])
985 954
986 gclient.gclient_scm.CreateSCM(self.url, self.root_dir, 955 gclient.gclient_scm.CreateSCM(self.url, self.root_dir,
987 None).AndReturn(scm_wrapper_src) 956 None).AndReturn(scm_wrapper_src)
988 scm_wrapper_src.FullUrlForRelativeUrl('/trunk/bar_custom/WebKit' 957 scm_wrapper_src.FullUrlForRelativeUrl('/trunk/bar_custom/WebKit'
989 ).AndReturn(webkit_path) 958 ).AndReturn(webkit_path)
990 959
991 gclient.gclient_scm.CreateSCM(webkit_path, self.root_dir, 960 gclient.gclient_scm.CreateSCM(webkit_path, self.root_dir,
992 'foo/third_party/WebKit').AndReturn(gclient.gclient_scm.CreateSCM) 961 'foo/third_party/WebKit').AndReturn(gclient.gclient_scm.CreateSCM)
993 gclient.gclient_scm.CreateSCM.RunCommand( 962 gclient.gclient_scm.CreateSCM.RunCommand('update', options, self.args, [])
994 'update', mox.Func(CompareOptions(options)), self.args, [])
995 963
996 self.mox.ReplayAll() 964 self.mox.ReplayAll()
997 client = self._gclient_gclient(self.root_dir, options) 965 client = self._gclient_gclient(self.root_dir, options)
998 client.SetConfig(gclient_config) 966 client.SetConfig(gclient_config)
999 client.RunOnDeps('update', self.args) 967 client.RunOnDeps('update', self.args)
1000 968
1001 def testRunOnDepsFailureVars(self): 969 def testRunOnDepsFailureVars(self):
1002 # Fake .gclient file. 970 # Fake .gclient file.
1003 name = 'testRunOnDepsFailureVars_solution_name' 971 name = 'testRunOnDepsFailureVars_solution_name'
1004 gclient_config = """solutions = [ { 972 gclient_config = """solutions = [ {
1005 'name': '%s', 973 'name': '%s',
1006 'url': '%s', 974 'url': '%s',
1007 'custom_deps': {}, 975 'custom_deps': {},
1008 'custom_vars': {}, 976 'custom_vars': {},
1009 }, ]""" % (name, self.url) 977 }, ]""" % (name, self.url)
1010 # Fake DEPS file. 978 # Fake DEPS file.
1011 deps_content = """deps = { 979 deps_content = """deps = {
1012 'foo/third_party/WebKit': Var('webkit') + 'WebKit', 980 'foo/third_party/WebKit': Var('webkit') + 'WebKit',
1013 }""" 981 }"""
1014 982
1015 options = self.Options() 983 options = self.Options()
1016 gclient.gclient_utils.FileRead( 984 gclient.gclient_utils.FileRead(
1017 gclient.os.path.join(self.root_dir, name, options.deps_file) 985 gclient.os.path.join(self.root_dir, name, options.deps_file)
1018 ).AndReturn(deps_content) 986 ).AndReturn(deps_content)
1019 gclient.gclient_scm.CreateSCM(self.url, self.root_dir, name).AndReturn( 987 gclient.gclient_scm.CreateSCM(self.url, self.root_dir, name).AndReturn(
1020 gclient.gclient_scm.CreateSCM) 988 gclient.gclient_scm.CreateSCM)
1021 gclient.gclient_scm.CreateSCM.RunCommand( 989 gclient.gclient_scm.CreateSCM.RunCommand('update', options, self.args, [])
1022 'update', mox.Func(CompareOptions(options)), self.args, [])
1023 990
1024 self.mox.ReplayAll() 991 self.mox.ReplayAll()
1025 client = self._gclient_gclient(self.root_dir, options) 992 client = self._gclient_gclient(self.root_dir, options)
1026 client.SetConfig(gclient_config) 993 client.SetConfig(gclient_config)
1027 exception = "Var is not defined: webkit" 994 exception = "Var is not defined: webkit"
1028 try: 995 try:
1029 client.RunOnDeps('update', self.args) 996 client.RunOnDeps('update', self.args)
1030 except gclient.gclient_utils.Error, e: 997 except gclient.gclient_utils.Error, e:
1031 self.assertEquals(e.args[0], exception) 998 self.assertEquals(e.args[0], exception)
1032 else: 999 else:
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
1075 1042
1076 options = self.Options() 1043 options = self.Options()
1077 gclient.os.path.exists(gclient.os.path.join(self.root_dir, 'main', '.git') 1044 gclient.os.path.exists(gclient.os.path.join(self.root_dir, 'main', '.git')
1078 ).AndReturn(False) 1045 ).AndReturn(False)
1079 gclient.os.path.exists(gclient.os.path.join(self.root_dir, 'base', '.git') 1046 gclient.os.path.exists(gclient.os.path.join(self.root_dir, 'base', '.git')
1080 ).AndReturn(False) 1047 ).AndReturn(False)
1081 gclient.os.path.exists(gclient.os.path.join(self.root_dir, name, '.git') 1048 gclient.os.path.exists(gclient.os.path.join(self.root_dir, name, '.git')
1082 ).AndReturn(False) 1049 ).AndReturn(False)
1083 gclient.gclient_scm.CreateSCM(self.url, self.root_dir, name).AndReturn( 1050 gclient.gclient_scm.CreateSCM(self.url, self.root_dir, name).AndReturn(
1084 gclient.gclient_scm.CreateSCM) 1051 gclient.gclient_scm.CreateSCM)
1085 gclient.gclient_scm.CreateSCM.RunCommand( 1052 gclient.gclient_scm.CreateSCM.RunCommand('update', options, self.args, [])
1086 'update', mox.Func(CompareOptions(options)), self.args, [])
1087 gclient.gclient_utils.FileRead( 1053 gclient.gclient_utils.FileRead(
1088 gclient.os.path.join(self.root_dir, name, options.deps_file) 1054 gclient.os.path.join(self.root_dir, name, options.deps_file)
1089 ).AndReturn(deps_content) 1055 ).AndReturn(deps_content)
1090 1056
1091 # base gets updated. 1057 # base gets updated.
1092 gclient.gclient_scm.CreateSCM(base_url, self.root_dir, 'base').AndReturn( 1058 gclient.gclient_scm.CreateSCM(base_url, self.root_dir, 'base').AndReturn(
1093 gclient.gclient_scm.CreateSCM) 1059 gclient.gclient_scm.CreateSCM)
1094 gclient.gclient_scm.CreateSCM.RunCommand( 1060 gclient.gclient_scm.CreateSCM.RunCommand('update', options, self.args, [])
1095 'update', mox.Func(CompareOptions(options)), self.args, [])
1096 gclient.gclient_utils.FileRead( 1061 gclient.gclient_utils.FileRead(
1097 gclient.os.path.join(self.root_dir, 'base', options.deps_file) 1062 gclient.os.path.join(self.root_dir, 'base', options.deps_file)
1098 ).AndReturn(base_deps_content) 1063 ).AndReturn(base_deps_content)
1099 1064
1100 # main gets updated. 1065 # main gets updated.
1101 gclient.gclient_scm.CreateSCM(main_url, self.root_dir, 'main').AndReturn( 1066 gclient.gclient_scm.CreateSCM(main_url, self.root_dir, 'main').AndReturn(
1102 gclient.gclient_scm.CreateSCM) 1067 gclient.gclient_scm.CreateSCM)
1103 gclient.gclient_scm.CreateSCM.RunCommand( 1068 gclient.gclient_scm.CreateSCM.RunCommand('update', options, self.args, [])
1104 'update', mox.Func(CompareOptions(options)), self.args, [])
1105 1069
1106 # Process is done and will write an .gclient_entries. 1070 # Process is done and will write an .gclient_entries.
1107 gclient.os.path.exists( 1071 gclient.os.path.exists(
1108 gclient.os.path.join(self.root_dir, options.entries_filename) 1072 gclient.os.path.join(self.root_dir, options.entries_filename)
1109 ).AndReturn(False) 1073 ).AndReturn(False)
1110 gclient.gclient_utils.FileWrite( 1074 gclient.gclient_utils.FileWrite(
1111 gclient.os.path.join(self.root_dir, options.entries_filename), 1075 gclient.os.path.join(self.root_dir, options.entries_filename),
1112 mox.IgnoreArg()) 1076 mox.IgnoreArg())
1113 1077
1114 self.mox.ReplayAll() 1078 self.mox.ReplayAll()
(...skipping 26 matching lines...) Expand all
1141 1105
1142 options = self.Options() 1106 options = self.Options()
1143 gclient.os.path.exists(gclient.os.path.join(self.root_dir, 'main', '.git') 1107 gclient.os.path.exists(gclient.os.path.join(self.root_dir, 'main', '.git')
1144 ).AndReturn(False) 1108 ).AndReturn(False)
1145 gclient.os.path.exists(gclient.os.path.join(self.root_dir, 'base', '.git') 1109 gclient.os.path.exists(gclient.os.path.join(self.root_dir, 'base', '.git')
1146 ).AndReturn(False) 1110 ).AndReturn(False)
1147 gclient.os.path.exists(gclient.os.path.join(self.root_dir, name, '.git') 1111 gclient.os.path.exists(gclient.os.path.join(self.root_dir, name, '.git')
1148 ).AndReturn(False) 1112 ).AndReturn(False)
1149 gclient.gclient_scm.CreateSCM(self.url, self.root_dir, name).AndReturn( 1113 gclient.gclient_scm.CreateSCM(self.url, self.root_dir, name).AndReturn(
1150 gclient.gclient_scm.CreateSCM) 1114 gclient.gclient_scm.CreateSCM)
1151 gclient.gclient_scm.CreateSCM.RunCommand( 1115 gclient.gclient_scm.CreateSCM.RunCommand('update', options, self.args, [])
1152 'update', mox.Func(CompareOptions(options)), self.args, [])
1153 gclient.gclient_utils.FileRead( 1116 gclient.gclient_utils.FileRead(
1154 gclient.os.path.join(self.root_dir, name, options.deps_file) 1117 gclient.os.path.join(self.root_dir, name, options.deps_file)
1155 ).AndReturn(deps_content) 1118 ).AndReturn(deps_content)
1156 1119
1157 # base gets updated. 1120 # base gets updated.
1158 gclient.gclient_scm.CreateSCM(base_url, self.root_dir, 'base').AndReturn( 1121 gclient.gclient_scm.CreateSCM(base_url, self.root_dir, 'base').AndReturn(
1159 gclient.gclient_scm.CreateSCM) 1122 gclient.gclient_scm.CreateSCM)
1160 gclient.gclient_scm.CreateSCM.RunCommand( 1123 gclient.gclient_scm.CreateSCM.RunCommand('update', options, self.args, [])
1161 'update', mox.Func(CompareOptions(options)), self.args, [])
1162 gclient.gclient_utils.FileRead( 1124 gclient.gclient_utils.FileRead(
1163 gclient.os.path.join(self.root_dir, 'base', options.deps_file) 1125 gclient.os.path.join(self.root_dir, 'base', options.deps_file)
1164 ).AndReturn(base_deps_content) 1126 ).AndReturn(base_deps_content)
1165 1127
1166 # main gets updated. 1128 # main gets updated.
1167 gclient.gclient_scm.CreateSCM(main_url, self.root_dir, 'main').AndReturn( 1129 gclient.gclient_scm.CreateSCM(main_url, self.root_dir, 'main').AndReturn(
1168 gclient.gclient_scm.CreateSCM) 1130 gclient.gclient_scm.CreateSCM)
1169 gclient.gclient_scm.CreateSCM.RunCommand( 1131 gclient.gclient_scm.CreateSCM.RunCommand('update', options, self.args, [])
1170 'update', mox.Func(CompareOptions(options)), self.args, [])
1171 1132
1172 # Process is done and will write an .gclient_entries. 1133 # Process is done and will write an .gclient_entries.
1173 gclient.os.path.exists( 1134 gclient.os.path.exists(
1174 gclient.os.path.join(self.root_dir, options.entries_filename) 1135 gclient.os.path.join(self.root_dir, options.entries_filename)
1175 ).AndReturn(False) 1136 ).AndReturn(False)
1176 gclient.gclient_utils.FileWrite( 1137 gclient.gclient_utils.FileWrite(
1177 gclient.os.path.join(self.root_dir, options.entries_filename), 1138 gclient.os.path.join(self.root_dir, options.entries_filename),
1178 mox.IgnoreArg()) 1139 mox.IgnoreArg())
1179 1140
1180 self.mox.ReplayAll() 1141 self.mox.ReplayAll()
(...skipping 26 matching lines...) Expand all
1207 1168
1208 options = self.Options() 1169 options = self.Options()
1209 gclient.os.path.exists(gclient.os.path.join(self.root_dir, 'main', '.git') 1170 gclient.os.path.exists(gclient.os.path.join(self.root_dir, 'main', '.git')
1210 ).AndReturn(False) 1171 ).AndReturn(False)
1211 gclient.os.path.exists(gclient.os.path.join(self.root_dir, 'base', '.git') 1172 gclient.os.path.exists(gclient.os.path.join(self.root_dir, 'base', '.git')
1212 ).AndReturn(False) 1173 ).AndReturn(False)
1213 gclient.os.path.exists(gclient.os.path.join(self.root_dir, name, '.git') 1174 gclient.os.path.exists(gclient.os.path.join(self.root_dir, name, '.git')
1214 ).AndReturn(False) 1175 ).AndReturn(False)
1215 gclient.gclient_scm.CreateSCM(self.url, self.root_dir, name).AndReturn( 1176 gclient.gclient_scm.CreateSCM(self.url, self.root_dir, name).AndReturn(
1216 gclient.gclient_scm.CreateSCM) 1177 gclient.gclient_scm.CreateSCM)
1217 gclient.gclient_scm.CreateSCM.RunCommand( 1178 gclient.gclient_scm.CreateSCM.RunCommand('update', options, self.args, [])
1218 'update', mox.Func(CompareOptions(options)), self.args, [])
1219 gclient.gclient_utils.FileRead( 1179 gclient.gclient_utils.FileRead(
1220 gclient.os.path.join(self.root_dir, name, options.deps_file) 1180 gclient.os.path.join(self.root_dir, name, options.deps_file)
1221 ).AndReturn(deps_content) 1181 ).AndReturn(deps_content)
1222 1182
1223 # base gets updated. 1183 # base gets updated.
1224 gclient.gclient_scm.CreateSCM(base_url, self.root_dir, 'base').AndReturn( 1184 gclient.gclient_scm.CreateSCM(base_url, self.root_dir, 'base').AndReturn(
1225 gclient.gclient_scm.CreateSCM) 1185 gclient.gclient_scm.CreateSCM)
1226 gclient.gclient_scm.CreateSCM.RunCommand( 1186 gclient.gclient_scm.CreateSCM.RunCommand('update', options, self.args, [])
1227 'update', mox.Func(CompareOptions(options)), self.args, [])
1228 gclient.gclient_utils.FileRead( 1187 gclient.gclient_utils.FileRead(
1229 gclient.os.path.join(self.root_dir, 'base', options.deps_file) 1188 gclient.os.path.join(self.root_dir, 'base', options.deps_file)
1230 ).AndReturn(base_deps_content) 1189 ).AndReturn(base_deps_content)
1231 1190
1232 # main gets updated after resolving the relative url. 1191 # main gets updated after resolving the relative url.
1233 gclient.gclient_scm.CreateSCM(base_url, self.root_dir, None).AndReturn( 1192 gclient.gclient_scm.CreateSCM(base_url, self.root_dir, None).AndReturn(
1234 gclient.gclient_scm.CreateSCM) 1193 gclient.gclient_scm.CreateSCM)
1235 gclient.gclient_scm.CreateSCM.FullUrlForRelativeUrl(main_url 1194 gclient.gclient_scm.CreateSCM.FullUrlForRelativeUrl(main_url
1236 ).AndReturn('svn://base' + main_url) 1195 ).AndReturn('svn://base' + main_url)
1237 gclient.gclient_scm.CreateSCM('svn://base' + main_url, self.root_dir, 1196 gclient.gclient_scm.CreateSCM('svn://base' + main_url, self.root_dir,
1238 'main').AndReturn(gclient.gclient_scm.CreateSCM) 1197 'main').AndReturn(gclient.gclient_scm.CreateSCM)
1239 gclient.gclient_scm.CreateSCM.RunCommand( 1198 gclient.gclient_scm.CreateSCM.RunCommand('update', options, self.args, [])
1240 'update', mox.Func(CompareOptions(options)), self.args, [])
1241 1199
1242 # Process is done and will write an .gclient_entries. 1200 # Process is done and will write an .gclient_entries.
1243 gclient.os.path.exists( 1201 gclient.os.path.exists(
1244 gclient.os.path.join(self.root_dir, options.entries_filename) 1202 gclient.os.path.join(self.root_dir, options.entries_filename)
1245 ).AndReturn(False) 1203 ).AndReturn(False)
1246 gclient.gclient_utils.FileWrite( 1204 gclient.gclient_utils.FileWrite(
1247 gclient.os.path.join(self.root_dir, options.entries_filename), 1205 gclient.os.path.join(self.root_dir, options.entries_filename),
1248 mox.IgnoreArg()) 1206 mox.IgnoreArg())
1249 1207
1250 self.mox.ReplayAll() 1208 self.mox.ReplayAll()
(...skipping 11 matching lines...) Expand all
1262 # Fake DEPS file. 1220 # Fake DEPS file.
1263 target = "chromium_deps" 1221 target = "chromium_deps"
1264 deps_content = ( 1222 deps_content = (
1265 "deps = {" 1223 "deps = {"
1266 " '%s': File('%s/DEPS') }" % (target, self.url) 1224 " '%s': File('%s/DEPS') }" % (target, self.url)
1267 ) 1225 )
1268 1226
1269 gclient.gclient_scm.CreateSCM(self.url, self.root_dir, name).AndReturn( 1227 gclient.gclient_scm.CreateSCM(self.url, self.root_dir, name).AndReturn(
1270 gclient.gclient_scm.CreateSCM) 1228 gclient.gclient_scm.CreateSCM)
1271 options = self.Options() 1229 options = self.Options()
1272 gclient.gclient_scm.CreateSCM.RunCommand( 1230 gclient.gclient_scm.CreateSCM.RunCommand('update', options, self.args, [])
1273 'update', mox.Func(CompareOptions(options)), self.args, [])
1274 gclient.gclient_utils.FileRead( 1231 gclient.gclient_utils.FileRead(
1275 gclient.os.path.join(self.root_dir, name, options.deps_file) 1232 gclient.os.path.join(self.root_dir, name, options.deps_file)
1276 ).AndReturn(deps_content) 1233 ).AndReturn(deps_content)
1277 gclient.os.path.exists( 1234 gclient.os.path.exists(
1278 gclient.os.path.join(self.root_dir, name, '.git') 1235 gclient.os.path.join(self.root_dir, name, '.git')
1279 ).AndReturn(False) 1236 ).AndReturn(False)
1280 gclient.os.path.exists( 1237 gclient.os.path.exists(
1281 gclient.os.path.join(self.root_dir, options.entries_filename) 1238 gclient.os.path.join(self.root_dir, options.entries_filename)
1282 ).AndReturn(False) 1239 ).AndReturn(False)
1283 1240
1284 # This is where gclient tries to do the initial checkout. 1241 # This is where gclient tries to do the initial checkout.
1285 gclient.gclient_scm.CreateSCM(self.url, self.root_dir, target).AndReturn( 1242 gclient.gclient_scm.CreateSCM(self.url, self.root_dir, target).AndReturn(
1286 gclient.gclient_scm.CreateSCM) 1243 gclient.gclient_scm.CreateSCM)
1287 gclient.gclient_scm.CreateSCM.RunCommand('updatesingle', 1244 gclient.gclient_scm.CreateSCM.RunCommand('updatesingle', options,
1288 mox.Func(CompareOptions(options)),
1289 self.args + ["DEPS"], []) 1245 self.args + ["DEPS"], [])
1290 gclient.gclient_utils.FileWrite( 1246 gclient.gclient_utils.FileWrite(
1291 gclient.os.path.join(self.root_dir, options.entries_filename), 1247 gclient.os.path.join(self.root_dir, options.entries_filename),
1292 "entries = \\\n{ '%s': '%s'}\n" % (name, self.url)) 1248 "entries = \\\n{ '%s': '%s'}\n" % (name, self.url))
1293 1249
1294 self.mox.ReplayAll() 1250 self.mox.ReplayAll()
1295 client = self._gclient_gclient(self.root_dir, options) 1251 client = self._gclient_gclient(self.root_dir, options)
1296 client.SetConfig(gclient_config) 1252 client.SetConfig(gclient_config)
1297 client.RunOnDeps('update', self.args) 1253 client.RunOnDeps('update', self.args)
1298 1254
1299 def test_PrintRevInfo(self): 1255 def test_PrintRevInfo(self):
1300 # TODO(aharper): no test yet for revinfo, lock it down once we've verified 1256 # TODO(aharper): no test yet for revinfo, lock it down once we've verified
1301 # implementation for Pulse plugin 1257 # implementation for Pulse plugin
1302 pass 1258 pass
1303 1259
1304 def testGetSCMCommandClosure(self):
1305 options = self.Options()
1306 name = 'testGetSCMCommandClosure_name'
1307 command = 'testGetSCMCommandClosure_command'
1308 revision = '123'
1309 file_list = []
1310 called_options = self.Options()
1311 called_options.revision = revision
1312 gclient.gclient_scm.CreateSCM(self.url, self.root_dir, name).AndReturn(
1313 gclient.gclient_scm.CreateSCM)
1314 gclient.gclient_scm.CreateSCM.RunCommand(
1315 command, mox.Func(CompareOptions(called_options)), self.args, file_list)
1316
1317 self.mox.ReplayAll()
1318 client = self._gclient_gclient(self.root_dir, options)
1319 closure = client.GetSCMCommandClosure(name, self.url, revision, command,
1320 self.args, file_list)
1321 closure()
1322
1323 # No test for internal functions. 1260 # No test for internal functions.
1324 def test_GetAllDeps(self): 1261 def test_GetAllDeps(self):
1325 pass 1262 pass
1326 def test_GetDefaultSolutionDeps(self): 1263 def test_GetDefaultSolutionDeps(self):
1327 pass 1264 pass
1328 def test_LoadConfig(self): 1265 def test_LoadConfig(self):
1329 pass 1266 pass
1330 def test_ReadEntries(self): 1267 def test_ReadEntries(self):
1331 pass 1268 pass
1332 def test_SaveEntries(self): 1269 def test_SaveEntries(self):
1333 pass 1270 pass
1334 def test_VarImpl(self): 1271 def test_VarImpl(self):
1335 pass 1272 pass
1336 1273
1337 1274
1338 if __name__ == '__main__': 1275 if __name__ == '__main__':
1339 import unittest 1276 import unittest
1340 unittest.main() 1277 unittest.main()
1341 1278
1342 # vim: ts=2:sw=2:tw=80:et: 1279 # vim: ts=2:sw=2:tw=80:et:
OLDNEW
« no previous file with comments | « gclient_utils.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698