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

Side by Side Diff: tests/gclient_scm_test.py

Issue 192323006: Revert of Another attempt: gclient: delete mismatching checkouts (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Created 6 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 | « testing_support/fake_repos.py ('k') | tests/gclient_smoketest.py » ('j') | 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 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 def testGITFakeHttpsUrl(self): 128 def testGITFakeHttpsUrl(self):
129 self.url = 'git+https://foo' 129 self.url = 'git+https://foo'
130 130
131 self.mox.ReplayAll() 131 self.mox.ReplayAll()
132 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, 132 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir,
133 relpath=self.relpath) 133 relpath=self.relpath)
134 self.assertEqual(scm.url, 'https://foo') 134 self.assertEqual(scm.url, 'https://foo')
135 135
136 def testRunCommandException(self): 136 def testRunCommandException(self):
137 options = self.Options(verbose=False) 137 options = self.Options(verbose=False)
138 gclient_scm.os.path.exists(join(self.base_path, '.git')).AndReturn(False)
138 gclient_scm.os.path.exists(join(self.base_path, '.hg')).AndReturn(False) 139 gclient_scm.os.path.exists(join(self.base_path, '.hg')).AndReturn(False)
139 140
140 self.mox.ReplayAll() 141 self.mox.ReplayAll()
141 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, 142 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir,
142 relpath=self.relpath) 143 relpath=self.relpath)
143 exception = "Unsupported argument(s): %s" % ','.join(self.args) 144 exception = "Unsupported argument(s): %s" % ','.join(self.args)
144 self.assertRaisesError(exception, scm.RunCommand, 145 self.assertRaisesError(exception, scm.RunCommand,
145 'update', options, self.args) 146 'update', options, self.args)
146 147
147 def testRunCommandUnknown(self): 148 def testRunCommandUnknown(self):
148 # TODO(maruel): if ever used. 149 # TODO(maruel): if ever used.
149 pass 150 pass
150 151
151 def testRevertMissing(self): 152 def testRevertMissing(self):
152 options = self.Options(verbose=True) 153 options = self.Options(verbose=True)
153 gclient_scm.os.path.isdir(self.base_path).AndReturn(False) 154 gclient_scm.os.path.isdir(self.base_path).AndReturn(False)
154 gclient_scm.os.path.exists(self.base_path).AndReturn(False) 155 gclient_scm.os.path.exists(self.base_path).AndReturn(False)
155 gclient_scm.scm.SVN.Capture(['--version', '--quiet'], None 156 gclient_scm.scm.SVN.Capture(['--version', '--quiet'], None
156 ).AndReturn('1.5.1') 157 ).AndReturn('1.5.1')
157 # It'll to a checkout instead. 158 # It'll to a checkout instead.
159 gclient_scm.os.path.exists(join(self.base_path, '.git')).AndReturn(False)
158 gclient_scm.os.path.exists(join(self.base_path, '.hg')).AndReturn(False) 160 gclient_scm.os.path.exists(join(self.base_path, '.hg')).AndReturn(False)
159 # Checkout. 161 # Checkout.
160 gclient_scm.os.path.exists(self.base_path).AndReturn(False) 162 gclient_scm.os.path.exists(self.base_path).AndReturn(False)
161 parent = gclient_scm.os.path.dirname(self.base_path) 163 parent = gclient_scm.os.path.dirname(self.base_path)
162 gclient_scm.os.path.exists(parent).AndReturn(False) 164 gclient_scm.os.path.exists(parent).AndReturn(False)
163 gclient_scm.os.makedirs(parent) 165 gclient_scm.os.makedirs(parent)
164 gclient_scm.os.path.exists(parent).AndReturn(True) 166 gclient_scm.os.path.exists(parent).AndReturn(True)
165 files_list = self.mox.CreateMockAnything() 167 files_list = self.mox.CreateMockAnything()
166 gclient_scm.scm.SVN.RunAndGetFileList( 168 gclient_scm.scm.SVN.RunAndGetFileList(
167 options.verbose, 169 options.verbose,
(...skipping 11 matching lines...) Expand all
179 self.checkstdout( 181 self.checkstdout(
180 ('\n_____ %s is missing, synching instead\n' % self.relpath)) 182 ('\n_____ %s is missing, synching instead\n' % self.relpath))
181 183
182 def testRevertNoDotSvn(self): 184 def testRevertNoDotSvn(self):
183 options = self.Options(verbose=True, force=True) 185 options = self.Options(verbose=True, force=True)
184 gclient_scm.os.path.isdir(self.base_path).AndReturn(True) 186 gclient_scm.os.path.isdir(self.base_path).AndReturn(True)
185 gclient_scm.os.path.isdir(join(self.base_path, '.svn')).AndReturn(False) 187 gclient_scm.os.path.isdir(join(self.base_path, '.svn')).AndReturn(False)
186 gclient_scm.os.path.isdir(join(self.base_path, '.git')).AndReturn(False) 188 gclient_scm.os.path.isdir(join(self.base_path, '.git')).AndReturn(False)
187 gclient_scm.os.path.isdir(join(self.base_path, '.hg')).AndReturn(False) 189 gclient_scm.os.path.isdir(join(self.base_path, '.hg')).AndReturn(False)
188 # Checkout. 190 # Checkout.
191 gclient_scm.os.path.exists(join(self.base_path, '.git')).AndReturn(False)
189 gclient_scm.os.path.exists(join(self.base_path, '.hg')).AndReturn(False) 192 gclient_scm.os.path.exists(join(self.base_path, '.hg')).AndReturn(False)
190 gclient_scm.os.path.exists(self.base_path).AndReturn(False) 193 gclient_scm.os.path.exists(self.base_path).AndReturn(False)
191 parent = gclient_scm.os.path.dirname(self.base_path) 194 parent = gclient_scm.os.path.dirname(self.base_path)
192 gclient_scm.os.path.exists(parent).AndReturn(False) 195 gclient_scm.os.path.exists(parent).AndReturn(False)
193 gclient_scm.os.makedirs(parent) 196 gclient_scm.os.makedirs(parent)
194 gclient_scm.os.path.exists(parent).AndReturn(True) 197 gclient_scm.os.path.exists(parent).AndReturn(True)
195 files_list = self.mox.CreateMockAnything() 198 files_list = self.mox.CreateMockAnything()
196 gclient_scm.scm.SVN.Capture(['--version', '--quiet'], None 199 gclient_scm.scm.SVN.Capture(['--version', '--quiet'], None
197 ).AndReturn('1.6') 200 ).AndReturn('1.6')
198 gclient_scm.scm.SVN.RunAndGetFileList( 201 gclient_scm.scm.SVN.RunAndGetFileList(
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 307
305 # TODO(maruel): TEST REVISIONS!!! 308 # TODO(maruel): TEST REVISIONS!!!
306 # TODO(maruel): TEST RELOCATE!!! 309 # TODO(maruel): TEST RELOCATE!!!
307 def testUpdateCheckout(self): 310 def testUpdateCheckout(self):
308 options = self.Options(verbose=True) 311 options = self.Options(verbose=True)
309 file_info = gclient_scm.gclient_utils.PrintableObject() 312 file_info = gclient_scm.gclient_utils.PrintableObject()
310 file_info.root = 'blah' 313 file_info.root = 'blah'
311 file_info.url = self.url 314 file_info.url = self.url
312 file_info.uuid = 'ABC' 315 file_info.uuid = 'ABC'
313 file_info.revision = 42 316 file_info.revision = 42
317 gclient_scm.os.path.exists(join(self.base_path, '.git')).AndReturn(False)
314 gclient_scm.os.path.exists(join(self.base_path, '.hg')).AndReturn(False) 318 gclient_scm.os.path.exists(join(self.base_path, '.hg')).AndReturn(False)
315 # Checkout. 319 # Checkout.
316 gclient_scm.os.path.exists(self.base_path).AndReturn(False) 320 gclient_scm.os.path.exists(self.base_path).AndReturn(False)
317 parent = gclient_scm.os.path.dirname(self.base_path) 321 parent = gclient_scm.os.path.dirname(self.base_path)
318 gclient_scm.os.path.exists(parent).AndReturn(False) 322 gclient_scm.os.path.exists(parent).AndReturn(False)
319 gclient_scm.os.makedirs(parent) 323 gclient_scm.os.makedirs(parent)
320 gclient_scm.os.path.exists(parent).AndReturn(True) 324 gclient_scm.os.path.exists(parent).AndReturn(True)
321 files_list = self.mox.CreateMockAnything() 325 files_list = self.mox.CreateMockAnything()
322 gclient_scm.scm.SVN.Capture(['--version', '--quiet'], None 326 gclient_scm.scm.SVN.Capture(['--version', '--quiet'], None
323 ).AndReturn('1.5.1') 327 ).AndReturn('1.5.1')
(...skipping 12 matching lines...) Expand all
336 def testUpdateUpdate(self): 340 def testUpdateUpdate(self):
337 options = self.Options(verbose=True) 341 options = self.Options(verbose=True)
338 options.force = True 342 options.force = True
339 options.nohooks = False 343 options.nohooks = False
340 file_info = { 344 file_info = {
341 'Repository Root': 'blah', 345 'Repository Root': 'blah',
342 'URL': self.url, 346 'URL': self.url,
343 'UUID': 'ABC', 347 'UUID': 'ABC',
344 'Revision': 42, 348 'Revision': 42,
345 } 349 }
350 gclient_scm.os.path.exists(join(self.base_path, '.git')).AndReturn(False)
346 gclient_scm.os.path.exists(join(self.base_path, '.hg')).AndReturn(False) 351 gclient_scm.os.path.exists(join(self.base_path, '.hg')).AndReturn(False)
347 self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'IsGitSvn', True)
348 gclient_scm.scm.GIT.IsGitSvn(self.base_path).AndReturn(False)
349 gclient_scm.os.path.exists(self.base_path).AndReturn(True) 352 gclient_scm.os.path.exists(self.base_path).AndReturn(True)
350 353
351 # Checkout or update. 354 # Checkout or update.
352 dotted_path = join(self.base_path, '.') 355 dotted_path = join(self.base_path, '.')
353 gclient_scm.scm.SVN._CaptureInfo([], dotted_path).AndReturn(file_info) 356 gclient_scm.scm.SVN._CaptureInfo([], dotted_path).AndReturn(file_info)
354 357
355 # Verify no locked files. 358 # Verify no locked files.
356 gclient_scm.scm.SVN.CaptureStatus(None, dotted_path).AndReturn([]) 359 gclient_scm.scm.SVN.CaptureStatus(None, dotted_path).AndReturn([])
357 360
358 # Cheat a bit here. 361 # Cheat a bit here.
(...skipping 24 matching lines...) Expand all
383 386
384 def testUpdateReset(self): 387 def testUpdateReset(self):
385 options = self.Options(verbose=True) 388 options = self.Options(verbose=True)
386 options.reset = True 389 options.reset = True
387 file_info = { 390 file_info = {
388 'Repository Root': 'blah', 391 'Repository Root': 'blah',
389 'URL': self.url, 392 'URL': self.url,
390 'UUID': 'ABC', 393 'UUID': 'ABC',
391 'Revision': 42, 394 'Revision': 42,
392 } 395 }
396 gclient_scm.os.path.exists(join(self.base_path, '.git')).AndReturn(False)
393 gclient_scm.os.path.exists(join(self.base_path, '.hg')).AndReturn(False) 397 gclient_scm.os.path.exists(join(self.base_path, '.hg')).AndReturn(False)
394 self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'IsGitSvn', True)
395 gclient_scm.scm.GIT.IsGitSvn(self.base_path).AndReturn(False)
396 gclient_scm.os.path.exists(self.base_path).AndReturn(True) 398 gclient_scm.os.path.exists(self.base_path).AndReturn(True)
397 399
398 # Checkout or update. 400 # Checkout or update.
399 dotted_path = join(self.base_path, '.') 401 dotted_path = join(self.base_path, '.')
400 gclient_scm.scm.SVN._CaptureInfo([], dotted_path).AndReturn(file_info) 402 gclient_scm.scm.SVN._CaptureInfo([], dotted_path).AndReturn(file_info)
401 403
402 # Create an untracked file and directory. 404 # Create an untracked file and directory.
403 gclient_scm.scm.SVN.CaptureStatus(None, dotted_path 405 gclient_scm.scm.SVN.CaptureStatus(None, dotted_path
404 ).AndReturn([['? ', 'dir'], ['? ', 'file']]) 406 ).AndReturn([['? ', 'dir'], ['? ', 'file']])
405 407
(...skipping 14 matching lines...) Expand all
420 options = self.Options(verbose=True) 422 options = self.Options(verbose=True)
421 options.reset = True 423 options.reset = True
422 options.delete_unversioned_trees = True 424 options.delete_unversioned_trees = True
423 425
424 file_info = { 426 file_info = {
425 'Repository Root': 'blah', 427 'Repository Root': 'blah',
426 'URL': self.url, 428 'URL': self.url,
427 'UUID': 'ABC', 429 'UUID': 'ABC',
428 'Revision': 42, 430 'Revision': 42,
429 } 431 }
432 gclient_scm.os.path.exists(join(self.base_path, '.git')).AndReturn(False)
430 gclient_scm.os.path.exists(join(self.base_path, '.hg')).AndReturn(False) 433 gclient_scm.os.path.exists(join(self.base_path, '.hg')).AndReturn(False)
431 self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'IsGitSvn', True)
432 gclient_scm.scm.GIT.IsGitSvn(self.base_path).AndReturn(False)
433 gclient_scm.os.path.exists(self.base_path).AndReturn(True) 434 gclient_scm.os.path.exists(self.base_path).AndReturn(True)
434 435
435 # Checkout or update. 436 # Checkout or update.
436 dotted_path = join(self.base_path, '.') 437 dotted_path = join(self.base_path, '.')
437 gclient_scm.scm.SVN._CaptureInfo([], dotted_path).AndReturn(file_info) 438 gclient_scm.scm.SVN._CaptureInfo([], dotted_path).AndReturn(file_info)
438 439
439 # Create an untracked file and directory. 440 # Create an untracked file and directory.
440 gclient_scm.scm.SVN.CaptureStatus(None, dotted_path 441 gclient_scm.scm.SVN.CaptureStatus(None, dotted_path
441 ).AndReturn([['? ', 'dir'], ['? ', 'file']]) 442 ).AndReturn([['? ', 'dir'], ['? ', 'file']])
442 443
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
487 ['svn', 'checkout', '--depth', 'empty', self.url, self.base_path], 488 ['svn', 'checkout', '--depth', 'empty', self.url, self.base_path],
488 always=True, 489 always=True,
489 cwd=self.root_dir) 490 cwd=self.root_dir)
490 gclient_scm.scm.SVN.RunAndGetFileList( 491 gclient_scm.scm.SVN.RunAndGetFileList(
491 options.verbose, 492 options.verbose,
492 ['update', 'DEPS', '--ignore-externals'], 493 ['update', 'DEPS', '--ignore-externals'],
493 cwd=self.base_path, 494 cwd=self.base_path,
494 file_list=files_list) 495 file_list=files_list)
495 496
496 # Now we fall back on scm.update(). 497 # Now we fall back on scm.update().
498 gclient_scm.os.path.exists(join(self.base_path, '.git')).AndReturn(False)
497 gclient_scm.os.path.exists(join(self.base_path, '.hg')).AndReturn(False) 499 gclient_scm.os.path.exists(join(self.base_path, '.hg')).AndReturn(False)
498 self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'IsGitSvn', True)
499 gclient_scm.scm.GIT.IsGitSvn(self.base_path).AndReturn(False)
500 gclient_scm.os.path.exists(self.base_path).AndReturn(True) 500 gclient_scm.os.path.exists(self.base_path).AndReturn(True)
501 gclient_scm.scm.SVN._CaptureInfo([], dotted_path).AndReturn(file_info) 501 gclient_scm.scm.SVN._CaptureInfo([], dotted_path).AndReturn(file_info)
502 gclient_scm.scm.SVN._CaptureInfo([file_info['URL']], None 502 gclient_scm.scm.SVN._CaptureInfo([file_info['URL']], None
503 ).AndReturn(file_info) 503 ).AndReturn(file_info)
504 504
505 gclient_scm.scm.SVN._CaptureInfo([], self.base_path+'/.' 505 gclient_scm.scm.SVN._CaptureInfo([], self.base_path+'/.'
506 ).AndReturn({'Revision': 100}) 506 ).AndReturn({'Revision': 100})
507 507
508 self.mox.ReplayAll() 508 self.mox.ReplayAll()
509 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, 509 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir,
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
558 ['svn', 'checkout', '--depth', 'empty', self.url, self.base_path], 558 ['svn', 'checkout', '--depth', 'empty', self.url, self.base_path],
559 always=True, 559 always=True,
560 cwd=self.root_dir) 560 cwd=self.root_dir)
561 gclient_scm.scm.SVN.RunAndGetFileList( 561 gclient_scm.scm.SVN.RunAndGetFileList(
562 options.verbose, 562 options.verbose,
563 ['update', 'DEPS', '--ignore-externals'], 563 ['update', 'DEPS', '--ignore-externals'],
564 cwd=self.base_path, 564 cwd=self.base_path,
565 file_list=files_list) 565 file_list=files_list)
566 566
567 # Now we fall back on scm.update(). 567 # Now we fall back on scm.update().
568 gclient_scm.os.path.exists(join(self.base_path, '.git')).AndReturn(False)
568 gclient_scm.os.path.exists(join(self.base_path, '.hg')).AndReturn(False) 569 gclient_scm.os.path.exists(join(self.base_path, '.hg')).AndReturn(False)
569 self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'IsGitSvn', True)
570 gclient_scm.scm.GIT.IsGitSvn(self.base_path).AndReturn(False)
571 gclient_scm.os.path.exists(self.base_path).AndReturn(True) 570 gclient_scm.os.path.exists(self.base_path).AndReturn(True)
572 gclient_scm.scm.SVN._CaptureInfo( 571 gclient_scm.scm.SVN._CaptureInfo(
573 [], join(self.base_path, ".")).AndReturn(file_info) 572 [], join(self.base_path, ".")).AndReturn(file_info)
574 gclient_scm.scm.SVN._CaptureInfo([file_info['URL']], None 573 gclient_scm.scm.SVN._CaptureInfo([file_info['URL']], None
575 ).AndReturn(file_info) 574 ).AndReturn(file_info)
576 575
577 gclient_scm.scm.SVN._CaptureInfo([], self.base_path+'/.' 576 gclient_scm.scm.SVN._CaptureInfo([], self.base_path+'/.'
578 ).AndReturn({'Revision': 100}) 577 ).AndReturn({'Revision': 100})
579 578
580 self.mox.ReplayAll() 579 self.mox.ReplayAll()
(...skipping 14 matching lines...) Expand all
595 gclient_scm.scm.SVN.Capture(['--version', '--quiet'], None 594 gclient_scm.scm.SVN.Capture(['--version', '--quiet'], None
596 ).AndReturn('1.5.1') 595 ).AndReturn('1.5.1')
597 gclient_scm.os.path.exists(join(self.base_path, '.svn')).AndReturn(True) 596 gclient_scm.os.path.exists(join(self.base_path, '.svn')).AndReturn(True)
598 597
599 # Verify no locked files. 598 # Verify no locked files.
600 gclient_scm.scm.SVN.CaptureStatus(None, join(self.base_path, '.') 599 gclient_scm.scm.SVN.CaptureStatus(None, join(self.base_path, '.')
601 ).AndReturn([]) 600 ).AndReturn([])
602 601
603 # Now we fall back on scm.update(). 602 # Now we fall back on scm.update().
604 files_list = self.mox.CreateMockAnything() 603 files_list = self.mox.CreateMockAnything()
604 gclient_scm.os.path.exists(join(self.base_path, '.git')).AndReturn(False)
605 gclient_scm.os.path.exists(join(self.base_path, '.hg')).AndReturn(False) 605 gclient_scm.os.path.exists(join(self.base_path, '.hg')).AndReturn(False)
606 self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'IsGitSvn', True)
607 gclient_scm.scm.GIT.IsGitSvn(self.base_path).AndReturn(False)
608 gclient_scm.os.path.exists(self.base_path).AndReturn(True) 606 gclient_scm.os.path.exists(self.base_path).AndReturn(True)
609 gclient_scm.scm.SVN._CaptureInfo( 607 gclient_scm.scm.SVN._CaptureInfo(
610 [], join(self.base_path, '.')).AndReturn(file_info) 608 [], join(self.base_path, '.')).AndReturn(file_info)
611 gclient_scm.scm.SVN._CaptureInfo([file_info['URL']], None 609 gclient_scm.scm.SVN._CaptureInfo([file_info['URL']], None
612 ).AndReturn(file_info) 610 ).AndReturn(file_info)
613 611
614 gclient_scm.scm.SVN._CaptureInfo([], self.base_path+'/.' 612 gclient_scm.scm.SVN._CaptureInfo([], self.base_path+'/.'
615 ).AndReturn({'Revision': 100}) 613 ).AndReturn({'Revision': 100})
616 614
617 self.mox.ReplayAll() 615 self.mox.ReplayAll()
618 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, 616 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir,
619 relpath=self.relpath) 617 relpath=self.relpath)
620 scm.updatesingle(options, ['DEPS'], files_list) 618 scm.updatesingle(options, ['DEPS'], files_list)
621 self.checkstdout('\n_____ %s at 42\n' % self.relpath) 619 self.checkstdout('\n_____ %s at 42\n' % self.relpath)
622 620
623 def testUpdateGit(self): 621 def testUpdateGit(self):
624 options = self.Options(verbose=True) 622 options = self.Options(verbose=True)
625 file_path = gclient_scm.os.path.join(self.root_dir, self.relpath, '.hg') 623 file_path = gclient_scm.os.path.join(self.root_dir, self.relpath, '.git')
626 gclient_scm.os.path.exists(file_path).AndReturn(False) 624 gclient_scm.os.path.exists(file_path).AndReturn(True)
627 gclient_scm.os.path.exists(self.base_path).AndReturn(True)
628 self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'IsGitSvn', True)
629 gclient_scm.scm.GIT.IsGitSvn(self.base_path).AndReturn(False)
630 error = gclient_scm.subprocess2.CalledProcessError(
631 1, 'cmd', '/cwd', 'stdout', 'stderr')
632 gclient_scm.scm.SVN._CaptureInfo([], self.base_path+'/.').AndRaise(error)
633
634 self.mox.ReplayAll()
635 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir,
636 relpath=self.relpath)
637 error = ('Can\'t update/checkout %s if an unversioned directory is '
638 'present. Delete the directory and try again.' % self.base_path)
639 self.assertRaisesError(error, scm.update, options, None, [])
640
641 def testUpdateGitForce(self):
642 options = self.Options(verbose=True, force=True)
643 file_path = gclient_scm.os.path.join(self.root_dir, self.relpath, '.hg')
644 gclient_scm.os.path.exists(file_path).AndReturn(False)
645 gclient_scm.os.path.exists(self.base_path).AndReturn(True)
646 self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'IsGitSvn', True)
647 gclient_scm.scm.GIT.IsGitSvn(self.base_path).AndReturn(False)
648 error = gclient_scm.subprocess2.CalledProcessError(
649 1, 'cmd', '/cwd', 'stdout', 'stderr')
650 gclient_scm.scm.SVN._CaptureInfo([], self.base_path+'/.').AndRaise(error)
651 gclient_scm.gclient_utils.rmtree(self.base_path)
652 gclient_scm.os.path.exists(self.root_dir).AndReturn(True)
653 gclient_scm.scm.SVN.Capture(['--version', '--quiet'], None
654 ).AndReturn('1.5.1')
655 gclient_scm.scm.SVN.RunAndGetFileList(
656 options.verbose,
657 ['checkout', self.url, self.base_path, '--force', '--ignore-externals'],
658 cwd=self.root_dir,
659 file_list=[])
660
661 gclient_scm.scm.SVN._CaptureInfo([], self.base_path+'/.'
662 ).AndReturn({'Revision': 100})
663 625
664 self.mox.ReplayAll() 626 self.mox.ReplayAll()
665 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, 627 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir,
666 relpath=self.relpath) 628 relpath=self.relpath)
667 file_list = [] 629 file_list = []
668 scm.update(options, None, file_list) 630 scm.update(options, self.args, file_list)
669 self.checkstdout('Removing troublesome path %s\n' % self.base_path)
670
671 def testUpdateGitSvn(self):
672 options = self.Options(verbose=True)
673 file_path = gclient_scm.os.path.join(self.root_dir, self.relpath, '.hg')
674 gclient_scm.os.path.exists(file_path).AndReturn(False)
675 gclient_scm.os.path.exists(self.base_path).AndReturn(True)
676 self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'IsGitSvn', True)
677 gclient_scm.scm.GIT.IsGitSvn(self.base_path).AndReturn(True)
678 self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'Capture', True)
679 gclient_scm.scm.GIT.Capture(['config', '--local', '--get',
680 'svn-remote.svn.url'],
681 cwd=self.base_path).AndReturn(self.url)
682
683 self.mox.ReplayAll()
684 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir,
685 relpath=self.relpath)
686 file_list = []
687 scm.update(options, [], file_list)
688 self.checkstdout( 631 self.checkstdout(
689 ('\n_____ %s looks like a git-svn checkout. Skipping.\n' % self.relpath) 632 ('________ found .git directory; skipping %s\n' % self.relpath))
690 )
691 633
692 def testUpdateHg(self): 634 def testUpdateHg(self):
693 options = self.Options(verbose=True) 635 options = self.Options(verbose=True)
636 gclient_scm.os.path.exists(join(self.base_path, '.git')).AndReturn(False)
694 gclient_scm.os.path.exists(join(self.base_path, '.hg')).AndReturn(True) 637 gclient_scm.os.path.exists(join(self.base_path, '.hg')).AndReturn(True)
695 638
696 self.mox.ReplayAll() 639 self.mox.ReplayAll()
697 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, 640 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir,
698 relpath=self.relpath) 641 relpath=self.relpath)
699 file_list = [] 642 file_list = []
700 scm.update(options, self.args, file_list) 643 scm.update(options, self.args, file_list)
701 self.checkstdout( 644 self.checkstdout(
702 ('________ found .hg directory; skipping %s\n' % self.relpath)) 645 ('________ found .hg directory; skipping %s\n' % self.relpath))
703 646
(...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after
1248 self.assertEquals(git_svn_scm.GetUsableRev('3', options), 1191 self.assertEquals(git_svn_scm.GetUsableRev('3', options),
1249 self.fake_hash_2) 1192 self.fake_hash_2)
1250 # Given a git sha1 with a git-svn checkout, it should be used as is. 1193 # Given a git sha1 with a git-svn checkout, it should be used as is.
1251 self.assertEquals(git_svn_scm.GetUsableRev(self.fake_hash_1, options), 1194 self.assertEquals(git_svn_scm.GetUsableRev(self.fake_hash_1, options),
1252 self.fake_hash_1) 1195 self.fake_hash_1)
1253 # We currently check for seemingly valid SVN revisions by assuming 6 digit 1196 # We currently check for seemingly valid SVN revisions by assuming 6 digit
1254 # numbers, so assure that numeric revs >= 1000000 don't work. 1197 # numbers, so assure that numeric revs >= 1000000 don't work.
1255 self.assertRaises(gclient_scm.gclient_utils.Error, 1198 self.assertRaises(gclient_scm.gclient_utils.Error,
1256 git_svn_scm.GetUsableRev, too_big, options) 1199 git_svn_scm.GetUsableRev, too_big, options)
1257 1200
1258 def testUpdateNoDotGit(self):
1259 options = self.Options()
1260
1261 gclient_scm.os.path.exists(self.base_path).AndReturn(True)
1262 gclient_scm.os.path.isdir(self.base_path).AndReturn(True)
1263 gclient_scm.os.path.exists(os.path.join(self.base_path, '.git')
1264 ).AndReturn(False)
1265 gclient_scm.os.path.isdir(self.base_path).AndReturn(True)
1266 gclient_scm.os.path.exists(os.path.join(self.base_path, '.git')
1267 ).AndReturn(False)
1268
1269 self.mox.ReplayAll()
1270 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir,
1271 relpath=self.relpath)
1272 error = ('\n____ %s at refs/remotes/origin/master\n\tPath is not a git '
1273 'repo. No .git dir.\n\tTo resolve:\n\t\trm -rf %s\n\tAnd run '
1274 'gclient sync again\n\tOr run with --force\n' % (self.relpath,
1275 self.relpath))
1276 self.assertRaisesError(error, scm.update, options, None, [])
1277
1278 def testUpdateNoDotGitForce(self):
1279 options = self.Options(force=True)
1280
1281 gclient_scm.os.path.exists(self.base_path).AndReturn(True)
1282 gclient_scm.os.path.isdir(self.base_path).AndReturn(True)
1283 gclient_scm.os.path.exists(os.path.join(self.base_path, '.git')
1284 ).AndReturn(False)
1285 gclient_scm.os.path.isdir(self.base_path).AndReturn(True)
1286 gclient_scm.os.path.exists(os.path.join(self.base_path, '.git')
1287 ).AndReturn(False)
1288 gclient_scm.gclient_utils.rmtree(self.base_path)
1289 self.mox.StubOutWithMock(gclient_scm.GitWrapper, '_Clone', True)
1290 # pylint: disable=E1120
1291 gclient_scm.GitWrapper._Clone('refs/remotes/origin/master', self.url,
1292 options)
1293 # pylint: disable=E1120
1294 self.mox.StubOutWithMock(gclient_scm.GitWrapper, 'UpdateSubmoduleConfig',
1295 True)
1296 gclient_scm.GitWrapper.UpdateSubmoduleConfig()
1297 self.mox.StubOutWithMock(gclient_scm.subprocess2, 'check_output', True)
1298 gclient_scm.subprocess2.check_output(['git', 'ls-files'],
1299 cwd=self.base_path,
1300 stderr=gclient_scm.subprocess2.VOID,
1301 ).AndReturn('')
1302 gclient_scm.subprocess2.check_output(
1303 ['git', 'rev-parse', '--verify', 'HEAD'],
1304 cwd=self.base_path,
1305 stderr=gclient_scm.subprocess2.VOID,
1306 ).AndReturn('')
1307
1308 self.mox.ReplayAll()
1309 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir,
1310 relpath=self.relpath)
1311 scm.update(options, None, [])
1312 self.checkstdout('_____ Conflicting directory found in %s. Removing.\n\n'
1313 % self.base_path)
1314
1315 1201
1316 class UnmanagedGitWrapperTestCase(BaseGitWrapperTestCase): 1202 class UnmanagedGitWrapperTestCase(BaseGitWrapperTestCase):
1317 def testUpdateUpdate(self): 1203 def testUpdateUpdate(self):
1318 if not self.enabled: 1204 if not self.enabled:
1319 return 1205 return
1320 options = self.Options() 1206 options = self.Options()
1321 expected_file_list = [] 1207 expected_file_list = []
1322 scm = gclient_scm.CreateSCM(url=self.url, root_dir=self.root_dir, 1208 scm = gclient_scm.CreateSCM(url=self.url, root_dir=self.root_dir,
1323 relpath=self.relpath) 1209 relpath=self.relpath)
1324 file_list = [] 1210 file_list = []
1325 options.revision = 'unmanaged' 1211 options.revision = 'unmanaged'
1326 scm.update(options, (), file_list) 1212 scm.update(options, (), file_list)
1327 self.assertEquals(file_list, expected_file_list) 1213 self.assertEquals(file_list, expected_file_list)
1328 self.assertEquals(scm.revinfo(options, (), None), 1214 self.assertEquals(scm.revinfo(options, (), None),
1329 '069c602044c5388d2d15c3f875b057c852003458') 1215 '069c602044c5388d2d15c3f875b057c852003458')
1330 self.checkstdout('________ unmanaged solution; skipping .\n') 1216 self.checkstdout('________ unmanaged solution; skipping .\n')
1331 1217
1332 1218
1333 if __name__ == '__main__': 1219 if __name__ == '__main__':
1334 if '-v' in sys.argv: 1220 if '-v' in sys.argv:
1335 logging.basicConfig( 1221 logging.basicConfig(
1336 level=logging.DEBUG, 1222 level=logging.DEBUG,
1337 format='%(asctime).19s %(levelname)s %(filename)s:' 1223 format='%(asctime).19s %(levelname)s %(filename)s:'
1338 '%(lineno)s %(message)s') 1224 '%(lineno)s %(message)s')
1339 unittest.main() 1225 unittest.main()
1340 1226
1341 # vim: ts=2:sw=2:tw=80:et: 1227 # vim: ts=2:sw=2:tw=80:et:
OLDNEW
« no previous file with comments | « testing_support/fake_repos.py ('k') | tests/gclient_smoketest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698