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

Side by Side Diff: tests/gclient_test.py

Issue 1356005: Add the ability to check out a single file from a repo.... (Closed) Base URL: http://src.chromium.org/svn/trunk/tools/depot_tools/
Patch Set: '' Created 10 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 | « tests/gclient_scm_test.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, IsOneOf, SuperMoxTestBase 9 from super_mox import mox, IsOneOf, SuperMoxTestBase
10 10
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 206
207 def testGoodClient(self): 207 def testGoodClient(self):
208 self.ReturnValue('runhooks', gclient.DoRunHooks, 0) 208 self.ReturnValue('runhooks', gclient.DoRunHooks, 0)
209 def testError(self): 209 def testError(self):
210 self.ReturnValue('runhooks', gclient.DoRunHooks, 42) 210 self.ReturnValue('runhooks', gclient.DoRunHooks, 42)
211 def testBadClient(self): 211 def testBadClient(self):
212 self.BadClient(gclient.DoRunHooks) 212 self.BadClient(gclient.DoRunHooks)
213 213
214 214
215 class TestDoUpdate(GenericCommandTestCase): 215 class TestDoUpdate(GenericCommandTestCase):
216 def Options(self, verbose=False, *args, **kwargs):
217 return self.OptionsObject(self, verbose=verbose, *args, **kwargs)
218
219 def ReturnValue(self, command, function, return_value): 216 def ReturnValue(self, command, function, return_value):
220 options = self.Options() 217 options = self.Options()
221 gclient.GClient.LoadCurrentConfig(options).AndReturn(gclient.GClient) 218 gclient.GClient.LoadCurrentConfig(options).AndReturn(gclient.GClient)
222 gclient.GClient.GetVar("solutions") 219 gclient.GClient.GetVar("solutions")
223 gclient.GClient.RunOnDeps(command, self.args).AndReturn(return_value) 220 gclient.GClient.RunOnDeps(command, self.args).AndReturn(return_value)
224 221
225 self.mox.ReplayAll() 222 self.mox.ReplayAll()
226 result = function(options, self.args) 223 result = function(options, self.args)
227 self.assertEquals(result, return_value) 224 self.assertEquals(result, return_value)
228 225
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 class GClientClassTestCase(GclientTestCase): 299 class GClientClassTestCase(GclientTestCase):
303 def testDir(self): 300 def testDir(self):
304 members = [ 301 members = [
305 'ConfigContent', 'FromImpl', 'GetVar', 'LoadCurrentConfig', 302 'ConfigContent', 'FileImpl', 'FromImpl', 'GetVar', 'LoadCurrentConfig',
306 'RunOnDeps', 'SaveConfig', 'SetConfig', 'SetDefaultConfig', 303 'RunOnDeps', 'SaveConfig', 'SetConfig', 'SetDefaultConfig',
307 'supported_commands', 'PrintRevInfo', 304 'supported_commands', 'PrintRevInfo',
308 ] 305 ]
309 306
310 # 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!
311 self.compareMembers(self._gclient_gclient('root_dir', 'options'), members) 308 self.compareMembers(self._gclient_gclient('root_dir', 'options'), members)
312 309
313 def testSetConfig_ConfigContent_GetVar_SaveConfig_SetDefaultConfig(self): 310 def testSetConfig_ConfigContent_GetVar_SaveConfig_SetDefaultConfig(self):
314 options = self.Options() 311 options = self.Options()
315 text = "# Dummy content\nclient = 'my client'" 312 text = "# Dummy content\nclient = 'my client'"
(...skipping 710 matching lines...) Expand 10 before | Expand all | Expand 10 after
1026 self.mox.ReplayAll() 1023 self.mox.ReplayAll()
1027 client = self._gclient_gclient(self.root_dir, options) 1024 client = self._gclient_gclient(self.root_dir, options)
1028 exception = "No solution specified" 1025 exception = "No solution specified"
1029 self.assertRaisesError(exception, self._gclient_gclient.RunOnDeps, client, 1026 self.assertRaisesError(exception, self._gclient_gclient.RunOnDeps, client,
1030 'update', self.args) 1027 'update', self.args)
1031 1028
1032 def testFromImpl(self): 1029 def testFromImpl(self):
1033 # TODO(maruel): Test me! 1030 # TODO(maruel): Test me!
1034 pass 1031 pass
1035 1032
1033 def testFileImpl(self):
1034 # Fake .gclient file.
1035 name = "testFileImpl"
1036 gclient_config = (
1037 "solutions = [ { 'name': '%s',"
1038 "'url': '%s', } ]" % (name, self.url)
1039 )
1040 # Fake DEPS file.
1041 target = "chromium_deps"
1042 deps_content = (
1043 "deps = {"
1044 " '%s': File('%s/DEPS') }" % (target, self.url)
1045 )
1046
1047 gclient.gclient_scm.CreateSCM(self.url, self.root_dir, name).AndReturn(
1048 gclient.gclient_scm.CreateSCM)
1049 options = self.Options()
1050 gclient.gclient_scm.CreateSCM.RunCommand('update', options, self.args, [])
1051 gclient.gclient_utils.FileRead(
1052 gclient.os.path.join(self.root_dir, name, options.deps_file)
1053 ).AndReturn(deps_content)
1054 gclient.os.path.exists(
1055 gclient.os.path.join(self.root_dir, name, '.git')
1056 ).AndReturn(False)
1057 gclient.os.path.exists(
1058 gclient.os.path.join(self.root_dir, options.entries_filename)
1059 ).AndReturn(False)
1060
1061 # This is where gclient tries to do the initial checkout.
1062 gclient.gclient_scm.CreateSCM(self.url, self.root_dir, target).AndReturn(
1063 gclient.gclient_scm.CreateSCM)
1064 gclient.gclient_scm.CreateSCM.RunCommand('updatesingle', options,
1065 self.args + ["DEPS"], [])
1066 gclient.gclient_utils.FileWrite(
1067 gclient.os.path.join(self.root_dir, options.entries_filename),
1068 "entries = \\\n{'%s': '%s'}\n" % (name, self.url))
1069
1070 self.mox.ReplayAll()
1071 client = self._gclient_gclient(self.root_dir, options)
1072 client.SetConfig(gclient_config)
1073 client.RunOnDeps('update', self.args)
1074
1036 def test_PrintRevInfo(self): 1075 def test_PrintRevInfo(self):
1037 # TODO(aharper): no test yet for revinfo, lock it down once we've verified 1076 # TODO(aharper): no test yet for revinfo, lock it down once we've verified
1038 # implementation for Pulse plugin 1077 # implementation for Pulse plugin
1039 pass 1078 pass
1040 1079
1041 # No test for internal functions. 1080 # No test for internal functions.
1042 def test_GetAllDeps(self): 1081 def test_GetAllDeps(self):
1043 pass 1082 pass
1044 def test_GetDefaultSolutionDeps(self): 1083 def test_GetDefaultSolutionDeps(self):
1045 pass 1084 pass
1046 def test_LoadConfig(self): 1085 def test_LoadConfig(self):
1047 pass 1086 pass
1048 def test_ReadEntries(self): 1087 def test_ReadEntries(self):
1049 pass 1088 pass
1050 def test_SaveEntries(self): 1089 def test_SaveEntries(self):
1051 pass 1090 pass
1052 def test_VarImpl(self): 1091 def test_VarImpl(self):
1053 pass 1092 pass
1054 1093
1055 1094
1056 if __name__ == '__main__': 1095 if __name__ == '__main__':
1057 import unittest 1096 import unittest
1058 unittest.main() 1097 unittest.main()
1059 1098
1060 # vim: ts=2:sw=2:tw=80:et: 1099 # vim: ts=2:sw=2:tw=80:et:
OLDNEW
« no previous file with comments | « tests/gclient_scm_test.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698