blob: 761c3b1ebcedfa14ea0e0fc9459fa332ce737308 [file] [log] [blame]
msb@chromium.orge28e4982009-09-25 20:51:45 +00001#!/usr/bin/python
2#
3# Copyright 2008-2009 Google Inc. All Rights Reserved.
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16
17"""Unit tests for gclient_scm.py."""
18
19import os
20import shutil
21import subprocess
22import tempfile
23import unittest
24
25import gclient
26import gclient_scm
27import gclient_test
28import gclient_utils
29from super_mox import mox
30
31
32class SVNWrapperTestCase(gclient_test.GClientBaseTestCase):
33 class OptionsObject(object):
34 def __init__(self, test_case, verbose=False, revision=None):
35 self.verbose = verbose
36 self.revision = revision
37 self.manually_grab_svn_rev = True
38 self.deps_os = None
39 self.force = False
40 self.nohooks = False
41
42 def setUp(self):
43 gclient_test.GClientBaseTestCase.setUp(self)
44 self.root_dir = self.Dir()
45 self.args = self.Args()
46 self.url = self.Url()
47 self.relpath = 'asf'
48
49 def testDir(self):
50 members = [
51 'FullUrlForRelativeUrl', 'RunCommand', 'cleanup', 'diff', 'export',
msb@chromium.org0f282062009-11-06 20:14:02 +000052 'pack', 'relpath', 'revert', 'revinfo', 'runhooks', 'scm_name', 'status',
msb@chromium.orge28e4982009-09-25 20:51:45 +000053 'update', 'url',
54 ]
55
56 # If you add a member, be sure to add the relevant test!
57 self.compareMembers(self._scm_wrapper(), members)
58
59 def testUnsupportedSCM(self):
60 args = [self.url, self.root_dir, self.relpath]
61 kwargs = {'scm_name' : 'foo'}
62 exception_msg = 'Unsupported scm %(scm_name)s' % kwargs
63 self.assertRaisesError(exception_msg, self._scm_wrapper, *args, **kwargs)
64
65 def testFullUrlForRelativeUrl(self):
66 self.url = 'svn://a/b/c/d'
67
68 self.mox.ReplayAll()
69 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir,
70 relpath=self.relpath)
71 self.assertEqual(scm.FullUrlForRelativeUrl('/crap'), 'svn://a/b/crap')
72
73 def testRunCommandException(self):
74 options = self.Options(verbose=False)
75 file_path = os.path.join(self.root_dir, self.relpath, '.git')
76 gclient.os.path.exists(file_path).AndReturn(False)
77
78 self.mox.ReplayAll()
79 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir,
80 relpath=self.relpath)
81 exception = "Unsupported argument(s): %s" % ','.join(self.args)
82 self.assertRaisesError(exception, scm.RunCommand,
83 'update', options, self.args)
84
85 def testRunCommandUnknown(self):
86 # TODO(maruel): if ever used.
87 pass
88
89 def testRevertMissing(self):
90 options = self.Options(verbose=True)
91 base_path = os.path.join(self.root_dir, self.relpath)
92 gclient.os.path.isdir(base_path).AndReturn(False)
93 # It'll to a checkout instead.
94 gclient.os.path.exists(os.path.join(base_path, '.git')).AndReturn(False)
95 print("\n_____ %s is missing, synching instead" % self.relpath)
96 # Checkout.
97 gclient.os.path.exists(base_path).AndReturn(False)
98 files_list = self.mox.CreateMockAnything()
dpranke@google.com22e29d42009-10-28 00:48:26 +000099 gclient_scm.RunSVNAndGetFileList(options, ['checkout', self.url, base_path],
msb@chromium.orge28e4982009-09-25 20:51:45 +0000100 self.root_dir, files_list)
101
102 self.mox.ReplayAll()
103 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir,
104 relpath=self.relpath)
105 scm.revert(options, self.args, files_list)
106
107 def testRevertNone(self):
108 options = self.Options(verbose=True)
109 base_path = os.path.join(self.root_dir, self.relpath)
110 gclient.os.path.isdir(base_path).AndReturn(True)
111 gclient_scm.CaptureSVNStatus(base_path).AndReturn([])
dpranke@google.com22e29d42009-10-28 00:48:26 +0000112 gclient_scm.RunSVNAndGetFileList(options, ['update', '--revision', 'BASE'],
msb@chromium.orge28e4982009-09-25 20:51:45 +0000113 base_path, mox.IgnoreArg())
114
115 self.mox.ReplayAll()
116 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir,
117 relpath=self.relpath)
118 file_list = []
119 scm.revert(options, self.args, file_list)
120
121 def testRevert2Files(self):
122 options = self.Options(verbose=True)
123 base_path = os.path.join(self.root_dir, self.relpath)
124 gclient.os.path.isdir(base_path).AndReturn(True)
125 items = [
126 ('M ', 'a'),
127 ('A ', 'b'),
128 ]
129 file_path1 = os.path.join(base_path, 'a')
130 file_path2 = os.path.join(base_path, 'b')
131 gclient_scm.CaptureSVNStatus(base_path).AndReturn(items)
132 gclient_scm.os.path.exists(file_path1).AndReturn(True)
133 gclient_scm.os.path.isfile(file_path1).AndReturn(True)
134 gclient_scm.os.remove(file_path1)
135 gclient_scm.os.path.exists(file_path2).AndReturn(True)
136 gclient_scm.os.path.isfile(file_path2).AndReturn(True)
137 gclient_scm.os.remove(file_path2)
dpranke@google.com22e29d42009-10-28 00:48:26 +0000138 gclient_scm.RunSVNAndGetFileList(options, ['update', '--revision', 'BASE'],
msb@chromium.orge28e4982009-09-25 20:51:45 +0000139 base_path, mox.IgnoreArg())
140 print(os.path.join(base_path, 'a'))
141 print(os.path.join(base_path, 'b'))
142
143 self.mox.ReplayAll()
144 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir,
145 relpath=self.relpath)
146 file_list = []
147 scm.revert(options, self.args, file_list)
148
149 def testRevertDirectory(self):
150 options = self.Options(verbose=True)
151 base_path = os.path.join(self.root_dir, self.relpath)
152 gclient.os.path.isdir(base_path).AndReturn(True)
153 items = [
154 ('~ ', 'a'),
155 ]
156 gclient_scm.CaptureSVNStatus(base_path).AndReturn(items)
157 file_path = os.path.join(base_path, 'a')
158 print(file_path)
159 gclient_scm.os.path.exists(file_path).AndReturn(True)
160 gclient_scm.os.path.isfile(file_path).AndReturn(False)
161 gclient_scm.os.path.isdir(file_path).AndReturn(True)
162 gclient_utils.RemoveDirectory(file_path)
163 file_list1 = []
dpranke@google.com22e29d42009-10-28 00:48:26 +0000164 gclient_scm.RunSVNAndGetFileList(options, ['update', '--revision', 'BASE'],
msb@chromium.orge28e4982009-09-25 20:51:45 +0000165 base_path, mox.IgnoreArg())
166
167 self.mox.ReplayAll()
168 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir,
169 relpath=self.relpath)
170 file_list2 = []
171 scm.revert(options, self.args, file_list2)
172
173 def testStatus(self):
174 options = self.Options(verbose=True)
175 base_path = os.path.join(self.root_dir, self.relpath)
176 gclient.os.path.isdir(base_path).AndReturn(True)
dpranke@google.com22e29d42009-10-28 00:48:26 +0000177 gclient_scm.RunSVNAndGetFileList(options, ['status'] + self.args,
178 base_path, []).AndReturn(None)
msb@chromium.orge28e4982009-09-25 20:51:45 +0000179
180 self.mox.ReplayAll()
181 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir,
182 relpath=self.relpath)
183 file_list = []
184 self.assertEqual(scm.status(options, self.args, file_list), None)
185
186
187 # TODO(maruel): TEST REVISIONS!!!
188 # TODO(maruel): TEST RELOCATE!!!
189 def testUpdateCheckout(self):
190 options = self.Options(verbose=True)
191 base_path = os.path.join(self.root_dir, self.relpath)
192 file_info = gclient_utils.PrintableObject()
193 file_info.root = 'blah'
194 file_info.url = self.url
195 file_info.uuid = 'ABC'
196 file_info.revision = 42
197 gclient.os.path.exists(os.path.join(base_path, '.git')).AndReturn(False)
198 # Checkout.
199 gclient.os.path.exists(base_path).AndReturn(False)
200 files_list = self.mox.CreateMockAnything()
dpranke@google.com22e29d42009-10-28 00:48:26 +0000201 gclient_scm.RunSVNAndGetFileList(options, ['checkout', self.url,
202 base_path], self.root_dir, files_list)
msb@chromium.orge28e4982009-09-25 20:51:45 +0000203 self.mox.ReplayAll()
204 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir,
205 relpath=self.relpath)
206 scm.update(options, (), files_list)
207
208 def testUpdateUpdate(self):
209 options = self.Options(verbose=True)
210 base_path = os.path.join(self.root_dir, self.relpath)
211 options.force = True
212 options.nohooks = False
213 file_info = {
214 'Repository Root': 'blah',
215 'URL': self.url,
216 'UUID': 'ABC',
217 'Revision': 42,
218 }
219 gclient.os.path.exists(os.path.join(base_path, '.git')).AndReturn(False)
220 # Checkout or update.
221 gclient.os.path.exists(base_path).AndReturn(True)
222 gclient_scm.CaptureSVNInfo(os.path.join(base_path, "."), '.'
223 ).AndReturn(file_info)
224 # Cheat a bit here.
225 gclient_scm.CaptureSVNInfo(file_info['URL'], '.').AndReturn(file_info)
226 additional_args = []
227 if options.manually_grab_svn_rev:
228 additional_args = ['--revision', str(file_info['Revision'])]
229 files_list = []
dpranke@google.com22e29d42009-10-28 00:48:26 +0000230 gclient_scm.RunSVNAndGetFileList(options,
231 ['update', base_path] + additional_args,
maruel@chromium.org7753d242009-10-07 17:40:24 +0000232 self.root_dir, files_list)
msb@chromium.orge28e4982009-09-25 20:51:45 +0000233
234 self.mox.ReplayAll()
235 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir,
236 relpath=self.relpath)
237 scm.update(options, (), files_list)
238
239 def testUpdateGit(self):
240 options = self.Options(verbose=True)
241 file_path = os.path.join(self.root_dir, self.relpath, '.git')
242 gclient.os.path.exists(file_path).AndReturn(True)
243 print("________ found .git directory; skipping %s" % self.relpath)
244
245 self.mox.ReplayAll()
246 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir,
247 relpath=self.relpath)
248 file_list = []
249 scm.update(options, self.args, file_list)
250
251 def testGetSVNFileInfo(self):
252 xml_text = r"""<?xml version="1.0"?>
253<info>
254<entry kind="file" path="%s" revision="14628">
255<url>http://src.chromium.org/svn/trunk/src/chrome/app/d</url>
256<repository><root>http://src.chromium.org/svn</root></repository>
257<wc-info>
258<schedule>add</schedule>
259<depth>infinity</depth>
260<copy-from-url>http://src.chromium.org/svn/trunk/src/chrome/app/DEPS</copy-from-url>
261<copy-from-rev>14628</copy-from-rev>
262<checksum>369f59057ba0e6d9017e28f8bdfb1f43</checksum>
263</wc-info>
264</entry>
265</info>
266""" % self.url
267 gclient_scm.CaptureSVN(['info', '--xml', self.url],
268 '.', True).AndReturn(xml_text)
269 expected = {
270 'URL': 'http://src.chromium.org/svn/trunk/src/chrome/app/d',
271 'UUID': None,
272 'Repository Root': 'http://src.chromium.org/svn',
273 'Schedule': 'add',
274 'Copied From URL':
275 'http://src.chromium.org/svn/trunk/src/chrome/app/DEPS',
276 'Copied From Rev': '14628',
277 'Path': self.url,
278 'Revision': 14628,
279 'Node Kind': 'file',
280 }
281 self.mox.ReplayAll()
282 file_info = self._CaptureSVNInfo(self.url, '.', True)
283 self.assertEquals(sorted(file_info.items()), sorted(expected.items()))
284
285 def testCaptureSvnInfo(self):
286 xml_text = """<?xml version="1.0"?>
287<info>
288<entry
289 kind="dir"
290 path="."
291 revision="35">
292<url>%s</url>
293<repository>
294<root>%s</root>
295<uuid>7b9385f5-0452-0410-af26-ad4892b7a1fb</uuid>
296</repository>
297<wc-info>
298<schedule>normal</schedule>
299<depth>infinity</depth>
300</wc-info>
301<commit
302 revision="35">
303<author>maruel</author>
304<date>2008-12-04T20:12:19.685120Z</date>
305</commit>
306</entry>
307</info>
308""" % (self.url, self.root_dir)
309 gclient_scm.CaptureSVN(['info', '--xml',
310 self.url], '.', True).AndReturn(xml_text)
311 self.mox.ReplayAll()
312 file_info = self._CaptureSVNInfo(self.url, '.', True)
313 expected = {
314 'URL': self.url,
315 'UUID': '7b9385f5-0452-0410-af26-ad4892b7a1fb',
316 'Revision': 35,
317 'Repository Root': self.root_dir,
318 'Schedule': 'normal',
319 'Copied From URL': None,
320 'Copied From Rev': None,
321 'Path': '.',
322 'Node Kind': 'dir',
323 }
324 self.assertEqual(file_info, expected)
325
msb@chromium.org0f282062009-11-06 20:14:02 +0000326 def testRevinfo(self):
327 options = self.Options(verbose=False)
328 xml_text = """<?xml version="1.0"?>
329<info>
330<entry
331 kind="dir"
332 path="."
333 revision="35">
334<url>%s</url>
335<repository>
336<root>%s</root>
337<uuid>7b9385f5-0452-0410-af26-ad4892b7a1fb</uuid>
338</repository>
339<wc-info>
340<schedule>normal</schedule>
341<depth>infinity</depth>
342</wc-info>
343<commit
344 revision="35">
345<author>maruel</author>
346<date>2008-12-04T20:12:19.685120Z</date>
347</commit>
348</entry>
349</info>
350""" % (self.url, self.root_dir)
351 gclient_scm.CaptureSVN(['info', '--xml',
352 self.url], os.getcwd()).AndReturn(xml_text)
353 self.mox.ReplayAll()
354 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir,
355 relpath=self.relpath)
356 rev_info = scm.revinfo(options, self.args, None)
357 self.assertEqual(rev_info, '35')
358
msb@chromium.orge28e4982009-09-25 20:51:45 +0000359
360class GitWrapperTestCase(gclient_test.GClientBaseTestCase):
361 class OptionsObject(object):
362 def __init__(self, test_case, verbose=False, revision=None):
363 self.verbose = verbose
364 self.revision = revision
365 self.manually_grab_svn_rev = True
366 self.deps_os = None
367 self.force = False
368 self.nohooks = False
369
370 sample_git_import = """blob
371mark :1
372data 6
373Hello
374
375blob
376mark :2
377data 4
378Bye
379
380reset refs/heads/master
381commit refs/heads/master
382mark :3
383author Bob <bob@example.com> 1253744361 -0700
384committer Bob <bob@example.com> 1253744361 -0700
385data 8
386A and B
387M 100644 :1 a
388M 100644 :2 b
389
390blob
391mark :4
392data 10
393Hello
394You
395
396blob
397mark :5
398data 8
399Bye
400You
401
402commit refs/heads/origin
403mark :6
404author Alice <alice@example.com> 1253744424 -0700
405committer Alice <alice@example.com> 1253744424 -0700
406data 13
407Personalized
408from :3
409M 100644 :4 a
410M 100644 :5 b
411
412reset refs/heads/master
413from :3
414"""
msb@chromium.orge28e4982009-09-25 20:51:45 +0000415 def Options(self, *args, **kwargs):
416 return self.OptionsObject(self, *args, **kwargs)
417
418 def CreateGitRepo(self, git_import, path):
maruel@chromium.orgea6c2c52009-10-09 20:38:14 +0000419 try:
420 subprocess.Popen(['git', 'init'], stdout=subprocess.PIPE,
421 stderr=subprocess.STDOUT, cwd=path).communicate()
422 except WindowsError:
423 # git is not available, skip this test.
424 return False
msb@chromium.orge28e4982009-09-25 20:51:45 +0000425 subprocess.Popen(['git', 'fast-import'], stdin=subprocess.PIPE,
426 stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
427 cwd=path).communicate(input=git_import)
428 subprocess.Popen(['git', 'checkout'], stdout=subprocess.PIPE,
429 stderr=subprocess.STDOUT, cwd=path).communicate()
maruel@chromium.orgea6c2c52009-10-09 20:38:14 +0000430 return True
msb@chromium.orge28e4982009-09-25 20:51:45 +0000431
msb@chromium.orge28e4982009-09-25 20:51:45 +0000432 def setUp(self):
433 gclient_test.BaseTestCase.setUp(self)
434 self.args = self.Args()
435 self.url = 'git://foo'
436 self.root_dir = tempfile.mkdtemp()
437 self.relpath = '.'
438 self.base_path = os.path.join(self.root_dir, self.relpath)
maruel@chromium.orgea6c2c52009-10-09 20:38:14 +0000439 self.enabled = self.CreateGitRepo(self.sample_git_import, self.base_path)
msb@chromium.orge28e4982009-09-25 20:51:45 +0000440
441 def tearDown(self):
442 shutil.rmtree(self.root_dir)
443 gclient_test.BaseTestCase.tearDown(self)
444
445 def testDir(self):
446 members = [
447 'FullUrlForRelativeUrl', 'RunCommand', 'cleanup', 'diff', 'export',
msb@chromium.org0f282062009-11-06 20:14:02 +0000448 'relpath', 'revert', 'revinfo', 'runhooks', 'scm_name', 'status',
449 'update', 'url',
msb@chromium.orge28e4982009-09-25 20:51:45 +0000450 ]
451
452 # If you add a member, be sure to add the relevant test!
453 self.compareMembers(gclient_scm.CreateSCM(url=self.url), members)
454
455 def testRevertMissing(self):
maruel@chromium.orgea6c2c52009-10-09 20:38:14 +0000456 if not self.enabled:
457 return
msb@chromium.orge28e4982009-09-25 20:51:45 +0000458 options = self.Options()
459 file_path = os.path.join(self.base_path, 'a')
460 os.remove(file_path)
461 scm = gclient_scm.CreateSCM(url=self.url, root_dir=self.root_dir,
462 relpath=self.relpath)
463 file_list = []
464 scm.revert(options, self.args, file_list)
465 self.assertEquals(file_list, [file_path])
466 file_list = []
467 scm.diff(options, self.args, file_list)
468 self.assertEquals(file_list, [])
469
470 def testRevertNone(self):
maruel@chromium.orgea6c2c52009-10-09 20:38:14 +0000471 if not self.enabled:
472 return
msb@chromium.orge28e4982009-09-25 20:51:45 +0000473 options = self.Options()
474 scm = gclient_scm.CreateSCM(url=self.url, root_dir=self.root_dir,
475 relpath=self.relpath)
476 file_list = []
477 scm.revert(options, self.args, file_list)
478 self.assertEquals(file_list, [])
msb@chromium.org0f282062009-11-06 20:14:02 +0000479 self.assertEquals(scm.revinfo(options, self.args, None),
msb@chromium.orge28e4982009-09-25 20:51:45 +0000480 '069c602044c5388d2d15c3f875b057c852003458')
481
482
483 def testRevertModified(self):
maruel@chromium.orgea6c2c52009-10-09 20:38:14 +0000484 if not self.enabled:
485 return
msb@chromium.orge28e4982009-09-25 20:51:45 +0000486 options = self.Options()
487 file_path = os.path.join(self.base_path, 'a')
488 open(file_path, 'a').writelines('touched\n')
489 scm = gclient_scm.CreateSCM(url=self.url, root_dir=self.root_dir,
490 relpath=self.relpath)
491 file_list = []
492 scm.revert(options, self.args, file_list)
493 self.assertEquals(file_list, [file_path])
494 file_list = []
495 scm.diff(options, self.args, file_list)
496 self.assertEquals(file_list, [])
msb@chromium.org0f282062009-11-06 20:14:02 +0000497 self.assertEquals(scm.revinfo(options, self.args, None),
msb@chromium.orge28e4982009-09-25 20:51:45 +0000498 '069c602044c5388d2d15c3f875b057c852003458')
499
500 def testRevertNew(self):
maruel@chromium.orgea6c2c52009-10-09 20:38:14 +0000501 if not self.enabled:
502 return
msb@chromium.orge28e4982009-09-25 20:51:45 +0000503 options = self.Options()
504 file_path = os.path.join(self.base_path, 'c')
505 f = open(file_path, 'w')
506 f.writelines('new\n')
507 f.close()
508 subprocess.Popen(['git', 'add', 'c'], stdout=subprocess.PIPE,
509 stderr=subprocess.STDOUT, cwd=self.base_path).communicate()
510 scm = gclient_scm.CreateSCM(url=self.url, root_dir=self.root_dir,
511 relpath=self.relpath)
512 file_list = []
513 scm.revert(options, self.args, file_list)
514 self.assertEquals(file_list, [file_path])
515 file_list = []
516 scm.diff(options, self.args, file_list)
517 self.assertEquals(file_list, [])
msb@chromium.org0f282062009-11-06 20:14:02 +0000518 self.assertEquals(scm.revinfo(options, self.args, None),
msb@chromium.orge28e4982009-09-25 20:51:45 +0000519 '069c602044c5388d2d15c3f875b057c852003458')
520
521 def testStatusNew(self):
maruel@chromium.orgea6c2c52009-10-09 20:38:14 +0000522 if not self.enabled:
523 return
msb@chromium.orge28e4982009-09-25 20:51:45 +0000524 options = self.Options()
525 file_path = os.path.join(self.base_path, 'a')
526 open(file_path, 'a').writelines('touched\n')
527 scm = gclient_scm.CreateSCM(url=self.url, root_dir=self.root_dir,
528 relpath=self.relpath)
529 file_list = []
530 scm.status(options, self.args, file_list)
531 self.assertEquals(file_list, [file_path])
532
533 def testStatus2New(self):
maruel@chromium.orgea6c2c52009-10-09 20:38:14 +0000534 if not self.enabled:
535 return
msb@chromium.orge28e4982009-09-25 20:51:45 +0000536 options = self.Options()
537 expected_file_list = []
538 for f in ['a', 'b']:
539 file_path = os.path.join(self.base_path, f)
540 open(file_path, 'a').writelines('touched\n')
541 expected_file_list.extend([file_path])
542 scm = gclient_scm.CreateSCM(url=self.url, root_dir=self.root_dir,
543 relpath=self.relpath)
544 file_list = []
545 scm.status(options, self.args, file_list)
546 expected_file_list = [os.path.join(self.base_path, x) for x in ['a', 'b']]
547 self.assertEquals(sorted(file_list), expected_file_list)
548
549 def testUpdateCheckout(self):
maruel@chromium.orgea6c2c52009-10-09 20:38:14 +0000550 if not self.enabled:
551 return
msb@chromium.orge28e4982009-09-25 20:51:45 +0000552 options = self.Options(verbose=True)
553 root_dir = tempfile.mkdtemp()
554 relpath = 'foo'
555 base_path = os.path.join(root_dir, relpath)
556 url = os.path.join(self.root_dir, self.relpath, '.git')
557 try:
558 scm = gclient_scm.CreateSCM(url=url, root_dir=root_dir,
559 relpath=relpath)
560 file_list = []
561 scm.update(options, (), file_list)
562 self.assertEquals(len(file_list), 2)
563 self.assert_(os.path.isfile(os.path.join(base_path, 'a')))
msb@chromium.org0f282062009-11-06 20:14:02 +0000564 self.assertEquals(scm.revinfo(options, (), None),
msb@chromium.orge28e4982009-09-25 20:51:45 +0000565 '069c602044c5388d2d15c3f875b057c852003458')
566 finally:
567 shutil.rmtree(root_dir)
568
569 def testUpdateUpdate(self):
maruel@chromium.orgea6c2c52009-10-09 20:38:14 +0000570 if not self.enabled:
571 return
msb@chromium.orge28e4982009-09-25 20:51:45 +0000572 options = self.Options()
573 expected_file_list = [os.path.join(self.base_path, x) for x in ['a', 'b']]
574 scm = gclient_scm.CreateSCM(url=self.url, root_dir=self.root_dir,
575 relpath=self.relpath)
576 file_list = []
577 scm.update(options, (), file_list)
msb@chromium.org0f282062009-11-06 20:14:02 +0000578 self.assertEquals(file_list, expected_file_list)
579 self.assertEquals(scm.revinfo(options, (), None),
msb@chromium.orge28e4982009-09-25 20:51:45 +0000580 'a7142dc9f0009350b96a11f372b6ea658592aa95')
581
msb@chromium.org0f282062009-11-06 20:14:02 +0000582 def testRevinfo(self):
583 if not self.enabled:
584 return
585 options = self.Options()
586 scm = gclient_scm.CreateSCM(url=self.url, root_dir=self.root_dir,
587 relpath=self.relpath)
588 rev_info = scm.revinfo(options, (), None)
589 self.assertEquals(rev_info, '069c602044c5388d2d15c3f875b057c852003458')
590
msb@chromium.orge28e4982009-09-25 20:51:45 +0000591
592class RunSVNTestCase(gclient_test.BaseTestCase):
593 def testRunSVN(self):
594 param2 = 'bleh'
595 self.mox.StubOutWithMock(gclient_utils, 'SubprocessCall')
596 gclient_utils.SubprocessCall(['svn', 'foo', 'bar'], param2).AndReturn(None)
597 self.mox.ReplayAll()
598 gclient_scm.RunSVN(['foo', 'bar'], param2)
599
600
601if __name__ == '__main__':
602 unittest.main()
603
604# vim: ts=2:sw=2:tw=80:et: