| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # Copyright (c) 2010 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 """Smoke tests for gclient.py. | 6 """Smoke tests for gclient.py. |
| 7 | 7 |
| 8 Shell out 'gclient' and run basic conformance tests. | 8 Shell out 'gclient' and run basic conformance tests. |
| 9 | 9 |
| 10 This test assumes GClientSmokeBase.URL_BASE is valid. | 10 This test assumes GClientSmokeBase.URL_BASE is valid. |
| (...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 376 def testRunHooksDepsOs(self): | 376 def testRunHooksDepsOs(self): |
| 377 self.gclient(['config', self.svn_base + 'trunk/src/']) | 377 self.gclient(['config', self.svn_base + 'trunk/src/']) |
| 378 self.gclient(['sync', '--deps', 'mac', '--revision', 'src@1']) | 378 self.gclient(['sync', '--deps', 'mac', '--revision', 'src@1']) |
| 379 out = self.parseGclient(['runhooks', '--deps', 'mac'], []) | 379 out = self.parseGclient(['runhooks', '--deps', 'mac'], []) |
| 380 self.assertEquals([], out) | 380 self.assertEquals([], out) |
| 381 | 381 |
| 382 def testRevInfo(self): | 382 def testRevInfo(self): |
| 383 self.gclient(['config', self.svn_base + 'trunk/src/']) | 383 self.gclient(['config', self.svn_base + 'trunk/src/']) |
| 384 self.gclient(['sync', '--deps', 'mac']) | 384 self.gclient(['sync', '--deps', 'mac']) |
| 385 results = self.gclient(['revinfo', '--deps', 'mac']) | 385 results = self.gclient(['revinfo', '--deps', 'mac']) |
| 386 out = ('src: %(base)s/src@2;\n' | 386 out = ('src: %(base)s/src\n' |
| 387 'src/other: %(base)s/other@2;\n' | 387 'src/other: %(base)s/other\n' |
| 388 'src/third_party/foo: %(base)s/third_party/foo@1\n' % | 388 'src/third_party/foo: %(base)s/third_party/foo@1\n' % |
| 389 { 'base': self.svn_base + 'trunk' }) | 389 { 'base': self.svn_base + 'trunk' }) |
| 390 self.check((out, '', 0), results) | 390 self.check((out, '', 0), results) |
| 391 results = self.gclient(['revinfo', '--deps', 'mac', '--actual']) |
| 392 out = ('src: %(base)s/src@2\n' |
| 393 'src/other: %(base)s/other@2\n' |
| 394 'src/third_party/foo: %(base)s/third_party/foo@1\n' % |
| 395 { 'base': self.svn_base + 'trunk' }) |
| 396 self.check((out, '', 0), results) |
| 391 | 397 |
| 392 | 398 |
| 393 class GClientSmokeGIT(GClientSmokeBase): | 399 class GClientSmokeGIT(GClientSmokeBase): |
| 394 def setUp(self): | 400 def setUp(self): |
| 395 GClientSmokeBase.setUp(self) | 401 GClientSmokeBase.setUp(self) |
| 396 self.enabled = self.FAKE_REPOS.setUpGIT() | 402 self.enabled = self.FAKE_REPOS.setUpGIT() |
| 397 | 403 |
| 398 def testSync(self): | 404 def testSync(self): |
| 399 if not self.enabled: | 405 if not self.enabled: |
| 400 return | 406 return |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 555 tree['src/git_hooked2'] = 'git_hooked2' | 561 tree['src/git_hooked2'] = 'git_hooked2' |
| 556 self.assertTree(tree) | 562 self.assertTree(tree) |
| 557 | 563 |
| 558 def testRevInfo(self): | 564 def testRevInfo(self): |
| 559 if not self.enabled: | 565 if not self.enabled: |
| 560 return | 566 return |
| 561 # TODO(maruel): Test multiple solutions. | 567 # TODO(maruel): Test multiple solutions. |
| 562 self.gclient(['config', self.git_base + 'repo_1', '--name', 'src']) | 568 self.gclient(['config', self.git_base + 'repo_1', '--name', 'src']) |
| 563 self.gclient(['sync', '--deps', 'mac']) | 569 self.gclient(['sync', '--deps', 'mac']) |
| 564 results = self.gclient(['revinfo', '--deps', 'mac']) | 570 results = self.gclient(['revinfo', '--deps', 'mac']) |
| 565 out = ('src: %(base)srepo_1@%(hash1)s;\n' | 571 out = ('src: %(base)srepo_1\n' |
| 566 'src/repo2: %(base)srepo_2@%(hash2)s;\n' | 572 'src/repo2: %(base)srepo_2@%(hash2)s\n' |
| 573 'src/repo2/repo_renamed: %(base)srepo_3\n' % |
| 574 { |
| 575 'base': self.git_base, |
| 576 'hash1': self.githash('repo_1', 2)[:7], |
| 577 'hash2': self.githash('repo_2', 1)[:7], |
| 578 'hash3': self.githash('repo_3', 2)[:7], |
| 579 }) |
| 580 self.check((out, '', 0), results) |
| 581 results = self.gclient(['revinfo', '--deps', 'mac', '--actual']) |
| 582 out = ('src: %(base)srepo_1@%(hash1)s\n' |
| 583 'src/repo2: %(base)srepo_2@%(hash2)s\n' |
| 567 'src/repo2/repo_renamed: %(base)srepo_3@%(hash3)s\n' % | 584 'src/repo2/repo_renamed: %(base)srepo_3@%(hash3)s\n' % |
| 568 { | 585 { |
| 569 'base': self.git_base, | 586 'base': self.git_base, |
| 570 'hash1': self.githash('repo_1', 2), | 587 'hash1': self.githash('repo_1', 2), |
| 571 'hash2': self.githash('repo_2', 1), | 588 'hash2': self.githash('repo_2', 1), |
| 572 'hash3': self.githash('repo_3', 2), | 589 'hash3': self.githash('repo_3', 2), |
| 573 }) | 590 }) |
| 574 self.check((out, '', 0), results) | 591 self.check((out, '', 0), results) |
| 575 | 592 |
| 576 | 593 |
| 577 class GClientSmokeBoth(GClientSmokeBase): | 594 class GClientSmokeBoth(GClientSmokeBase): |
| 578 def setUp(self): | 595 def setUp(self): |
| 579 GClientSmokeBase.setUp(self) | 596 GClientSmokeBase.setUp(self) |
| 580 self.FAKE_REPOS.setUpSVN() | 597 self.FAKE_REPOS.setUpSVN() |
| 581 self.enabled = self.FAKE_REPOS.setUpGIT() | 598 self.enabled = self.FAKE_REPOS.setUpGIT() |
| 582 | 599 |
| 583 def testMultiSolutions(self): | 600 def testMultiSolutions(self): |
| 584 if not self.enabled: | 601 if not self.enabled: |
| 585 return | 602 return |
| 586 self.gclient(['config', '--spec', | 603 self.gclient(['config', '--spec', |
| 587 'solutions=[' | 604 'solutions=[' |
| 588 '{"name": "src",' | 605 '{"name": "src",' |
| 589 ' "url": "' + self.svn_base + 'trunk/src/"},' | 606 ' "url": "' + self.svn_base + 'trunk/src/"},' |
| 590 '{"name": "src-git",' | 607 '{"name": "src-git",' |
| 591 '"url": "' + self.git_base + 'repo_1"}]']) | 608 '"url": "' + self.git_base + 'repo_1"}]']) |
| 592 results = self.gclient(['sync', '--deps', 'mac']) | 609 results = self.gclient(['sync', '--deps', 'mac']) |
| 593 # 3x svn checkout, 3x run hooks | 610 # 3x svn checkout, 3x run hooks |
| 594 self.checkBlock(results[0], | 611 self.checkBlock(results[0], |
| 595 ['running', 'running', 'running', 'running', 'running', | 612 ['running', 'running', 'running', 'running', 'running', |
| 596 'running', 'running']) | 613 'running']) |
| 597 # TODO(maruel): Something's wrong here. git outputs to stderr 'Switched to | 614 # TODO(maruel): Something's wrong here. git outputs to stderr 'Switched to |
| 598 # new branch \'hash\''. | 615 # new branch \'hash\''. |
| 599 #self.checkString('', results[1]) | 616 #self.checkString('', results[1]) |
| 600 self.assertEquals(0, results[2]) | 617 self.assertEquals(0, results[2]) |
| 601 tree = self.mangle_git_tree(('repo_1@2', 'src-git'), | 618 tree = self.mangle_git_tree(('repo_1@2', 'src-git'), |
| 602 ('repo_2@1', 'src/repo2'), | 619 ('repo_2@1', 'src/repo2'), |
| 603 ('repo_3@2', 'src/repo2/repo_renamed')) | 620 ('repo_3@2', 'src/repo2/repo_renamed')) |
| 604 tree.update(self.mangle_svn_tree( | 621 tree.update(self.mangle_svn_tree( |
| 605 ('trunk/src@2', 'src'), | 622 ('trunk/src@2', 'src'), |
| 606 ('trunk/third_party/foo@1', 'src/third_party/foo'), | 623 ('trunk/third_party/foo@1', 'src/third_party/foo'), |
| 607 ('trunk/other@2', 'src/other'))) | 624 ('trunk/other@2', 'src/other'))) |
| 608 tree['src/git_hooked1'] = 'git_hooked1' | 625 tree['src/git_hooked1'] = 'git_hooked1' |
| 609 tree['src/git_hooked2'] = 'git_hooked2' | 626 tree['src/git_hooked2'] = 'git_hooked2' |
| 610 tree['src/svn_hooked1'] = 'svn_hooked1' | 627 tree['src/svn_hooked1'] = 'svn_hooked1' |
| 611 tree['src/svn_hooked2'] = 'svn_hooked2' | |
| 612 self.assertTree(tree) | 628 self.assertTree(tree) |
| 613 | 629 |
| 614 def testMultiSolutionsMultiRev(self): | 630 def testMultiSolutionsMultiRev(self): |
| 615 if not self.enabled: | 631 if not self.enabled: |
| 616 return | 632 return |
| 617 self.gclient(['config', '--spec', | 633 self.gclient(['config', '--spec', |
| 618 'solutions=[' | 634 'solutions=[' |
| 619 '{"name": "src",' | 635 '{"name": "src",' |
| 620 ' "url": "' + self.svn_base + 'trunk/src/"},' | 636 ' "url": "' + self.svn_base + 'trunk/src/"},' |
| 621 '{"name": "src-git",' | 637 '{"name": "src-git",' |
| (...skipping 20 matching lines...) Expand all Loading... |
| 642 if not self.enabled: | 658 if not self.enabled: |
| 643 return | 659 return |
| 644 self.gclient(['config', '--spec', | 660 self.gclient(['config', '--spec', |
| 645 'solutions=[' | 661 'solutions=[' |
| 646 '{"name": "src",' | 662 '{"name": "src",' |
| 647 ' "url": "' + self.svn_base + 'trunk/src/"},' | 663 ' "url": "' + self.svn_base + 'trunk/src/"},' |
| 648 '{"name": "src-git",' | 664 '{"name": "src-git",' |
| 649 '"url": "' + self.git_base + 'repo_1"}]']) | 665 '"url": "' + self.git_base + 'repo_1"}]']) |
| 650 self.gclient(['sync', '--deps', 'mac']) | 666 self.gclient(['sync', '--deps', 'mac']) |
| 651 results = self.gclient(['revinfo', '--deps', 'mac']) | 667 results = self.gclient(['revinfo', '--deps', 'mac']) |
| 652 out = ('src: %(svn_base)s/src/@2;\n' | 668 out = ('src: %(svn_base)s/src/\n' |
| 653 'src-git: %(git_base)srepo_1@%(hash1)s;\n' | 669 'src-git: %(git_base)srepo_1\n' |
| 654 'src/other: %(svn_base)s/other@2;\n' | 670 'src/other: %(svn_base)s/other\n' |
| 655 'src/repo2: %(git_base)srepo_2@%(hash2)s;\n' | 671 'src/repo2: %(git_base)srepo_2@%(hash2)s\n' |
| 656 'src/repo2/repo_renamed: %(git_base)srepo_3@%(hash3)s;\n' | 672 'src/repo2/repo_renamed: %(git_base)srepo_3\n' |
| 657 'src/third_party/foo: %(svn_base)s/third_party/foo@1\n') % { | 673 'src/third_party/foo: %(svn_base)s/third_party/foo@1\n') % { |
| 658 'svn_base': self.svn_base + 'trunk', | 674 'svn_base': self.svn_base + 'trunk', |
| 659 'git_base': self.git_base, | 675 'git_base': self.git_base, |
| 676 'hash1': self.githash('repo_1', 2)[:7], |
| 677 'hash2': self.githash('repo_2', 1)[:7], |
| 678 'hash3': self.githash('repo_3', 2)[:7], |
| 679 } |
| 680 self.check((out, '', 0), results) |
| 681 results = self.gclient(['revinfo', '--deps', 'mac', '--actual']) |
| 682 out = ('src: %(svn_base)s/src/@2\n' |
| 683 'src-git: %(git_base)srepo_1@%(hash1)s\n' |
| 684 'src/other: %(svn_base)s/other@2\n' |
| 685 'src/repo2: %(git_base)srepo_2@%(hash2)s\n' |
| 686 'src/repo2/repo_renamed: %(git_base)srepo_3@%(hash3)s\n' |
| 687 'src/third_party/foo: %(svn_base)s/third_party/foo@1\n') % { |
| 688 'svn_base': self.svn_base + 'trunk', |
| 689 'git_base': self.git_base, |
| 660 'hash1': self.githash('repo_1', 2), | 690 'hash1': self.githash('repo_1', 2), |
| 661 'hash2': self.githash('repo_2', 1), | 691 'hash2': self.githash('repo_2', 1), |
| 662 'hash3': self.githash('repo_3', 2), | 692 'hash3': self.githash('repo_3', 2), |
| 663 } | 693 } |
| 664 self.check((out, '', 0), results) | 694 self.check((out, '', 0), results) |
| 665 | 695 |
| 666 | 696 |
| 667 if __name__ == '__main__': | 697 if __name__ == '__main__': |
| 668 if '-c' in sys.argv: | 698 if '-c' in sys.argv: |
| 669 COVERAGE = True | 699 COVERAGE = True |
| 670 sys.argv.remove('-c') | 700 sys.argv.remove('-c') |
| 671 if os.path.exists('.coverage'): | 701 if os.path.exists('.coverage'): |
| 672 os.remove('.coverage') | 702 os.remove('.coverage') |
| 673 os.environ['COVERAGE_FILE'] = os.path.join( | 703 os.environ['COVERAGE_FILE'] = os.path.join( |
| 674 os.path.dirname(os.path.dirname(os.path.abspath(__file__))), | 704 os.path.dirname(os.path.dirname(os.path.abspath(__file__))), |
| 675 '.coverage') | 705 '.coverage') |
| 676 unittest.main() | 706 unittest.main() |
| OLD | NEW |