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

Side by Side Diff: tests/gclient_scm_test.py

Issue 10103024: Check binary existence in gclient: 2nd try. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools/
Patch Set: Created 8 years, 8 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_scm.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/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 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=E1103 8 # pylint: disable=E1103
9 9
10 # Import before super_mox to keep valid references. 10 # Import before super_mox to keep valid references.
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 self.mox.StubOutWithMock(gclient_scm.gclient_utils, 'FileWrite') 57 self.mox.StubOutWithMock(gclient_scm.gclient_utils, 'FileWrite')
58 self.mox.StubOutWithMock(gclient_scm.gclient_utils, 'RemoveDirectory') 58 self.mox.StubOutWithMock(gclient_scm.gclient_utils, 'RemoveDirectory')
59 self.mox.StubOutWithMock(gclient_scm.scm.SVN, 'Capture') 59 self.mox.StubOutWithMock(gclient_scm.scm.SVN, 'Capture')
60 self.mox.StubOutWithMock(gclient_scm.scm.SVN, '_CaptureInfo') 60 self.mox.StubOutWithMock(gclient_scm.scm.SVN, '_CaptureInfo')
61 self.mox.StubOutWithMock(gclient_scm.scm.SVN, 'CaptureStatus') 61 self.mox.StubOutWithMock(gclient_scm.scm.SVN, 'CaptureStatus')
62 self.mox.StubOutWithMock(gclient_scm.scm.SVN, 'RunAndGetFileList') 62 self.mox.StubOutWithMock(gclient_scm.scm.SVN, 'RunAndGetFileList')
63 self.mox.StubOutWithMock(subprocess2, 'communicate') 63 self.mox.StubOutWithMock(subprocess2, 'communicate')
64 self.mox.StubOutWithMock(subprocess2, 'Popen') 64 self.mox.StubOutWithMock(subprocess2, 'Popen')
65 self._scm_wrapper = gclient_scm.CreateSCM 65 self._scm_wrapper = gclient_scm.CreateSCM
66 gclient_scm.scm.SVN.current_version = None 66 gclient_scm.scm.SVN.current_version = None
67 self._original_SVNBinaryExists = gclient_scm.SVNWrapper.BinaryExists
68 self._original_GitBinaryExists = gclient_scm.GitWrapper.BinaryExists
69 gclient_scm.SVNWrapper.BinaryExists = staticmethod(lambda : True)
70 gclient_scm.GitWrapper.BinaryExists = staticmethod(lambda : True)
67 # Absolute path of the fake checkout directory. 71 # Absolute path of the fake checkout directory.
68 self.base_path = join(self.root_dir, self.relpath) 72 self.base_path = join(self.root_dir, self.relpath)
69 73
70 def tearDown(self): 74 def tearDown(self):
71 SuperMoxTestBase.tearDown(self) 75 SuperMoxTestBase.tearDown(self)
76 gclient_scm.SVNWrapper.BinaryExists = self._original_SVNBinaryExists
77 gclient_scm.GitWrapper.BinaryExists = self._original_GitBinaryExists
72 78
73 79
74 class SVNWrapperTestCase(BaseTestCase): 80 class SVNWrapperTestCase(BaseTestCase):
75 class OptionsObject(object): 81 class OptionsObject(object):
76 def __init__(self, verbose=False, revision=None, force=False): 82 def __init__(self, verbose=False, revision=None, force=False):
77 self.verbose = verbose 83 self.verbose = verbose
78 self.revision = revision 84 self.revision = revision
79 self.manually_grab_svn_rev = True 85 self.manually_grab_svn_rev = True
80 self.deps_os = None 86 self.deps_os = None
81 self.force = force 87 self.force = force
82 self.reset = False 88 self.reset = False
83 self.nohooks = False 89 self.nohooks = False
84 # TODO(maruel): Test --jobs > 1. 90 # TODO(maruel): Test --jobs > 1.
85 self.jobs = 1 91 self.jobs = 1
86 self.delete_unversioned_trees = False 92 self.delete_unversioned_trees = False
87 93
88 def Options(self, *args, **kwargs): 94 def Options(self, *args, **kwargs):
89 return self.OptionsObject(*args, **kwargs) 95 return self.OptionsObject(*args, **kwargs)
90 96
91 def setUp(self): 97 def setUp(self):
92 BaseTestCase.setUp(self) 98 BaseTestCase.setUp(self)
93 self.url = self.SvnUrl() 99 self.url = self.SvnUrl()
94 100
95 def testDir(self): 101 def testDir(self):
96 members = [ 102 members = [
103 'BinaryExists',
97 'FullUrlForRelativeUrl', 104 'FullUrlForRelativeUrl',
98 'GetRevisionDate', 105 'GetRevisionDate',
99 'GetUsableRev', 106 'GetUsableRev',
100 'RunCommand', 107 'RunCommand',
101 'cleanup', 108 'cleanup',
102 'diff', 109 'diff',
103 'pack', 110 'pack',
104 'relpath', 111 'relpath',
105 'revert', 112 'revert',
106 'revinfo', 113 'revinfo',
(...skipping 636 matching lines...) Expand 10 before | Expand all | Expand 10 after
743 750
744 def setUp(self): 751 def setUp(self):
745 TestCaseUtils.setUp(self) 752 TestCaseUtils.setUp(self)
746 unittest.TestCase.setUp(self) 753 unittest.TestCase.setUp(self)
747 self.url = 'git://foo' 754 self.url = 'git://foo'
748 self.root_dir = tempfile.mkdtemp() 755 self.root_dir = tempfile.mkdtemp()
749 self.relpath = '.' 756 self.relpath = '.'
750 self.base_path = join(self.root_dir, self.relpath) 757 self.base_path = join(self.root_dir, self.relpath)
751 self.enabled = self.CreateGitRepo(self.sample_git_import, self.base_path) 758 self.enabled = self.CreateGitRepo(self.sample_git_import, self.base_path)
752 StdoutCheck.setUp(self) 759 StdoutCheck.setUp(self)
760 self._original_GitBinaryExists = gclient_scm.GitWrapper.BinaryExists
761 self._original_SVNBinaryExists = gclient_scm.SVNWrapper.BinaryExists
762 gclient_scm.GitWrapper.BinaryExists = staticmethod(lambda : True)
763 gclient_scm.SVNWrapper.BinaryExists = staticmethod(lambda : True)
753 764
754 def tearDown(self): 765 def tearDown(self):
755 StdoutCheck.tearDown(self) 766 StdoutCheck.tearDown(self)
756 TestCaseUtils.tearDown(self) 767 TestCaseUtils.tearDown(self)
757 unittest.TestCase.tearDown(self) 768 unittest.TestCase.tearDown(self)
758 rmtree(self.root_dir) 769 rmtree(self.root_dir)
770 gclient_scm.GitWrapper.BinaryExists = self._original_GitBinaryExists
771 gclient_scm.SVNWrapper.BinaryExists = self._original_SVNBinaryExists
759 772
760 class ManagedGitWrapperTestCase(BaseGitWrapperTestCase): 773 class ManagedGitWrapperTestCase(BaseGitWrapperTestCase):
761 def testDir(self): 774 def testDir(self):
762 members = [ 775 members = [
776 'BinaryExists',
763 'FullUrlForRelativeUrl', 777 'FullUrlForRelativeUrl',
764 'GetRevisionDate', 778 'GetRevisionDate',
765 'GetUsableRev', 779 'GetUsableRev',
766 'RunCommand', 780 'RunCommand',
767 'cleanup', 781 'cleanup',
768 'diff', 782 'diff',
769 'pack', 783 'pack',
770 'relpath', 784 'relpath',
771 'revert', 785 'revert',
772 'revinfo', 786 'revinfo',
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after
1206 1220
1207 if __name__ == '__main__': 1221 if __name__ == '__main__':
1208 if '-v' in sys.argv: 1222 if '-v' in sys.argv:
1209 logging.basicConfig( 1223 logging.basicConfig(
1210 level=logging.DEBUG, 1224 level=logging.DEBUG,
1211 format='%(asctime).19s %(levelname)s %(filename)s:' 1225 format='%(asctime).19s %(levelname)s %(filename)s:'
1212 '%(lineno)s %(message)s') 1226 '%(lineno)s %(message)s')
1213 unittest.main() 1227 unittest.main()
1214 1228
1215 # vim: ts=2:sw=2:tw=80:et: 1229 # vim: ts=2:sw=2:tw=80:et:
OLDNEW
« no previous file with comments | « gclient_scm.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698