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

Side by Side Diff: tests/gclient_scm_test.py

Issue 6594038: Accept output from even more Git versions in tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: whitespace Created 9 years, 9 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 | « 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 # 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.
11 from os import rename 11 from os import rename
12 from shutil import rmtree 12 from shutil import rmtree
13 from subprocess import Popen, PIPE, STDOUT 13 from subprocess import Popen, PIPE, STDOUT
14 import tempfile 14 import tempfile
15 import unittest 15 import unittest
16 import __builtin__ 16 import __builtin__
17 17
18 # Fixes include path. 18 # Fixes include path.
19 from super_mox import mox, StdoutCheck, TestCaseUtils, SuperMoxTestBase 19 from super_mox import mox, StdoutCheck, TestCaseUtils, SuperMoxTestBase
20 20
21 import logging 21 import logging
22 import re
22 import sys 23 import sys
23 import gclient_scm 24 import gclient_scm
24 25
25 # Shortcut since this function is used often 26 # Shortcut since this function is used often
26 join = gclient_scm.os.path.join 27 join = gclient_scm.os.path.join
27 28
28 29
29 class GCBaseTestCase(object): 30 class GCBaseTestCase(object):
30 def assertRaisesError(self, msg, fn, *args, **kwargs): 31 def assertRaisesError(self, msg, fn, *args, **kwargs):
31 """Like unittest's assertRaises() but checks for Gclient.Error.""" 32 """Like unittest's assertRaises() but checks for Gclient.Error."""
(...skipping 699 matching lines...) Expand 10 before | Expand all | Expand 10 after
731 scm = gclient_scm.CreateSCM(url=url, root_dir=root_dir, 732 scm = gclient_scm.CreateSCM(url=url, root_dir=root_dir,
732 relpath=relpath) 733 relpath=relpath)
733 file_list = [] 734 file_list = []
734 scm.update(options, (), file_list) 735 scm.update(options, (), file_list)
735 self.assertEquals(len(file_list), 2) 736 self.assertEquals(len(file_list), 2)
736 self.assert_(gclient_scm.os.path.isfile(join(base_path, 'a'))) 737 self.assert_(gclient_scm.os.path.isfile(join(base_path, 'a')))
737 self.assertEquals(scm.revinfo(options, (), None), 738 self.assertEquals(scm.revinfo(options, (), None),
738 '069c602044c5388d2d15c3f875b057c852003458') 739 '069c602044c5388d2d15c3f875b057c852003458')
739 finally: 740 finally:
740 rmtree(root_dir) 741 rmtree(root_dir)
741 msg1 = ( 742 msg_re = re.compile(
742 "\n_____ foo at refs/heads/master\n\n" 743 "\n_____ foo at refs/heads/master\n\n"
743 "________ running 'git clone -b master --verbose %s %s' in '%s'\n" 744 "________ running 'git clone -b master --verbose %s %s' in '%s'\n"
744 "Initialized empty Git repository in %s\n") % ( 745 "(Initialized empty Git repository in "
745 join(self.root_dir, '.', '.git'), 746 "|Cloning into )(%s|%s)(...\ndone.)?\n" % (
746 join(root_dir, 'foo'), 747 re.escape(join(self.root_dir, '.', '.git')),
747 root_dir, 748 re.escape(join(root_dir, 'foo')),
748 join(gclient_scm.os.path.realpath(root_dir), 'foo', '.git') + '/') 749 re.escape(root_dir),
749 msg2 = ( 750 re.escape(join(gclient_scm.os.path.realpath(root_dir),
750 "\n_____ foo at refs/heads/master\n\n" 751 'foo', '.git')) + '/',
751 "________ running 'git clone -b master --verbose %s %s' in '%s'\n" 752 re.escape(join(root_dir, 'foo'))))
752 "Cloning into %s...\ndone.\n") % (
753 join(self.root_dir, '.', '.git'),
754 join(root_dir, 'foo'),
755 root_dir,
756 join(gclient_scm.os.path.realpath(root_dir), 'foo'))
757 out = sys.stdout.getvalue() 753 out = sys.stdout.getvalue()
758 sys.stdout.close() 754 sys.stdout.close()
759 self.assertTrue(out in (msg1, msg2), (out, msg1, msg2)) 755 self.assertTrue(re.match(msg_re, out))
evanm 2011/02/28 22:35:11 Might be better to just set the --quiet flag and r
760 756
761 def testUpdateUpdate(self): 757 def testUpdateUpdate(self):
762 if not self.enabled: 758 if not self.enabled:
763 return 759 return
764 options = self.Options() 760 options = self.Options()
765 expected_file_list = [join(self.base_path, x) for x in ['a', 'b']] 761 expected_file_list = [join(self.base_path, x) for x in ['a', 'b']]
766 scm = gclient_scm.CreateSCM(url=self.url, root_dir=self.root_dir, 762 scm = gclient_scm.CreateSCM(url=self.url, root_dir=self.root_dir,
767 relpath=self.relpath) 763 relpath=self.relpath)
768 file_list = [] 764 file_list = []
769 scm.update(options, (), file_list) 765 scm.update(options, (), file_list)
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
853 849
854 if __name__ == '__main__': 850 if __name__ == '__main__':
855 if '-v' in sys.argv: 851 if '-v' in sys.argv:
856 logging.basicConfig( 852 logging.basicConfig(
857 level=logging.DEBUG, 853 level=logging.DEBUG,
858 format='%(asctime).19s %(levelname)s %(filename)s:' 854 format='%(asctime).19s %(levelname)s %(filename)s:'
859 '%(lineno)s %(message)s') 855 '%(lineno)s %(message)s')
860 unittest.main() 856 unittest.main()
861 857
862 # vim: ts=2:sw=2:tw=80:et: 858 # 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