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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
95 | 95 |
96 def setUp(self): | 96 def setUp(self): |
97 BaseTestCase.setUp(self) | 97 BaseTestCase.setUp(self) |
98 self.url = self.SvnUrl() | 98 self.url = self.SvnUrl() |
99 | 99 |
100 def testDir(self): | 100 def testDir(self): |
101 members = [ | 101 members = [ |
102 'BinaryExists', | 102 'BinaryExists', |
103 'FullUrlForRelativeUrl', | 103 'FullUrlForRelativeUrl', |
104 'GetCheckoutRoot', | 104 'GetCheckoutRoot', |
105 'GetRemoteURL', | |
105 'GetRevisionDate', | 106 'GetRevisionDate', |
106 'GetUsableRev', | 107 'GetUsableRev', |
107 'Svnversion', | 108 'Svnversion', |
108 'RunCommand', | 109 'RunCommand', |
109 'cleanup', | 110 'cleanup', |
110 'diff', | 111 'diff', |
111 'name', | 112 'name', |
112 'pack', | 113 'pack', |
113 'relpath', | 114 'relpath', |
114 'revert', | 115 'revert', |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
155 def testGITFakeHttpsUrl(self): | 156 def testGITFakeHttpsUrl(self): |
156 self.url = 'git+https://foo' | 157 self.url = 'git+https://foo' |
157 | 158 |
158 self.mox.ReplayAll() | 159 self.mox.ReplayAll() |
159 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, | 160 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, |
160 relpath=self.relpath) | 161 relpath=self.relpath) |
161 self.assertEqual(scm.url, 'https://foo') | 162 self.assertEqual(scm.url, 'https://foo') |
162 | 163 |
163 def testRunCommandException(self): | 164 def testRunCommandException(self): |
164 options = self.Options(verbose=False) | 165 options = self.Options(verbose=False) |
165 gclient_scm.os.path.exists(join(self.base_path, '.git')).AndReturn(False) | |
166 gclient_scm.os.path.exists(join(self.base_path, '.hg')).AndReturn(False) | |
167 | 166 |
168 self.mox.ReplayAll() | 167 self.mox.ReplayAll() |
169 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, | 168 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, |
170 relpath=self.relpath) | 169 relpath=self.relpath) |
171 exception = "Unsupported argument(s): %s" % ','.join(self.args) | 170 exception = "Unsupported argument(s): %s" % ','.join(self.args) |
172 self.assertRaisesError(exception, scm.RunCommand, | 171 self.assertRaisesError(exception, scm.RunCommand, |
173 'update', options, self.args) | 172 'update', options, self.args) |
174 | 173 |
175 def testRunCommandUnknown(self): | 174 def testRunCommandUnknown(self): |
176 # TODO(maruel): if ever used. | 175 # TODO(maruel): if ever used. |
177 pass | 176 pass |
178 | 177 |
179 def testRevertMissing(self): | 178 def testRevertMissing(self): |
180 options = self.Options(verbose=True) | 179 options = self.Options(verbose=True) |
181 gclient_scm.os.path.isdir(self.base_path).AndReturn(False) | 180 gclient_scm.os.path.isdir(self.base_path).AndReturn(False) |
182 gclient_scm.os.path.exists(self.base_path).AndReturn(False) | 181 gclient_scm.os.path.exists(self.base_path).AndReturn(False) |
183 gclient_scm.scm.SVN.Capture(['--version', '--quiet'], None | 182 gclient_scm.scm.SVN.Capture(['--version', '--quiet'], None |
184 ).AndReturn('1.5.1') | 183 ).AndReturn('1.5.1') |
185 # It'll to a checkout instead. | 184 # It'll to a checkout instead. |
186 gclient_scm.os.path.exists(join(self.base_path, '.git')).AndReturn(False) | |
187 gclient_scm.os.path.exists(join(self.base_path, '.hg')).AndReturn(False) | |
188 # Checkout. | 185 # Checkout. |
189 gclient_scm.os.path.exists(self.base_path).AndReturn(False) | 186 gclient_scm.os.path.exists(self.base_path).AndReturn(False) |
190 parent = gclient_scm.os.path.dirname(self.base_path) | 187 parent = gclient_scm.os.path.dirname(self.base_path) |
191 gclient_scm.os.path.exists(parent).AndReturn(False) | 188 gclient_scm.os.path.exists(parent).AndReturn(False) |
192 gclient_scm.os.makedirs(parent) | 189 gclient_scm.os.makedirs(parent) |
193 gclient_scm.os.path.exists(parent).AndReturn(True) | 190 gclient_scm.os.path.exists(parent).AndReturn(True) |
194 files_list = self.mox.CreateMockAnything() | 191 files_list = self.mox.CreateMockAnything() |
195 gclient_scm.scm.SVN.RunAndGetFileList( | 192 gclient_scm.scm.SVN.RunAndGetFileList( |
196 options.verbose, | 193 options.verbose, |
197 ['checkout', self.url, self.base_path, '--force', '--ignore-externals'], | 194 ['checkout', self.url, self.base_path, '--force', '--ignore-externals'], |
198 cwd=self.root_dir, | 195 cwd=self.root_dir, |
199 file_list=files_list) | 196 file_list=files_list) |
200 | 197 |
201 gclient_scm.scm.SVN._CaptureInfo([], self.base_path+'/.' | 198 gclient_scm.scm.SVN._CaptureInfo([], self.base_path+'/.' |
202 ).AndReturn({'Revision': 100}) | 199 ).AndReturn({'Revision': 100}) |
203 | 200 |
204 self.mox.ReplayAll() | 201 self.mox.ReplayAll() |
205 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, | 202 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, |
206 relpath=self.relpath) | 203 relpath=self.relpath) |
207 scm.revert(options, self.args, files_list) | 204 scm.revert(options, self.args, files_list) |
208 self.checkstdout( | 205 self.checkstdout( |
209 ('\n_____ %s is missing, synching instead\n' % self.relpath)) | 206 ('\n_____ %s is missing, synching instead\n' % self.relpath)) |
210 | 207 |
211 def testRevertNoDotSvn(self): | 208 def testRevertNoDotSvn(self): |
212 options = self.Options(verbose=True, force=True) | 209 options = self.Options(verbose=True, force=True) |
213 gclient_scm.os.path.isdir(self.base_path).AndReturn(True) | 210 gclient_scm.os.path.isdir(self.base_path).AndReturn(True) |
214 gclient_scm.os.path.isdir(join(self.base_path, '.svn')).AndReturn(False) | 211 gclient_scm.os.path.isdir(join(self.base_path, '.svn')).AndReturn(False) |
215 gclient_scm.os.path.isdir(join(self.base_path, '.git')).AndReturn(False) | |
216 gclient_scm.os.path.isdir(join(self.base_path, '.hg')).AndReturn(False) | |
217 # Checkout. | 212 # Checkout. |
218 gclient_scm.os.path.exists(join(self.base_path, '.git')).AndReturn(False) | |
219 gclient_scm.os.path.exists(join(self.base_path, '.hg')).AndReturn(False) | |
220 gclient_scm.os.path.exists(self.base_path).AndReturn(False) | 213 gclient_scm.os.path.exists(self.base_path).AndReturn(False) |
221 parent = gclient_scm.os.path.dirname(self.base_path) | 214 parent = gclient_scm.os.path.dirname(self.base_path) |
222 gclient_scm.os.path.exists(parent).AndReturn(False) | 215 gclient_scm.os.path.exists(parent).AndReturn(False) |
223 gclient_scm.os.makedirs(parent) | 216 gclient_scm.os.makedirs(parent) |
224 gclient_scm.os.path.exists(parent).AndReturn(True) | 217 gclient_scm.os.path.exists(parent).AndReturn(True) |
225 files_list = self.mox.CreateMockAnything() | 218 files_list = self.mox.CreateMockAnything() |
226 gclient_scm.scm.SVN.Capture(['--version', '--quiet'], None | 219 gclient_scm.scm.SVN.Capture(['--version', '--quiet'], None |
227 ).AndReturn('1.6') | 220 ).AndReturn('1.6') |
228 gclient_scm.scm.SVN.RunAndGetFileList( | 221 gclient_scm.scm.SVN.RunAndGetFileList( |
229 options.verbose, | 222 options.verbose, |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
334 | 327 |
335 # TODO(maruel): TEST REVISIONS!!! | 328 # TODO(maruel): TEST REVISIONS!!! |
336 # TODO(maruel): TEST RELOCATE!!! | 329 # TODO(maruel): TEST RELOCATE!!! |
337 def testUpdateCheckout(self): | 330 def testUpdateCheckout(self): |
338 options = self.Options(verbose=True) | 331 options = self.Options(verbose=True) |
339 file_info = gclient_scm.gclient_utils.PrintableObject() | 332 file_info = gclient_scm.gclient_utils.PrintableObject() |
340 file_info.root = 'blah' | 333 file_info.root = 'blah' |
341 file_info.url = self.url | 334 file_info.url = self.url |
342 file_info.uuid = 'ABC' | 335 file_info.uuid = 'ABC' |
343 file_info.revision = 42 | 336 file_info.revision = 42 |
344 gclient_scm.os.path.exists(join(self.base_path, '.git')).AndReturn(False) | |
345 gclient_scm.os.path.exists(join(self.base_path, '.hg')).AndReturn(False) | |
346 # Checkout. | 337 # Checkout. |
347 gclient_scm.os.path.exists(self.base_path).AndReturn(False) | 338 gclient_scm.os.path.exists(self.base_path).AndReturn(False) |
348 parent = gclient_scm.os.path.dirname(self.base_path) | 339 parent = gclient_scm.os.path.dirname(self.base_path) |
349 gclient_scm.os.path.exists(parent).AndReturn(False) | 340 gclient_scm.os.path.exists(parent).AndReturn(False) |
350 gclient_scm.os.makedirs(parent) | 341 gclient_scm.os.makedirs(parent) |
351 gclient_scm.os.path.exists(parent).AndReturn(True) | 342 gclient_scm.os.path.exists(parent).AndReturn(True) |
352 files_list = self.mox.CreateMockAnything() | 343 files_list = self.mox.CreateMockAnything() |
353 gclient_scm.scm.SVN.Capture(['--version', '--quiet'], None | 344 gclient_scm.scm.SVN.Capture(['--version', '--quiet'], None |
354 ).AndReturn('1.5.1') | 345 ).AndReturn('1.5.1') |
355 gclient_scm.scm.SVN.RunAndGetFileList( | 346 gclient_scm.scm.SVN.RunAndGetFileList( |
(...skipping 11 matching lines...) Expand all Loading... | |
367 def testUpdateUpdate(self): | 358 def testUpdateUpdate(self): |
368 options = self.Options(verbose=True) | 359 options = self.Options(verbose=True) |
369 options.force = True | 360 options.force = True |
370 options.nohooks = False | 361 options.nohooks = False |
371 file_info = { | 362 file_info = { |
372 'Repository Root': 'blah', | 363 'Repository Root': 'blah', |
373 'URL': self.url, | 364 'URL': self.url, |
374 'UUID': 'ABC', | 365 'UUID': 'ABC', |
375 'Revision': 42, | 366 'Revision': 42, |
376 } | 367 } |
377 gclient_scm.os.path.exists(join(self.base_path, '.git')).AndReturn(False) | |
378 gclient_scm.os.path.exists(join(self.base_path, '.hg')).AndReturn(False) | |
379 gclient_scm.os.path.exists(self.base_path).AndReturn(True) | 368 gclient_scm.os.path.exists(self.base_path).AndReturn(True) |
380 | 369 |
381 # Checkout or update. | 370 # Checkout or update. |
382 dotted_path = join(self.base_path, '.') | 371 dotted_path = join(self.base_path, '.') |
383 gclient_scm.scm.SVN._CaptureInfo([], dotted_path).AndReturn(file_info) | 372 gclient_scm.scm.SVN._CaptureInfo([], dotted_path).AndReturn(file_info) |
384 | 373 |
385 # Verify no locked files. | 374 # Verify no locked files. |
386 gclient_scm.scm.SVN.CaptureStatus(None, dotted_path).AndReturn([]) | 375 gclient_scm.scm.SVN.CaptureStatus(None, dotted_path).AndReturn([]) |
387 | 376 |
388 # Cheat a bit here. | 377 # Cheat a bit here. |
(...skipping 24 matching lines...) Expand all Loading... | |
413 | 402 |
414 def testUpdateReset(self): | 403 def testUpdateReset(self): |
415 options = self.Options(verbose=True) | 404 options = self.Options(verbose=True) |
416 options.reset = True | 405 options.reset = True |
417 file_info = { | 406 file_info = { |
418 'Repository Root': 'blah', | 407 'Repository Root': 'blah', |
419 'URL': self.url, | 408 'URL': self.url, |
420 'UUID': 'ABC', | 409 'UUID': 'ABC', |
421 'Revision': 42, | 410 'Revision': 42, |
422 } | 411 } |
423 gclient_scm.os.path.exists(join(self.base_path, '.git')).AndReturn(False) | |
424 gclient_scm.os.path.exists(join(self.base_path, '.hg')).AndReturn(False) | |
425 gclient_scm.os.path.exists(self.base_path).AndReturn(True) | 412 gclient_scm.os.path.exists(self.base_path).AndReturn(True) |
426 | 413 |
427 # Checkout or update. | 414 # Checkout or update. |
428 dotted_path = join(self.base_path, '.') | 415 dotted_path = join(self.base_path, '.') |
429 gclient_scm.scm.SVN._CaptureInfo([], dotted_path).AndReturn(file_info) | 416 gclient_scm.scm.SVN._CaptureInfo([], dotted_path).AndReturn(file_info) |
430 | 417 |
431 # Create an untracked file and directory. | 418 # Create an untracked file and directory. |
432 gclient_scm.scm.SVN.CaptureStatus(None, dotted_path | 419 gclient_scm.scm.SVN.CaptureStatus(None, dotted_path |
433 ).AndReturn([['? ', 'dir'], ['? ', 'file']]) | 420 ).AndReturn([['? ', 'dir'], ['? ', 'file']]) |
434 | 421 |
(...skipping 14 matching lines...) Expand all Loading... | |
449 options = self.Options(verbose=True) | 436 options = self.Options(verbose=True) |
450 options.reset = True | 437 options.reset = True |
451 options.delete_unversioned_trees = True | 438 options.delete_unversioned_trees = True |
452 | 439 |
453 file_info = { | 440 file_info = { |
454 'Repository Root': 'blah', | 441 'Repository Root': 'blah', |
455 'URL': self.url, | 442 'URL': self.url, |
456 'UUID': 'ABC', | 443 'UUID': 'ABC', |
457 'Revision': 42, | 444 'Revision': 42, |
458 } | 445 } |
459 gclient_scm.os.path.exists(join(self.base_path, '.git')).AndReturn(False) | |
460 gclient_scm.os.path.exists(join(self.base_path, '.hg')).AndReturn(False) | |
461 gclient_scm.os.path.exists(self.base_path).AndReturn(True) | 446 gclient_scm.os.path.exists(self.base_path).AndReturn(True) |
462 | 447 |
463 # Checkout or update. | 448 # Checkout or update. |
464 dotted_path = join(self.base_path, '.') | 449 dotted_path = join(self.base_path, '.') |
465 gclient_scm.scm.SVN._CaptureInfo([], dotted_path).AndReturn(file_info) | 450 gclient_scm.scm.SVN._CaptureInfo([], dotted_path).AndReturn(file_info) |
466 | 451 |
467 # Create an untracked file and directory. | 452 # Create an untracked file and directory. |
468 gclient_scm.scm.SVN.CaptureStatus(None, dotted_path | 453 gclient_scm.scm.SVN.CaptureStatus(None, dotted_path |
469 ).AndReturn([['? ', 'dir'], ['? ', 'file']]) | 454 ).AndReturn([['? ', 'dir'], ['? ', 'file']]) |
470 | 455 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
515 ['svn', 'checkout', '--depth', 'empty', self.url, self.base_path], | 500 ['svn', 'checkout', '--depth', 'empty', self.url, self.base_path], |
516 always=True, | 501 always=True, |
517 cwd=self.root_dir) | 502 cwd=self.root_dir) |
518 gclient_scm.scm.SVN.RunAndGetFileList( | 503 gclient_scm.scm.SVN.RunAndGetFileList( |
519 options.verbose, | 504 options.verbose, |
520 ['update', 'DEPS', '--ignore-externals'], | 505 ['update', 'DEPS', '--ignore-externals'], |
521 cwd=self.base_path, | 506 cwd=self.base_path, |
522 file_list=files_list) | 507 file_list=files_list) |
523 | 508 |
524 # Now we fall back on scm.update(). | 509 # Now we fall back on scm.update(). |
525 gclient_scm.os.path.exists(join(self.base_path, '.git')).AndReturn(False) | |
526 gclient_scm.os.path.exists(join(self.base_path, '.hg')).AndReturn(False) | |
527 gclient_scm.os.path.exists(self.base_path).AndReturn(True) | 510 gclient_scm.os.path.exists(self.base_path).AndReturn(True) |
528 gclient_scm.scm.SVN._CaptureInfo([], dotted_path).AndReturn(file_info) | 511 gclient_scm.scm.SVN._CaptureInfo([], dotted_path).AndReturn(file_info) |
529 gclient_scm.scm.SVN._CaptureInfo([file_info['URL']], None | 512 gclient_scm.scm.SVN._CaptureInfo([file_info['URL']], None |
530 ).AndReturn(file_info) | 513 ).AndReturn(file_info) |
531 | 514 |
532 gclient_scm.scm.SVN._CaptureInfo([], self.base_path+'/.' | 515 gclient_scm.scm.SVN._CaptureInfo([], self.base_path+'/.' |
533 ).AndReturn({'Revision': 100}) | 516 ).AndReturn({'Revision': 100}) |
534 | 517 |
535 self.mox.ReplayAll() | 518 self.mox.ReplayAll() |
536 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, | 519 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... | |
585 ['svn', 'checkout', '--depth', 'empty', self.url, self.base_path], | 568 ['svn', 'checkout', '--depth', 'empty', self.url, self.base_path], |
586 always=True, | 569 always=True, |
587 cwd=self.root_dir) | 570 cwd=self.root_dir) |
588 gclient_scm.scm.SVN.RunAndGetFileList( | 571 gclient_scm.scm.SVN.RunAndGetFileList( |
589 options.verbose, | 572 options.verbose, |
590 ['update', 'DEPS', '--ignore-externals'], | 573 ['update', 'DEPS', '--ignore-externals'], |
591 cwd=self.base_path, | 574 cwd=self.base_path, |
592 file_list=files_list) | 575 file_list=files_list) |
593 | 576 |
594 # Now we fall back on scm.update(). | 577 # Now we fall back on scm.update(). |
595 gclient_scm.os.path.exists(join(self.base_path, '.git')).AndReturn(False) | |
596 gclient_scm.os.path.exists(join(self.base_path, '.hg')).AndReturn(False) | |
597 gclient_scm.os.path.exists(self.base_path).AndReturn(True) | 578 gclient_scm.os.path.exists(self.base_path).AndReturn(True) |
598 gclient_scm.scm.SVN._CaptureInfo( | 579 gclient_scm.scm.SVN._CaptureInfo( |
599 [], join(self.base_path, ".")).AndReturn(file_info) | 580 [], join(self.base_path, ".")).AndReturn(file_info) |
600 gclient_scm.scm.SVN._CaptureInfo([file_info['URL']], None | 581 gclient_scm.scm.SVN._CaptureInfo([file_info['URL']], None |
601 ).AndReturn(file_info) | 582 ).AndReturn(file_info) |
602 | 583 |
603 gclient_scm.scm.SVN._CaptureInfo([], self.base_path+'/.' | 584 gclient_scm.scm.SVN._CaptureInfo([], self.base_path+'/.' |
604 ).AndReturn({'Revision': 100}) | 585 ).AndReturn({'Revision': 100}) |
605 | 586 |
606 self.mox.ReplayAll() | 587 self.mox.ReplayAll() |
(...skipping 14 matching lines...) Expand all Loading... | |
621 gclient_scm.scm.SVN.Capture(['--version', '--quiet'], None | 602 gclient_scm.scm.SVN.Capture(['--version', '--quiet'], None |
622 ).AndReturn('1.5.1') | 603 ).AndReturn('1.5.1') |
623 gclient_scm.os.path.exists(join(self.base_path, '.svn')).AndReturn(True) | 604 gclient_scm.os.path.exists(join(self.base_path, '.svn')).AndReturn(True) |
624 | 605 |
625 # Verify no locked files. | 606 # Verify no locked files. |
626 gclient_scm.scm.SVN.CaptureStatus(None, join(self.base_path, '.') | 607 gclient_scm.scm.SVN.CaptureStatus(None, join(self.base_path, '.') |
627 ).AndReturn([]) | 608 ).AndReturn([]) |
628 | 609 |
629 # Now we fall back on scm.update(). | 610 # Now we fall back on scm.update(). |
630 files_list = self.mox.CreateMockAnything() | 611 files_list = self.mox.CreateMockAnything() |
631 gclient_scm.os.path.exists(join(self.base_path, '.git')).AndReturn(False) | |
632 gclient_scm.os.path.exists(join(self.base_path, '.hg')).AndReturn(False) | |
633 gclient_scm.os.path.exists(self.base_path).AndReturn(True) | 612 gclient_scm.os.path.exists(self.base_path).AndReturn(True) |
634 gclient_scm.scm.SVN._CaptureInfo( | 613 gclient_scm.scm.SVN._CaptureInfo( |
635 [], join(self.base_path, '.')).AndReturn(file_info) | 614 [], join(self.base_path, '.')).AndReturn(file_info) |
636 gclient_scm.scm.SVN._CaptureInfo([file_info['URL']], None | 615 gclient_scm.scm.SVN._CaptureInfo([file_info['URL']], None |
637 ).AndReturn(file_info) | 616 ).AndReturn(file_info) |
638 | 617 |
639 gclient_scm.scm.SVN._CaptureInfo([], self.base_path+'/.' | 618 gclient_scm.scm.SVN._CaptureInfo([], self.base_path+'/.' |
640 ).AndReturn({'Revision': 100}) | 619 ).AndReturn({'Revision': 100}) |
641 | 620 |
642 self.mox.ReplayAll() | 621 self.mox.ReplayAll() |
643 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, | 622 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, |
644 relpath=self.relpath) | 623 relpath=self.relpath) |
645 scm.updatesingle(options, ['DEPS'], files_list) | 624 scm.updatesingle(options, ['DEPS'], files_list) |
646 self.checkstdout('\n_____ %s at 42\n' % self.relpath) | 625 self.checkstdout('\n_____ %s at 42\n' % self.relpath) |
647 | 626 |
648 def testUpdateGit(self): | |
borenet
2014/01/14 21:49:45
I just removed these two tests, since making them
| |
649 options = self.Options(verbose=True) | |
650 file_path = gclient_scm.os.path.join(self.root_dir, self.relpath, '.git') | |
651 gclient_scm.os.path.exists(file_path).AndReturn(True) | |
652 | |
653 self.mox.ReplayAll() | |
654 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, | |
655 relpath=self.relpath) | |
656 file_list = [] | |
657 scm.update(options, self.args, file_list) | |
658 self.checkstdout( | |
659 ('________ found .git directory; skipping %s\n' % self.relpath)) | |
660 | |
661 def testUpdateHg(self): | |
662 options = self.Options(verbose=True) | |
663 gclient_scm.os.path.exists(join(self.base_path, '.git')).AndReturn(False) | |
664 gclient_scm.os.path.exists(join(self.base_path, '.hg')).AndReturn(True) | |
665 | |
666 self.mox.ReplayAll() | |
667 scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, | |
668 relpath=self.relpath) | |
669 file_list = [] | |
670 scm.update(options, self.args, file_list) | |
671 self.checkstdout( | |
672 ('________ found .hg directory; skipping %s\n' % self.relpath)) | |
673 | |
674 def testGetUsableRevSVN(self): | 627 def testGetUsableRevSVN(self): |
675 # pylint: disable=E1101 | 628 # pylint: disable=E1101 |
676 options = self.Options(verbose=True) | 629 options = self.Options(verbose=True) |
677 | 630 |
678 # Mock SVN revision validity checking. | 631 # Mock SVN revision validity checking. |
679 self.mox.StubOutWithMock( | 632 self.mox.StubOutWithMock( |
680 gclient_scm.scm.SVN, 'IsValidRevision', True) | 633 gclient_scm.scm.SVN, 'IsValidRevision', True) |
681 gclient_scm.scm.SVN.IsValidRevision(url='%s@%s' % (self.url, 1) | 634 gclient_scm.scm.SVN.IsValidRevision(url='%s@%s' % (self.url, 1) |
682 ).AndReturn(True) | 635 ).AndReturn(True) |
683 gclient_scm.scm.SVN.IsValidRevision(url='%s@%s' % (self.url, 'fake') | 636 gclient_scm.scm.SVN.IsValidRevision(url='%s@%s' % (self.url, 'fake') |
684 ).AndReturn(False) | 637 ).AndReturn(False) |
685 | 638 |
686 self.mox.ReplayAll() | 639 self.mox.ReplayAll() |
687 | 640 |
688 svn_scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir) | 641 svn_scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir) |
689 # With an SVN checkout, 1 an example of a valid usable rev. | 642 # With an SVN checkout, 1 an example of a valid usable rev. |
690 self.assertEquals(svn_scm.GetUsableRev(1, options), 1) | 643 self.assertEquals(svn_scm.GetUsableRev(1, options), 1) |
691 # With an SVN checkout, a fake or unknown rev should raise an excpetion. | 644 # With an SVN checkout, a fake or unknown rev should raise an excpetion. |
692 self.assertRaises(gclient_scm.gclient_utils.Error, | 645 self.assertRaises(gclient_scm.gclient_utils.Error, |
693 svn_scm.GetUsableRev, 'fake', options) | 646 svn_scm.GetUsableRev, 'fake', options) |
694 | 647 |
648 def testGetRemoteURL(self): | |
649 self.mox.UnsetStubs() | |
650 options = self.Options(verbose=True) | |
651 self.mox.StubOutWithMock(gclient_scm.scm.SVN, 'Capture', True) | |
652 svn_scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, | |
653 relpath=self.relpath) | |
654 | |
655 if svn_scm.relpath: | |
656 cwd = os.path.join(svn_scm._root_dir, svn_scm.relpath) | |
657 else: | |
658 cwd = svn_scm._root_dir | |
659 | |
660 gclient_scm.scm.SVN.Capture(['info', '--xml', os.curdir], cwd).AndReturn( | |
661 """<?xml version="1.0"?> | |
662 <info> | |
663 <entry | |
664 path="." | |
665 revision="1234" | |
666 kind="dir"> | |
667 <url>%s</url> | |
668 <repository> | |
669 <root>https://dummy.repo.com/svn</root> | |
670 <uuid>FAKE</uuid> | |
671 </repository> | |
672 <wc-info> | |
673 <schedule>normal</schedule> | |
674 <depth>infinity</depth> | |
675 </wc-info> | |
676 <commit | |
677 revision="1234"> | |
678 <author>fakedev@chromium.org</author> | |
679 <date>2013-11-14T15:08:21.757885Z</date> | |
680 </commit> | |
681 </entry> | |
682 </info> | |
683 """ % svn_scm.url) | |
684 | |
685 self.mox.ReplayAll() | |
686 | |
687 self.assertEquals(svn_scm.GetRemoteURL(options), self.url) | |
688 | |
689 | |
695 class BaseGitWrapperTestCase(GCBaseTestCase, StdoutCheck, TestCaseUtils, | 690 class BaseGitWrapperTestCase(GCBaseTestCase, StdoutCheck, TestCaseUtils, |
696 unittest.TestCase): | 691 unittest.TestCase): |
697 """This class doesn't use pymox.""" | 692 """This class doesn't use pymox.""" |
698 class OptionsObject(object): | 693 class OptionsObject(object): |
699 def __init__(self, verbose=False, revision=None): | 694 def __init__(self, verbose=False, revision=None): |
700 self.verbose = verbose | 695 self.verbose = verbose |
701 self.revision = revision | 696 self.revision = revision |
702 self.manually_grab_svn_rev = True | 697 self.manually_grab_svn_rev = True |
703 self.deps_os = None | 698 self.deps_os = None |
704 self.force = False | 699 self.force = False |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
810 gclient_scm.GitWrapper.BinaryExists = self._original_GitBinaryExists | 805 gclient_scm.GitWrapper.BinaryExists = self._original_GitBinaryExists |
811 gclient_scm.SVNWrapper.BinaryExists = self._original_SVNBinaryExists | 806 gclient_scm.SVNWrapper.BinaryExists = self._original_SVNBinaryExists |
812 | 807 |
813 | 808 |
814 class ManagedGitWrapperTestCase(BaseGitWrapperTestCase): | 809 class ManagedGitWrapperTestCase(BaseGitWrapperTestCase): |
815 def testDir(self): | 810 def testDir(self): |
816 members = [ | 811 members = [ |
817 'BinaryExists', | 812 'BinaryExists', |
818 'FullUrlForRelativeUrl', | 813 'FullUrlForRelativeUrl', |
819 'GetCheckoutRoot', | 814 'GetCheckoutRoot', |
815 'GetRemoteURL', | |
820 'GetRevisionDate', | 816 'GetRevisionDate', |
821 'GetUsableRev', | 817 'GetUsableRev', |
822 'RunCommand', | 818 'RunCommand', |
823 'cache_dir', | 819 'cache_dir', |
824 'cache_locks', | 820 'cache_locks', |
825 'cleanup', | 821 'cleanup', |
826 'diff', | 822 'diff', |
827 'name', | 823 'name', |
828 'pack', | 824 'pack', |
829 'UpdateSubmoduleConfig', | 825 'UpdateSubmoduleConfig', |
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1178 self.assertEquals(git_svn_scm.GetUsableRev('3', options), | 1174 self.assertEquals(git_svn_scm.GetUsableRev('3', options), |
1179 self.fake_hash_2) | 1175 self.fake_hash_2) |
1180 # Given a git sha1 with a git-svn checkout, it should be used as is. | 1176 # Given a git sha1 with a git-svn checkout, it should be used as is. |
1181 self.assertEquals(git_svn_scm.GetUsableRev(self.fake_hash_1, options), | 1177 self.assertEquals(git_svn_scm.GetUsableRev(self.fake_hash_1, options), |
1182 self.fake_hash_1) | 1178 self.fake_hash_1) |
1183 # We currently check for seemingly valid SVN revisions by assuming 6 digit | 1179 # We currently check for seemingly valid SVN revisions by assuming 6 digit |
1184 # numbers, so assure that numeric revs >= 1000000 don't work. | 1180 # numbers, so assure that numeric revs >= 1000000 don't work. |
1185 self.assertRaises(gclient_scm.gclient_utils.Error, | 1181 self.assertRaises(gclient_scm.gclient_utils.Error, |
1186 git_svn_scm.GetUsableRev, too_big, options) | 1182 git_svn_scm.GetUsableRev, too_big, options) |
1187 | 1183 |
1184 def testGetRemoteURL(self): | |
1185 options = self.Options(verbose=True) | |
1186 self.mox.StubOutWithMock(gclient_scm.GitWrapper, '_Capture', True) | |
1187 git_scm = self._scm_wrapper(url=self.url, root_dir=self.root_dir, | |
1188 relpath=self.relpath) | |
1189 git_scm._Capture(['config', 'remote.origin.url'], cwd='/tmp/fake' | |
1190 ).AndReturn('%s\n' % git_scm.url) | |
1191 | |
1192 self.mox.ReplayAll() | |
1193 | |
1194 self.assertEquals(git_scm.GetRemoteURL(options), self.url) | |
1195 | |
1188 | 1196 |
1189 class UnmanagedGitWrapperTestCase(BaseGitWrapperTestCase): | 1197 class UnmanagedGitWrapperTestCase(BaseGitWrapperTestCase): |
1190 def testUpdateUpdate(self): | 1198 def testUpdateUpdate(self): |
1191 if not self.enabled: | 1199 if not self.enabled: |
1192 return | 1200 return |
1193 options = self.Options() | 1201 options = self.Options() |
1194 expected_file_list = [] | 1202 expected_file_list = [] |
1195 scm = gclient_scm.CreateSCM(url=self.url, root_dir=self.root_dir, | 1203 scm = gclient_scm.CreateSCM(url=self.url, root_dir=self.root_dir, |
1196 relpath=self.relpath) | 1204 relpath=self.relpath) |
1197 file_list = [] | 1205 file_list = [] |
1198 options.revision = 'unmanaged' | 1206 options.revision = 'unmanaged' |
1199 scm.update(options, (), file_list) | 1207 scm.update(options, (), file_list) |
1200 self.assertEquals(file_list, expected_file_list) | 1208 self.assertEquals(file_list, expected_file_list) |
1201 self.assertEquals(scm.revinfo(options, (), None), | 1209 self.assertEquals(scm.revinfo(options, (), None), |
1202 '069c602044c5388d2d15c3f875b057c852003458') | 1210 '069c602044c5388d2d15c3f875b057c852003458') |
1203 self.checkstdout('________ unmanaged solution; skipping .\n') | 1211 self.checkstdout('________ unmanaged solution; skipping .\n') |
1204 | 1212 |
1205 | 1213 |
1206 if __name__ == '__main__': | 1214 if __name__ == '__main__': |
1207 if '-v' in sys.argv: | 1215 if '-v' in sys.argv: |
1208 logging.basicConfig( | 1216 logging.basicConfig( |
1209 level=logging.DEBUG, | 1217 level=logging.DEBUG, |
1210 format='%(asctime).19s %(levelname)s %(filename)s:' | 1218 format='%(asctime).19s %(levelname)s %(filename)s:' |
1211 '%(lineno)s %(message)s') | 1219 '%(lineno)s %(message)s') |
1212 unittest.main() | 1220 unittest.main() |
1213 | 1221 |
1214 # vim: ts=2:sw=2:tw=80:et: | 1222 # vim: ts=2:sw=2:tw=80:et: |
OLD | NEW |