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

Side by Side Diff: tests/gclient_scm_test.py

Issue 3353018: Make gclient_scm_test much more silent (Closed)
Patch Set: gclient_scm_test can now be run Created 10 years, 3 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 | « scm.py ('k') | tests/scm_unittest.py » ('j') | 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_scm.py.""" 6 """Unit tests for gclient_scm.py."""
7 7
8 # Import before super_mox to keep valid references. 8 # Import before super_mox to keep valid references.
9 from os import rename 9 from os import rename
10 from shutil import rmtree 10 from shutil import rmtree
(...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after
623 file_list = [] 623 file_list = []
624 scm.update(options, None, file_list) 624 scm.update(options, None, file_list)
625 gclient_scm.os.remove(file_path) 625 gclient_scm.os.remove(file_path)
626 file_list = [] 626 file_list = []
627 scm.revert(options, self.args, file_list) 627 scm.revert(options, self.args, file_list)
628 self.assertEquals(file_list, [file_path]) 628 self.assertEquals(file_list, [file_path])
629 file_list = [] 629 file_list = []
630 scm.diff(options, self.args, file_list) 630 scm.diff(options, self.args, file_list)
631 self.assertEquals(file_list, []) 631 self.assertEquals(file_list, [])
632 self.checkstdout( 632 self.checkstdout(
633 ('\n_____ . at refs/heads/master\n\n\n' 633 ('\n_____ . at refs/heads/master\nUpdating 069c602..a7142dc\n'
634 'Fast-forward\n a | 1 +\n b | 1 +\n'
635 ' 2 files changed, 2 insertions(+), 0 deletions(-)\n\n\n'
634 '________ running \'git reset --hard origin/master\' in \'%s\'\n' 636 '________ running \'git reset --hard origin/master\' in \'%s\'\n'
635 'HEAD is now at a7142dc Personalized\n') % 637 'HEAD is now at a7142dc Personalized\n') %
636 gclient_scm.os.path.join(self.root_dir, '.')) 638 gclient_scm.os.path.join(self.root_dir, '.'))
637 639
638 def testRevertNone(self): 640 def testRevertNone(self):
639 if not self.enabled: 641 if not self.enabled:
640 return 642 return
641 options = self.Options() 643 options = self.Options()
642 scm = gclient_scm.CreateSCM(url=self.url, root_dir=self.root_dir, 644 scm = gclient_scm.CreateSCM(url=self.url, root_dir=self.root_dir,
643 relpath=self.relpath) 645 relpath=self.relpath)
644 file_list = [] 646 file_list = []
645 scm.update(options, None, file_list) 647 scm.update(options, None, file_list)
646 file_list = [] 648 file_list = []
647 scm.revert(options, self.args, file_list) 649 scm.revert(options, self.args, file_list)
648 self.assertEquals(file_list, []) 650 self.assertEquals(file_list, [])
649 self.assertEquals(scm.revinfo(options, self.args, None), 651 self.assertEquals(scm.revinfo(options, self.args, None),
650 'a7142dc9f0009350b96a11f372b6ea658592aa95') 652 'a7142dc9f0009350b96a11f372b6ea658592aa95')
651 self.checkstdout( 653 self.checkstdout(
652 ('\n_____ . at refs/heads/master\n\n\n' 654 ('\n_____ . at refs/heads/master\nUpdating 069c602..a7142dc\n'
655 'Fast-forward\n a | 1 +\n b | 1 +\n'
656 ' 2 files changed, 2 insertions(+), 0 deletions(-)\n\n\n'
653 '________ running \'git reset --hard origin/master\' in \'%s\'\n' 657 '________ running \'git reset --hard origin/master\' in \'%s\'\n'
654 'HEAD is now at a7142dc Personalized\n') % 658 'HEAD is now at a7142dc Personalized\n') %
655 gclient_scm.os.path.join(self.root_dir, '.')) 659 gclient_scm.os.path.join(self.root_dir, '.'))
656 660
657 def testRevertModified(self): 661 def testRevertModified(self):
658 if not self.enabled: 662 if not self.enabled:
659 return 663 return
660 options = self.Options() 664 options = self.Options()
661 scm = gclient_scm.CreateSCM(url=self.url, root_dir=self.root_dir, 665 scm = gclient_scm.CreateSCM(url=self.url, root_dir=self.root_dir,
662 relpath=self.relpath) 666 relpath=self.relpath)
663 file_list = [] 667 file_list = []
664 scm.update(options, None, file_list) 668 scm.update(options, None, file_list)
665 file_path = gclient_scm.os.path.join(self.base_path, 'a') 669 file_path = gclient_scm.os.path.join(self.base_path, 'a')
666 open(file_path, 'a').writelines('touched\n') 670 open(file_path, 'a').writelines('touched\n')
667 file_list = [] 671 file_list = []
668 scm.revert(options, self.args, file_list) 672 scm.revert(options, self.args, file_list)
669 self.assertEquals(file_list, [file_path]) 673 self.assertEquals(file_list, [file_path])
670 file_list = [] 674 file_list = []
671 scm.diff(options, self.args, file_list) 675 scm.diff(options, self.args, file_list)
672 self.assertEquals(file_list, []) 676 self.assertEquals(file_list, [])
673 self.assertEquals(scm.revinfo(options, self.args, None), 677 self.assertEquals(scm.revinfo(options, self.args, None),
674 'a7142dc9f0009350b96a11f372b6ea658592aa95') 678 'a7142dc9f0009350b96a11f372b6ea658592aa95')
675 self.checkstdout( 679 self.checkstdout(
676 ('\n_____ . at refs/heads/master\n\n\n' 680 ('\n_____ . at refs/heads/master\nUpdating 069c602..a7142dc\n'
681 'Fast-forward\n a | 1 +\n b | 1 +\n'
682 ' 2 files changed, 2 insertions(+), 0 deletions(-)\n\n\n'
677 '________ running \'git reset --hard origin/master\' in \'%s\'\n' 683 '________ running \'git reset --hard origin/master\' in \'%s\'\n'
678 'HEAD is now at a7142dc Personalized\n') % 684 'HEAD is now at a7142dc Personalized\n') %
679 gclient_scm.os.path.join(self.root_dir, '.')) 685 gclient_scm.os.path.join(self.root_dir, '.'))
680 686
681 def testRevertNew(self): 687 def testRevertNew(self):
682 if not self.enabled: 688 if not self.enabled:
683 return 689 return
684 options = self.Options() 690 options = self.Options()
685 scm = gclient_scm.CreateSCM(url=self.url, root_dir=self.root_dir, 691 scm = gclient_scm.CreateSCM(url=self.url, root_dir=self.root_dir,
686 relpath=self.relpath) 692 relpath=self.relpath)
687 file_list = [] 693 file_list = []
688 scm.update(options, None, file_list) 694 scm.update(options, None, file_list)
689 file_path = gclient_scm.os.path.join(self.base_path, 'c') 695 file_path = gclient_scm.os.path.join(self.base_path, 'c')
690 f = open(file_path, 'w') 696 f = open(file_path, 'w')
691 f.writelines('new\n') 697 f.writelines('new\n')
692 f.close() 698 f.close()
693 Popen(['git', 'add', 'c'], stdout=PIPE, 699 Popen(['git', 'add', 'c'], stdout=PIPE,
694 stderr=STDOUT, cwd=self.base_path).communicate() 700 stderr=STDOUT, cwd=self.base_path).communicate()
695 file_list = [] 701 file_list = []
696 scm.revert(options, self.args, file_list) 702 scm.revert(options, self.args, file_list)
697 self.assertEquals(file_list, [file_path]) 703 self.assertEquals(file_list, [file_path])
698 file_list = [] 704 file_list = []
699 scm.diff(options, self.args, file_list) 705 scm.diff(options, self.args, file_list)
700 self.assertEquals(file_list, []) 706 self.assertEquals(file_list, [])
701 self.assertEquals(scm.revinfo(options, self.args, None), 707 self.assertEquals(scm.revinfo(options, self.args, None),
702 'a7142dc9f0009350b96a11f372b6ea658592aa95') 708 'a7142dc9f0009350b96a11f372b6ea658592aa95')
703 self.checkstdout( 709 self.checkstdout(
704 ('\n_____ . at refs/heads/master\n\n\n' 710 ('\n_____ . at refs/heads/master\nUpdating 069c602..a7142dc\n'
711 'Fast-forward\n a | 1 +\n b | 1 +\n'
712 ' 2 files changed, 2 insertions(+), 0 deletions(-)\n\n\n'
705 '________ running \'git reset --hard origin/master\' in \'%s\'\n' 713 '________ running \'git reset --hard origin/master\' in \'%s\'\n'
706 'HEAD is now at a7142dc Personalized\n') % 714 'HEAD is now at a7142dc Personalized\n') %
707 gclient_scm.os.path.join(self.root_dir, '.')) 715 gclient_scm.os.path.join(self.root_dir, '.'))
708 716
709 def testStatusNew(self): 717 def testStatusNew(self):
710 if not self.enabled: 718 if not self.enabled:
711 return 719 return
712 options = self.Options() 720 options = self.Options()
713 file_path = gclient_scm.os.path.join(self.base_path, 'a') 721 file_path = gclient_scm.os.path.join(self.base_path, 'a')
714 open(file_path, 'a').writelines('touched\n') 722 open(file_path, 'a').writelines('touched\n')
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
777 options = self.Options() 785 options = self.Options()
778 expected_file_list = [gclient_scm.os.path.join(self.base_path, x) 786 expected_file_list = [gclient_scm.os.path.join(self.base_path, x)
779 for x in ['a', 'b']] 787 for x in ['a', 'b']]
780 scm = gclient_scm.CreateSCM(url=self.url, root_dir=self.root_dir, 788 scm = gclient_scm.CreateSCM(url=self.url, root_dir=self.root_dir,
781 relpath=self.relpath) 789 relpath=self.relpath)
782 file_list = [] 790 file_list = []
783 scm.update(options, (), file_list) 791 scm.update(options, (), file_list)
784 self.assertEquals(file_list, expected_file_list) 792 self.assertEquals(file_list, expected_file_list)
785 self.assertEquals(scm.revinfo(options, (), None), 793 self.assertEquals(scm.revinfo(options, (), None),
786 'a7142dc9f0009350b96a11f372b6ea658592aa95') 794 'a7142dc9f0009350b96a11f372b6ea658592aa95')
787 self.checkstdout('\n_____ . at refs/heads/master\n\n') 795 self.checkstdout(
796 '\n_____ . at refs/heads/master\n'
797 'Updating 069c602..a7142dc\nFast-forward\n a | 1 +\n b | 1 +\n'
798 ' 2 files changed, 2 insertions(+), 0 deletions(-)\n\n')
788 799
789 def testUpdateUnstagedConflict(self): 800 def testUpdateUnstagedConflict(self):
790 if not self.enabled: 801 if not self.enabled:
791 return 802 return
792 options = self.Options() 803 options = self.Options()
793 scm = gclient_scm.CreateSCM(url=self.url, root_dir=self.root_dir, 804 scm = gclient_scm.CreateSCM(url=self.url, root_dir=self.root_dir,
794 relpath=self.relpath) 805 relpath=self.relpath)
795 file_path = gclient_scm.os.path.join(self.base_path, 'b') 806 file_path = gclient_scm.os.path.join(self.base_path, 'b')
796 f = open(file_path, 'w').writelines('conflict\n') 807 f = open(file_path, 'w').writelines('conflict\n')
797 exception = ( 808 exception = (
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
854 relpath=self.relpath) 865 relpath=self.relpath)
855 rev_info = scm.revinfo(options, (), None) 866 rev_info = scm.revinfo(options, (), None)
856 self.assertEquals(rev_info, '069c602044c5388d2d15c3f875b057c852003458') 867 self.assertEquals(rev_info, '069c602044c5388d2d15c3f875b057c852003458')
857 self.checkstdout('') 868 self.checkstdout('')
858 869
859 870
860 if __name__ == '__main__': 871 if __name__ == '__main__':
861 unittest.main() 872 unittest.main()
862 873
863 # vim: ts=2:sw=2:tw=80:et: 874 # vim: ts=2:sw=2:tw=80:et:
OLDNEW
« no previous file with comments | « scm.py ('k') | tests/scm_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698