OLD | NEW |
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 # pylint: disable=E1101,E1103,W0403 | 8 # pylint: disable=E1101,E1103,W0403 |
9 | 9 |
10 # Import before super_mox to keep valid references. | 10 # Import before super_mox to keep valid references. |
(...skipping 674 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
685 self.assertEquals(sorted(file_list), expected_file_list) | 685 self.assertEquals(sorted(file_list), expected_file_list) |
686 self.checkstdout( | 686 self.checkstdout( |
687 ('\n________ running \'git diff --name-status ' | 687 ('\n________ running \'git diff --name-status ' |
688 '069c602044c5388d2d15c3f875b057c852003458\' in \'%s\'\nM\ta\nM\tb\n') % | 688 '069c602044c5388d2d15c3f875b057c852003458\' in \'%s\'\nM\ta\nM\tb\n') % |
689 join(self.root_dir, '.')) | 689 join(self.root_dir, '.')) |
690 | 690 |
691 def testUpdateCheckout(self): | 691 def testUpdateCheckout(self): |
692 if not self.enabled: | 692 if not self.enabled: |
693 return | 693 return |
694 options = self.Options(verbose=True) | 694 options = self.Options(verbose=True) |
695 root_dir = tempfile.mkdtemp() | 695 root_dir = gclient_scm.os.path.realpath(tempfile.mkdtemp()) |
696 relpath = 'foo' | 696 relpath = 'foo' |
697 base_path = join(root_dir, relpath) | 697 base_path = join(root_dir, relpath) |
698 url = join(self.base_path, '.git') | 698 url = join(self.base_path, '.git') |
699 try: | 699 try: |
700 scm = gclient_scm.CreateSCM(url=url, root_dir=root_dir, | 700 scm = gclient_scm.CreateSCM(url=url, root_dir=root_dir, |
701 relpath=relpath) | 701 relpath=relpath) |
702 file_list = [] | 702 file_list = [] |
703 scm.update(options, (), file_list) | 703 scm.update(options, (), file_list) |
704 self.assertEquals(len(file_list), 2) | 704 self.assertEquals(len(file_list), 2) |
705 self.assert_(gclient_scm.os.path.isfile(join(base_path, 'a'))) | 705 self.assert_(gclient_scm.os.path.isfile(join(base_path, 'a'))) |
(...skipping 12 matching lines...) Expand all Loading... |
718 msg2 = ( | 718 msg2 = ( |
719 "\n_____ foo at refs/heads/master\n\n" | 719 "\n_____ foo at refs/heads/master\n\n" |
720 "________ running 'git clone -b master --verbose %s %s' in '%s'\n" | 720 "________ running 'git clone -b master --verbose %s %s' in '%s'\n" |
721 "Cloning into %s...\ndone.\n") % ( | 721 "Cloning into %s...\ndone.\n") % ( |
722 join(self.root_dir, '.', '.git'), | 722 join(self.root_dir, '.', '.git'), |
723 join(root_dir, 'foo'), | 723 join(root_dir, 'foo'), |
724 root_dir, | 724 root_dir, |
725 join(gclient_scm.os.path.realpath(root_dir), 'foo')) | 725 join(gclient_scm.os.path.realpath(root_dir), 'foo')) |
726 out = sys.stdout.getvalue() | 726 out = sys.stdout.getvalue() |
727 sys.stdout.close() | 727 sys.stdout.close() |
| 728 sys.stdout = self._old_stdout |
728 self.assertTrue(out in (msg1, msg2), (out, msg1, msg2)) | 729 self.assertTrue(out in (msg1, msg2), (out, msg1, msg2)) |
729 | 730 |
730 def testUpdateUpdate(self): | 731 def testUpdateUpdate(self): |
731 if not self.enabled: | 732 if not self.enabled: |
732 return | 733 return |
733 options = self.Options() | 734 options = self.Options() |
734 expected_file_list = [join(self.base_path, x) for x in ['a', 'b']] | 735 expected_file_list = [join(self.base_path, x) for x in ['a', 'b']] |
735 scm = gclient_scm.CreateSCM(url=self.url, root_dir=self.root_dir, | 736 scm = gclient_scm.CreateSCM(url=self.url, root_dir=self.root_dir, |
736 relpath=self.relpath) | 737 relpath=self.relpath) |
737 file_list = [] | 738 file_list = [] |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
822 | 823 |
823 if __name__ == '__main__': | 824 if __name__ == '__main__': |
824 if '-v' in sys.argv: | 825 if '-v' in sys.argv: |
825 logging.basicConfig( | 826 logging.basicConfig( |
826 level=logging.DEBUG, | 827 level=logging.DEBUG, |
827 format='%(asctime).19s %(levelname)s %(filename)s:' | 828 format='%(asctime).19s %(levelname)s %(filename)s:' |
828 '%(lineno)s %(message)s') | 829 '%(lineno)s %(message)s') |
829 unittest.main() | 830 unittest.main() |
830 | 831 |
831 # vim: ts=2:sw=2:tw=80:et: | 832 # vim: ts=2:sw=2:tw=80:et: |
OLD | NEW |