OLD | NEW |
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 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 def testGITFakeHttpsUrl(self): | 154 def testGITFakeHttpsUrl(self): |
155 self.url = 'git+https://foo' | 155 self.url = 'git+https://foo' |
156 | 156 |
157 self.mox.ReplayAll() | 157 self.mox.ReplayAll() |
158 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, | 158 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, |
159 relpath=self.relpath) | 159 relpath=self.relpath) |
160 self.assertEqual(scm.url, 'https://foo') | 160 self.assertEqual(scm.url, 'https://foo') |
161 | 161 |
162 def testRunCommandException(self): | 162 def testRunCommandException(self): |
163 options = self.Options(verbose=False) | 163 options = self.Options(verbose=False) |
164 gclient_scm.os.path.exists(join(self.base_path, '.git')).AndReturn(False) | |
165 gclient_scm.os.path.exists(join(self.base_path, '.hg')).AndReturn(False) | |
166 | 164 |
167 self.mox.ReplayAll() | 165 self.mox.ReplayAll() |
168 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, | 166 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, |
169 relpath=self.relpath) | 167 relpath=self.relpath) |
170 exception = "Unsupported argument(s): %s" % ','.join(self.args) | 168 exception = "Unsupported argument(s): %s" % ','.join(self.args) |
171 self.assertRaisesError(exception, scm.RunCommand, | 169 self.assertRaisesError(exception, scm.RunCommand, |
172 'update', options, self.args) | 170 'update', options, self.args) |
173 | 171 |
174 def testRunCommandUnknown(self): | 172 def testRunCommandUnknown(self): |
175 # TODO(maruel): if ever used. | 173 # TODO(maruel): if ever used. |
176 pass | 174 pass |
177 | 175 |
178 def testRevertMissing(self): | 176 def testRevertMissing(self): |
179 options = self.Options(verbose=True) | 177 options = self.Options(verbose=True) |
180 gclient_scm.os.path.isdir(self.base_path).AndReturn(False) | 178 gclient_scm.os.path.isdir(self.base_path).AndReturn(False) |
181 gclient_scm.os.path.exists(self.base_path).AndReturn(False) | 179 gclient_scm.os.path.exists(self.base_path).AndReturn(False) |
182 gclient_scm.scm.SVN.Capture(['--version', '--quiet'], None | 180 gclient_scm.scm.SVN.Capture(['--version', '--quiet'], None |
183 ).AndReturn('1.5.1') | 181 ).AndReturn('1.5.1') |
184 # It'll to a checkout instead. | 182 # It'll to a checkout instead. |
185 gclient_scm.os.path.exists(join(self.base_path, '.git')).AndReturn(False) | |
186 gclient_scm.os.path.exists(join(self.base_path, '.hg')).AndReturn(False) | |
187 # Checkout. | 183 # Checkout. |
188 gclient_scm.os.path.exists(self.base_path).AndReturn(False) | 184 gclient_scm.os.path.exists(self.base_path).AndReturn(False) |
189 parent = gclient_scm.os.path.dirname(self.base_path) | 185 parent = gclient_scm.os.path.dirname(self.base_path) |
190 gclient_scm.os.path.exists(parent).AndReturn(False) | 186 gclient_scm.os.path.exists(parent).AndReturn(False) |
191 gclient_scm.os.makedirs(parent) | 187 gclient_scm.os.makedirs(parent) |
192 gclient_scm.os.path.exists(parent).AndReturn(True) | 188 gclient_scm.os.path.exists(parent).AndReturn(True) |
193 files_list = self.mox.CreateMockAnything() | 189 files_list = self.mox.CreateMockAnything() |
194 gclient_scm.scm.SVN.RunAndGetFileList( | 190 gclient_scm.scm.SVN.RunAndGetFileList( |
195 options.verbose, | 191 options.verbose, |
196 ['checkout', self.url, self.base_path, '--force', '--ignore-externals'], | 192 ['checkout', self.url, self.base_path, '--force', '--ignore-externals'], |
197 cwd=self.root_dir, | 193 cwd=self.root_dir, |
198 file_list=files_list) | 194 file_list=files_list) |
199 | 195 |
200 gclient_scm.scm.SVN._CaptureInfo([], self.base_path+'/.' | 196 gclient_scm.scm.SVN._CaptureInfo([], self.base_path+'/.' |
201 ).AndReturn({'Revision': 100}) | 197 ).AndReturn({'Revision': 100}) |
202 | 198 |
203 self.mox.ReplayAll() | 199 self.mox.ReplayAll() |
204 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, | 200 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, |
205 relpath=self.relpath) | 201 relpath=self.relpath) |
206 scm.revert(options, self.args, files_list) | 202 scm.revert(options, self.args, files_list) |
207 self.checkstdout( | 203 self.checkstdout( |
208 ('\n_____ %s is missing, synching instead\n' % self.relpath)) | 204 ('\n_____ %s is missing, synching instead\n' % self.relpath)) |
209 | 205 |
210 def testRevertNoDotSvn(self): | 206 def testRevertNoDotSvn(self): |
211 options = self.Options(verbose=True, force=True) | 207 options = self.Options(verbose=True, force=True) |
212 gclient_scm.os.path.isdir(self.base_path).AndReturn(True) | 208 gclient_scm.os.path.isdir(self.base_path).AndReturn(True) |
213 gclient_scm.os.path.isdir(join(self.base_path, '.svn')).AndReturn(False) | 209 gclient_scm.os.path.isdir(join(self.base_path, '.svn')).AndReturn(False) |
214 gclient_scm.os.path.isdir(join(self.base_path, '.git')).AndReturn(False) | 210 gclient_scm.os.path.isdir(join(self.base_path, '.git')).AndReturn(False) |
215 gclient_scm.os.path.isdir(join(self.base_path, '.hg')).AndReturn(False) | |
216 # Checkout. | 211 # Checkout. |
217 gclient_scm.os.path.exists(join(self.base_path, '.git')).AndReturn(False) | |
218 gclient_scm.os.path.exists(join(self.base_path, '.hg')).AndReturn(False) | |
219 gclient_scm.os.path.exists(self.base_path).AndReturn(False) | 212 gclient_scm.os.path.exists(self.base_path).AndReturn(False) |
220 parent = gclient_scm.os.path.dirname(self.base_path) | 213 parent = gclient_scm.os.path.dirname(self.base_path) |
221 gclient_scm.os.path.exists(parent).AndReturn(False) | 214 gclient_scm.os.path.exists(parent).AndReturn(False) |
222 gclient_scm.os.makedirs(parent) | 215 gclient_scm.os.makedirs(parent) |
223 gclient_scm.os.path.exists(parent).AndReturn(True) | 216 gclient_scm.os.path.exists(parent).AndReturn(True) |
224 files_list = self.mox.CreateMockAnything() | 217 files_list = self.mox.CreateMockAnything() |
225 gclient_scm.scm.SVN.Capture(['--version', '--quiet'], None | 218 gclient_scm.scm.SVN.Capture(['--version', '--quiet'], None |
226 ).AndReturn('1.6') | 219 ).AndReturn('1.6') |
227 gclient_scm.scm.SVN.RunAndGetFileList( | 220 gclient_scm.scm.SVN.RunAndGetFileList( |
228 options.verbose, | 221 options.verbose, |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
333 | 326 |
334 # TODO(maruel): TEST REVISIONS!!! | 327 # TODO(maruel): TEST REVISIONS!!! |
335 # TODO(maruel): TEST RELOCATE!!! | 328 # TODO(maruel): TEST RELOCATE!!! |
336 def testUpdateCheckout(self): | 329 def testUpdateCheckout(self): |
337 options = self.Options(verbose=True) | 330 options = self.Options(verbose=True) |
338 file_info = gclient_scm.gclient_utils.PrintableObject() | 331 file_info = gclient_scm.gclient_utils.PrintableObject() |
339 file_info.root = 'blah' | 332 file_info.root = 'blah' |
340 file_info.url = self.url | 333 file_info.url = self.url |
341 file_info.uuid = 'ABC' | 334 file_info.uuid = 'ABC' |
342 file_info.revision = 42 | 335 file_info.revision = 42 |
343 gclient_scm.os.path.exists(join(self.base_path, '.git')).AndReturn(False) | |
344 gclient_scm.os.path.exists(join(self.base_path, '.hg')).AndReturn(False) | |
345 # Checkout. | 336 # Checkout. |
346 gclient_scm.os.path.exists(self.base_path).AndReturn(False) | 337 gclient_scm.os.path.exists(self.base_path).AndReturn(False) |
347 parent = gclient_scm.os.path.dirname(self.base_path) | 338 parent = gclient_scm.os.path.dirname(self.base_path) |
348 gclient_scm.os.path.exists(parent).AndReturn(False) | 339 gclient_scm.os.path.exists(parent).AndReturn(False) |
349 gclient_scm.os.makedirs(parent) | 340 gclient_scm.os.makedirs(parent) |
350 gclient_scm.os.path.exists(parent).AndReturn(True) | 341 gclient_scm.os.path.exists(parent).AndReturn(True) |
351 files_list = self.mox.CreateMockAnything() | 342 files_list = self.mox.CreateMockAnything() |
352 gclient_scm.scm.SVN.Capture(['--version', '--quiet'], None | 343 gclient_scm.scm.SVN.Capture(['--version', '--quiet'], None |
353 ).AndReturn('1.5.1') | 344 ).AndReturn('1.5.1') |
354 gclient_scm.scm.SVN.RunAndGetFileList( | 345 gclient_scm.scm.SVN.RunAndGetFileList( |
(...skipping 11 matching lines...) Expand all Loading... |
366 def testUpdateUpdate(self): | 357 def testUpdateUpdate(self): |
367 options = self.Options(verbose=True) | 358 options = self.Options(verbose=True) |
368 options.force = True | 359 options.force = True |
369 options.nohooks = False | 360 options.nohooks = False |
370 file_info = { | 361 file_info = { |
371 'Repository Root': 'blah', | 362 'Repository Root': 'blah', |
372 'URL': self.url, | 363 'URL': self.url, |
373 'UUID': 'ABC', | 364 'UUID': 'ABC', |
374 'Revision': 42, | 365 'Revision': 42, |
375 } | 366 } |
376 gclient_scm.os.path.exists(join(self.base_path, '.git')).AndReturn(False) | 367 self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'IsGitSvn', True) |
377 gclient_scm.os.path.exists(join(self.base_path, '.hg')).AndReturn(False) | 368 gclient_scm.scm.GIT.IsGitSvn(self.base_path).AndReturn(False) |
378 gclient_scm.os.path.exists(self.base_path).AndReturn(True) | 369 gclient_scm.os.path.exists(self.base_path).AndReturn(True) |
379 | 370 |
380 # Checkout or update. | 371 # Checkout or update. |
381 dotted_path = join(self.base_path, '.') | 372 dotted_path = join(self.base_path, '.') |
382 gclient_scm.scm.SVN._CaptureInfo([], dotted_path).AndReturn(file_info) | 373 gclient_scm.scm.SVN._CaptureInfo([], dotted_path).AndReturn(file_info) |
383 | 374 |
384 # Verify no locked files. | 375 # Verify no locked files. |
385 gclient_scm.scm.SVN.CaptureStatus(None, dotted_path).AndReturn([]) | 376 gclient_scm.scm.SVN.CaptureStatus(None, dotted_path).AndReturn([]) |
386 | 377 |
387 # Cheat a bit here. | 378 # Cheat a bit here. |
(...skipping 24 matching lines...) Expand all Loading... |
412 | 403 |
413 def testUpdateReset(self): | 404 def testUpdateReset(self): |
414 options = self.Options(verbose=True) | 405 options = self.Options(verbose=True) |
415 options.reset = True | 406 options.reset = True |
416 file_info = { | 407 file_info = { |
417 'Repository Root': 'blah', | 408 'Repository Root': 'blah', |
418 'URL': self.url, | 409 'URL': self.url, |
419 'UUID': 'ABC', | 410 'UUID': 'ABC', |
420 'Revision': 42, | 411 'Revision': 42, |
421 } | 412 } |
422 gclient_scm.os.path.exists(join(self.base_path, '.git')).AndReturn(False) | 413 self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'IsGitSvn', True) |
423 gclient_scm.os.path.exists(join(self.base_path, '.hg')).AndReturn(False) | 414 gclient_scm.scm.GIT.IsGitSvn(self.base_path).AndReturn(False) |
424 gclient_scm.os.path.exists(self.base_path).AndReturn(True) | 415 gclient_scm.os.path.exists(self.base_path).AndReturn(True) |
425 | 416 |
426 # Checkout or update. | 417 # Checkout or update. |
427 dotted_path = join(self.base_path, '.') | 418 dotted_path = join(self.base_path, '.') |
428 gclient_scm.scm.SVN._CaptureInfo([], dotted_path).AndReturn(file_info) | 419 gclient_scm.scm.SVN._CaptureInfo([], dotted_path).AndReturn(file_info) |
429 | 420 |
430 # Create an untracked file and directory. | 421 # Create an untracked file and directory. |
431 gclient_scm.scm.SVN.CaptureStatus(None, dotted_path | 422 gclient_scm.scm.SVN.CaptureStatus(None, dotted_path |
432 ).AndReturn([['? ', 'dir'], ['? ', 'file']]) | 423 ).AndReturn([['? ', 'dir'], ['? ', 'file']]) |
433 | 424 |
(...skipping 14 matching lines...) Expand all Loading... |
448 options = self.Options(verbose=True) | 439 options = self.Options(verbose=True) |
449 options.reset = True | 440 options.reset = True |
450 options.delete_unversioned_trees = True | 441 options.delete_unversioned_trees = True |
451 | 442 |
452 file_info = { | 443 file_info = { |
453 'Repository Root': 'blah', | 444 'Repository Root': 'blah', |
454 'URL': self.url, | 445 'URL': self.url, |
455 'UUID': 'ABC', | 446 'UUID': 'ABC', |
456 'Revision': 42, | 447 'Revision': 42, |
457 } | 448 } |
458 gclient_scm.os.path.exists(join(self.base_path, '.git')).AndReturn(False) | 449 self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'IsGitSvn', True) |
459 gclient_scm.os.path.exists(join(self.base_path, '.hg')).AndReturn(False) | 450 gclient_scm.scm.GIT.IsGitSvn(self.base_path).AndReturn(False) |
460 gclient_scm.os.path.exists(self.base_path).AndReturn(True) | 451 gclient_scm.os.path.exists(self.base_path).AndReturn(True) |
461 | 452 |
462 # Checkout or update. | 453 # Checkout or update. |
463 dotted_path = join(self.base_path, '.') | 454 dotted_path = join(self.base_path, '.') |
464 gclient_scm.scm.SVN._CaptureInfo([], dotted_path).AndReturn(file_info) | 455 gclient_scm.scm.SVN._CaptureInfo([], dotted_path).AndReturn(file_info) |
465 | 456 |
466 # Create an untracked file and directory. | 457 # Create an untracked file and directory. |
467 gclient_scm.scm.SVN.CaptureStatus(None, dotted_path | 458 gclient_scm.scm.SVN.CaptureStatus(None, dotted_path |
468 ).AndReturn([['? ', 'dir'], ['? ', 'file']]) | 459 ).AndReturn([['? ', 'dir'], ['? ', 'file']]) |
469 | 460 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
514 ['svn', 'checkout', '--depth', 'empty', self.url, self.base_path], | 505 ['svn', 'checkout', '--depth', 'empty', self.url, self.base_path], |
515 always=True, | 506 always=True, |
516 cwd=self.root_dir) | 507 cwd=self.root_dir) |
517 gclient_scm.scm.SVN.RunAndGetFileList( | 508 gclient_scm.scm.SVN.RunAndGetFileList( |
518 options.verbose, | 509 options.verbose, |
519 ['update', 'DEPS', '--ignore-externals'], | 510 ['update', 'DEPS', '--ignore-externals'], |
520 cwd=self.base_path, | 511 cwd=self.base_path, |
521 file_list=files_list) | 512 file_list=files_list) |
522 | 513 |
523 # Now we fall back on scm.update(). | 514 # Now we fall back on scm.update(). |
524 gclient_scm.os.path.exists(join(self.base_path, '.git')).AndReturn(False) | 515 self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'IsGitSvn', True) |
525 gclient_scm.os.path.exists(join(self.base_path, '.hg')).AndReturn(False) | 516 gclient_scm.scm.GIT.IsGitSvn(self.base_path).AndReturn(False) |
526 gclient_scm.os.path.exists(self.base_path).AndReturn(True) | 517 gclient_scm.os.path.exists(self.base_path).AndReturn(True) |
527 gclient_scm.scm.SVN._CaptureInfo([], dotted_path).AndReturn(file_info) | 518 gclient_scm.scm.SVN._CaptureInfo([], dotted_path).AndReturn(file_info) |
528 gclient_scm.scm.SVN._CaptureInfo([file_info['URL']], None | 519 gclient_scm.scm.SVN._CaptureInfo([file_info['URL']], None |
529 ).AndReturn(file_info) | 520 ).AndReturn(file_info) |
530 | 521 |
531 gclient_scm.scm.SVN._CaptureInfo([], self.base_path+'/.' | 522 gclient_scm.scm.SVN._CaptureInfo([], self.base_path+'/.' |
532 ).AndReturn({'Revision': 100}) | 523 ).AndReturn({'Revision': 100}) |
533 | 524 |
534 self.mox.ReplayAll() | 525 self.mox.ReplayAll() |
535 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, | 526 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
584 ['svn', 'checkout', '--depth', 'empty', self.url, self.base_path], | 575 ['svn', 'checkout', '--depth', 'empty', self.url, self.base_path], |
585 always=True, | 576 always=True, |
586 cwd=self.root_dir) | 577 cwd=self.root_dir) |
587 gclient_scm.scm.SVN.RunAndGetFileList( | 578 gclient_scm.scm.SVN.RunAndGetFileList( |
588 options.verbose, | 579 options.verbose, |
589 ['update', 'DEPS', '--ignore-externals'], | 580 ['update', 'DEPS', '--ignore-externals'], |
590 cwd=self.base_path, | 581 cwd=self.base_path, |
591 file_list=files_list) | 582 file_list=files_list) |
592 | 583 |
593 # Now we fall back on scm.update(). | 584 # Now we fall back on scm.update(). |
594 gclient_scm.os.path.exists(join(self.base_path, '.git')).AndReturn(False) | 585 self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'IsGitSvn', True) |
595 gclient_scm.os.path.exists(join(self.base_path, '.hg')).AndReturn(False) | 586 gclient_scm.scm.GIT.IsGitSvn(self.base_path).AndReturn(False) |
596 gclient_scm.os.path.exists(self.base_path).AndReturn(True) | 587 gclient_scm.os.path.exists(self.base_path).AndReturn(True) |
597 gclient_scm.scm.SVN._CaptureInfo( | 588 gclient_scm.scm.SVN._CaptureInfo( |
598 [], join(self.base_path, ".")).AndReturn(file_info) | 589 [], join(self.base_path, ".")).AndReturn(file_info) |
599 gclient_scm.scm.SVN._CaptureInfo([file_info['URL']], None | 590 gclient_scm.scm.SVN._CaptureInfo([file_info['URL']], None |
600 ).AndReturn(file_info) | 591 ).AndReturn(file_info) |
601 | 592 |
602 gclient_scm.scm.SVN._CaptureInfo([], self.base_path+'/.' | 593 gclient_scm.scm.SVN._CaptureInfo([], self.base_path+'/.' |
603 ).AndReturn({'Revision': 100}) | 594 ).AndReturn({'Revision': 100}) |
604 | 595 |
605 self.mox.ReplayAll() | 596 self.mox.ReplayAll() |
(...skipping 14 matching lines...) Expand all Loading... |
620 gclient_scm.scm.SVN.Capture(['--version', '--quiet'], None | 611 gclient_scm.scm.SVN.Capture(['--version', '--quiet'], None |
621 ).AndReturn('1.5.1') | 612 ).AndReturn('1.5.1') |
622 gclient_scm.os.path.exists(join(self.base_path, '.svn')).AndReturn(True) | 613 gclient_scm.os.path.exists(join(self.base_path, '.svn')).AndReturn(True) |
623 | 614 |
624 # Verify no locked files. | 615 # Verify no locked files. |
625 gclient_scm.scm.SVN.CaptureStatus(None, join(self.base_path, '.') | 616 gclient_scm.scm.SVN.CaptureStatus(None, join(self.base_path, '.') |
626 ).AndReturn([]) | 617 ).AndReturn([]) |
627 | 618 |
628 # Now we fall back on scm.update(). | 619 # Now we fall back on scm.update(). |
629 files_list = self.mox.CreateMockAnything() | 620 files_list = self.mox.CreateMockAnything() |
630 gclient_scm.os.path.exists(join(self.base_path, '.git')).AndReturn(False) | 621 self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'IsGitSvn', True) |
631 gclient_scm.os.path.exists(join(self.base_path, '.hg')).AndReturn(False) | 622 gclient_scm.scm.GIT.IsGitSvn(self.base_path).AndReturn(False) |
632 gclient_scm.os.path.exists(self.base_path).AndReturn(True) | 623 gclient_scm.os.path.exists(self.base_path).AndReturn(True) |
633 gclient_scm.scm.SVN._CaptureInfo( | 624 gclient_scm.scm.SVN._CaptureInfo( |
634 [], join(self.base_path, '.')).AndReturn(file_info) | 625 [], join(self.base_path, '.')).AndReturn(file_info) |
635 gclient_scm.scm.SVN._CaptureInfo([file_info['URL']], None | 626 gclient_scm.scm.SVN._CaptureInfo([file_info['URL']], None |
636 ).AndReturn(file_info) | 627 ).AndReturn(file_info) |
637 | 628 |
638 gclient_scm.scm.SVN._CaptureInfo([], self.base_path+'/.' | 629 gclient_scm.scm.SVN._CaptureInfo([], self.base_path+'/.' |
639 ).AndReturn({'Revision': 100}) | 630 ).AndReturn({'Revision': 100}) |
640 | 631 |
641 self.mox.ReplayAll() | 632 self.mox.ReplayAll() |
642 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, | 633 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, |
643 relpath=self.relpath) | 634 relpath=self.relpath) |
644 scm.updatesingle(options, ['DEPS'], files_list) | 635 scm.updatesingle(options, ['DEPS'], files_list) |
645 self.checkstdout('\n_____ %s at 42\n' % self.relpath) | 636 self.checkstdout('\n_____ %s at 42\n' % self.relpath) |
646 | 637 |
647 def testUpdateGit(self): | 638 def testUpdateGitSvn(self): |
648 options = self.Options(verbose=True) | 639 options = self.Options(verbose=True) |
649 file_path = gclient_scm.os.path.join(self.root_dir, self.relpath, '.git') | 640 gclient_scm.os.path.exists(self.base_path).AndReturn(True) |
650 gclient_scm.os.path.exists(file_path).AndReturn(True) | 641 self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'IsGitSvn', True) |
651 | 642 gclient_scm.scm.GIT.IsGitSvn(self.base_path).AndReturn(True) |
| 643 self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'Capture', True) |
| 644 gclient_scm.scm.GIT.Capture(['config', '--local', '--get', |
| 645 'svn-remote.svn.url'], |
| 646 cwd=self.base_path).AndReturn(self.url) |
652 self.mox.ReplayAll() | 647 self.mox.ReplayAll() |
653 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, | 648 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, |
654 relpath=self.relpath) | 649 relpath=self.relpath) |
655 file_list = [] | 650 file_list = [] |
656 scm.update(options, self.args, file_list) | 651 scm.update(options, [], file_list) |
657 self.checkstdout( | 652 self.checkstdout( |
658 ('________ found .git directory; skipping %s\n' % self.relpath)) | 653 ('\n_____ %s looks like a git-svn checkout. Skipping.\n' % self.relpath) |
659 | 654 ) |
660 def testUpdateHg(self): | |
661 options = self.Options(verbose=True) | |
662 gclient_scm.os.path.exists(join(self.base_path, '.git')).AndReturn(False) | |
663 gclient_scm.os.path.exists(join(self.base_path, '.hg')).AndReturn(True) | |
664 | |
665 self.mox.ReplayAll() | |
666 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, | |
667 relpath=self.relpath) | |
668 file_list = [] | |
669 scm.update(options, self.args, file_list) | |
670 self.checkstdout( | |
671 ('________ found .hg directory; skipping %s\n' % self.relpath)) | |
672 | 655 |
673 def testGetUsableRevSVN(self): | 656 def testGetUsableRevSVN(self): |
674 # pylint: disable=E1101 | 657 # pylint: disable=E1101 |
675 options = self.Options(verbose=True) | 658 options = self.Options(verbose=True) |
676 | 659 |
677 # Mock SVN revision validity checking. | 660 # Mock SVN revision validity checking. |
678 self.mox.StubOutWithMock( | 661 self.mox.StubOutWithMock( |
679 gclient_scm.scm.SVN, 'IsValidRevision', True) | 662 gclient_scm.scm.SVN, 'IsValidRevision', True) |
680 gclient_scm.scm.SVN.IsValidRevision(url='%s@%s' % (self.url, 1) | 663 gclient_scm.scm.SVN.IsValidRevision(url='%s@%s' % (self.url, 1) |
681 ).AndReturn(True) | 664 ).AndReturn(True) |
(...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1155 | 1138 |
1156 def testGetUsableRevGit(self): | 1139 def testGetUsableRevGit(self): |
1157 # pylint: disable=E1101 | 1140 # pylint: disable=E1101 |
1158 options = self.Options(verbose=True) | 1141 options = self.Options(verbose=True) |
1159 | 1142 |
1160 self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'IsValidRevision', True) | 1143 self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'IsValidRevision', True) |
1161 gclient_scm.scm.GIT.IsValidRevision(cwd=self.base_path, rev=self.fake_hash_1 | 1144 gclient_scm.scm.GIT.IsValidRevision(cwd=self.base_path, rev=self.fake_hash_1 |
1162 ).AndReturn(True) | 1145 ).AndReturn(True) |
1163 | 1146 |
1164 self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'IsGitSvn', True) | 1147 self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'IsGitSvn', True) |
1165 gclient_scm.scm.GIT.IsGitSvn(cwd=self.base_path).MultipleTimes( | 1148 gclient_scm.scm.GIT.IsGitSvn(self.base_path).MultipleTimes( |
1166 ).AndReturn(False) | 1149 ).AndReturn(False) |
1167 | 1150 |
1168 gclient_scm.scm.os.path.isdir(self.base_path).AndReturn(True) | 1151 gclient_scm.scm.os.path.isdir(self.base_path).AndReturn(True) |
1169 gclient_scm.os.path.isdir(self.base_path).AndReturn(True) | 1152 gclient_scm.os.path.isdir(self.base_path).AndReturn(True) |
1170 | 1153 |
1171 self.mox.ReplayAll() | 1154 self.mox.ReplayAll() |
1172 | 1155 |
1173 git_scm = gclient_scm.CreateSCM(url=self.url, root_dir=self.root_dir, | 1156 git_scm = gclient_scm.CreateSCM(url=self.url, root_dir=self.root_dir, |
1174 relpath=self.relpath) | 1157 relpath=self.relpath) |
1175 # A [fake] git sha1 with a git repo should work (this is in the case that | 1158 # A [fake] git sha1 with a git repo should work (this is in the case that |
(...skipping 28 matching lines...) Expand all Loading... |
1204 cwd=self.base_path).AndReturn('blah') | 1187 cwd=self.base_path).AndReturn('blah') |
1205 gclient_scm.scm.GIT.Capture(['fetch'], cwd=self.base_path) | 1188 gclient_scm.scm.GIT.Capture(['fetch'], cwd=self.base_path) |
1206 gclient_scm.scm.GIT.Capture(['svn', 'fetch'], cwd=self.base_path) | 1189 gclient_scm.scm.GIT.Capture(['svn', 'fetch'], cwd=self.base_path) |
1207 error = subprocess2.CalledProcessError(1, 'cmd', '/cwd', 'stdout', 'stderr') | 1190 error = subprocess2.CalledProcessError(1, 'cmd', '/cwd', 'stdout', 'stderr') |
1208 gclient_scm.scm.GIT.Capture(['config', '--get', 'svn-remote.svn.fetch'], | 1191 gclient_scm.scm.GIT.Capture(['config', '--get', 'svn-remote.svn.fetch'], |
1209 cwd=self.base_path).AndRaise(error) | 1192 cwd=self.base_path).AndRaise(error) |
1210 gclient_scm.scm.GIT.Capture(['svn', 'fetch'], cwd=self.base_path) | 1193 gclient_scm.scm.GIT.Capture(['svn', 'fetch'], cwd=self.base_path) |
1211 gclient_scm.scm.GIT.Capture(['fetch', 'origin'], cwd=self.base_path) | 1194 gclient_scm.scm.GIT.Capture(['fetch', 'origin'], cwd=self.base_path) |
1212 | 1195 |
1213 self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'IsGitSvn', True) | 1196 self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'IsGitSvn', True) |
1214 gclient_scm.scm.GIT.IsGitSvn(cwd=self.base_path).MultipleTimes( | 1197 gclient_scm.scm.GIT.IsGitSvn(self.base_path).MultipleTimes( |
1215 ).AndReturn(True) | 1198 ).AndReturn(True) |
1216 | 1199 |
1217 self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'IsValidRevision', True) | 1200 self.mox.StubOutWithMock(gclient_scm.scm.GIT, 'IsValidRevision', True) |
1218 gclient_scm.scm.GIT.IsValidRevision(cwd=self.base_path, rev=self.fake_hash_1 | 1201 gclient_scm.scm.GIT.IsValidRevision(cwd=self.base_path, rev=self.fake_hash_1 |
1219 ).AndReturn(True) | 1202 ).AndReturn(True) |
1220 gclient_scm.scm.GIT.IsValidRevision(cwd=self.base_path, rev=too_big | 1203 gclient_scm.scm.GIT.IsValidRevision(cwd=self.base_path, rev=too_big |
1221 ).MultipleTimes(2).AndReturn(False) | 1204 ).MultipleTimes(2).AndReturn(False) |
1222 | 1205 |
1223 gclient_scm.os.path.isdir(self.base_path).AndReturn(False) | 1206 gclient_scm.os.path.isdir(self.base_path).AndReturn(False) |
1224 gclient_scm.os.path.isdir(self.base_path).MultipleTimes().AndReturn(True) | 1207 gclient_scm.os.path.isdir(self.base_path).MultipleTimes().AndReturn(True) |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1271 | 1254 |
1272 if __name__ == '__main__': | 1255 if __name__ == '__main__': |
1273 if '-v' in sys.argv: | 1256 if '-v' in sys.argv: |
1274 logging.basicConfig( | 1257 logging.basicConfig( |
1275 level=logging.DEBUG, | 1258 level=logging.DEBUG, |
1276 format='%(asctime).19s %(levelname)s %(filename)s:' | 1259 format='%(asctime).19s %(levelname)s %(filename)s:' |
1277 '%(lineno)s %(message)s') | 1260 '%(lineno)s %(message)s') |
1278 unittest.main() | 1261 unittest.main() |
1279 | 1262 |
1280 # vim: ts=2:sw=2:tw=80:et: | 1263 # vim: ts=2:sw=2:tw=80:et: |
OLD | NEW |