| 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 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 self.checkString('svn_hooked1', out[0][2]) | 276 self.checkString('svn_hooked1', out[0][2]) |
| 277 self.checkString(join('third_party', 'foo'), out[0][3]) | 277 self.checkString(join('third_party', 'foo'), out[0][3]) |
| 278 self.checkString('hi', out[1][1]) | 278 self.checkString('hi', out[1][1]) |
| 279 self.assertEquals(4, len(out[0])) | 279 self.assertEquals(4, len(out[0])) |
| 280 self.assertEquals(2, len(out[1])) | 280 self.assertEquals(2, len(out[1])) |
| 281 | 281 |
| 282 # Revert implies --force implies running hooks without looking at pattern | 282 # Revert implies --force implies running hooks without looking at pattern |
| 283 # matching. | 283 # matching. |
| 284 results = self.gclient(['revert', '--deps', 'mac']) | 284 results = self.gclient(['revert', '--deps', 'mac']) |
| 285 out = self.splitBlock(results[0]) | 285 out = self.splitBlock(results[0]) |
| 286 # src, src/other is missing, src/other, src/third_party/foo is missing, |
| 287 # src/third_party/foo, 2 svn hooks. |
| 286 self.assertEquals(7, len(out)) | 288 self.assertEquals(7, len(out)) |
| 287 self.checkString('', results[1]) | 289 self.checkString('', results[1]) |
| 288 self.assertEquals(0, results[2]) | 290 self.assertEquals(0, results[2]) |
| 289 tree = self.mangle_svn_tree( | 291 tree = self.mangle_svn_tree( |
| 290 ('trunk/src@2', 'src'), | 292 ('trunk/src@2', 'src'), |
| 291 ('trunk/third_party/foo@1', 'src/third_party/foo'), | 293 ('trunk/third_party/foo@1', 'src/third_party/foo'), |
| 292 ('trunk/other@2', 'src/other')) | 294 ('trunk/other@2', 'src/other')) |
| 293 tree['src/svn_hooked1'] = 'svn_hooked1' | 295 tree['src/svn_hooked1'] = 'svn_hooked1' |
| 294 tree['src/svn_hooked2'] = 'svn_hooked2' | 296 tree['src/svn_hooked2'] = 'svn_hooked2' |
| 295 self.assertTree(tree) | 297 self.assertTree(tree) |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 368 self.checkString(1, len(out[0])) | 370 self.checkString(1, len(out[0])) |
| 369 self.checkString(1, len(out[1])) | 371 self.checkString(1, len(out[1])) |
| 370 | 372 |
| 371 def testRunHooksDepsOs(self): | 373 def testRunHooksDepsOs(self): |
| 372 self.gclient(['config', self.svn_base + 'trunk/src/']) | 374 self.gclient(['config', self.svn_base + 'trunk/src/']) |
| 373 self.gclient(['sync', '--deps', 'mac', '--revision', 'src@1']) | 375 self.gclient(['sync', '--deps', 'mac', '--revision', 'src@1']) |
| 374 out = self.parseGclient(['runhooks', '--deps', 'mac'], []) | 376 out = self.parseGclient(['runhooks', '--deps', 'mac'], []) |
| 375 self.assertEquals([], out) | 377 self.assertEquals([], out) |
| 376 | 378 |
| 377 def testRevInfo(self): | 379 def testRevInfo(self): |
| 378 # TODO(maruel): Test multiple solutions. | |
| 379 self.gclient(['config', self.svn_base + 'trunk/src/']) | 380 self.gclient(['config', self.svn_base + 'trunk/src/']) |
| 380 self.gclient(['sync', '--deps', 'mac']) | 381 self.gclient(['sync', '--deps', 'mac']) |
| 381 results = self.gclient(['revinfo', '--deps', 'mac']) | 382 results = self.gclient(['revinfo', '--deps', 'mac']) |
| 382 out = ('src: %(base)s/src@2;\n' | 383 out = ('src: %(base)s/src@2;\n' |
| 383 'src/other: %(base)s/other@2;\n' | 384 'src/other: %(base)s/other@2;\n' |
| 384 'src/third_party/foo: %(base)s/third_party/foo@1\n' % | 385 'src/third_party/foo: %(base)s/third_party/foo@1\n' % |
| 385 { 'base': self.svn_base + 'trunk' }) | 386 { 'base': self.svn_base + 'trunk' }) |
| 386 self.check((out, '', 0), results) | 387 self.check((out, '', 0), results) |
| 387 | 388 |
| 388 | 389 |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 579 def testMultiSolutions(self): | 580 def testMultiSolutions(self): |
| 580 if not self.enabled: | 581 if not self.enabled: |
| 581 return | 582 return |
| 582 self.gclient(['config', '--spec', | 583 self.gclient(['config', '--spec', |
| 583 'solutions=[' | 584 'solutions=[' |
| 584 '{"name": "src",' | 585 '{"name": "src",' |
| 585 ' "url": "' + self.svn_base + 'trunk/src/"},' | 586 ' "url": "' + self.svn_base + 'trunk/src/"},' |
| 586 '{"name": "src-git",' | 587 '{"name": "src-git",' |
| 587 '"url": "' + self.git_base + 'repo_1"}]']) | 588 '"url": "' + self.git_base + 'repo_1"}]']) |
| 588 results = self.gclient(['sync', '--deps', 'mac']) | 589 results = self.gclient(['sync', '--deps', 'mac']) |
| 590 # 3x svn checkout, 3x run hooks |
| 589 self.checkBlock(results[0], | 591 self.checkBlock(results[0], |
| 590 ['running', 'running', 'running', 'running', 'running', | 592 ['running', 'running', 'running', 'running', 'running', |
| 591 'running', 'running']) | 593 'running', 'running']) |
| 592 # TODO(maruel): Something's wrong here. git outputs to stderr 'Switched to | 594 # TODO(maruel): Something's wrong here. git outputs to stderr 'Switched to |
| 593 # new branch \'hash\''. | 595 # new branch \'hash\''. |
| 594 #self.checkString('', results[1]) | 596 #self.checkString('', results[1]) |
| 595 self.assertEquals(0, results[2]) | 597 self.assertEquals(0, results[2]) |
| 596 tree = self.mangle_git_tree(('repo_1@2', 'src-git'), | 598 tree = self.mangle_git_tree(('repo_1@2', 'src-git'), |
| 597 ('repo_2@1', 'src/repo2'), | 599 ('repo_2@1', 'src/repo2'), |
| 598 ('repo_3@2', 'src/repo2/repo_renamed')) | 600 ('repo_3@2', 'src/repo2/repo_renamed')) |
| (...skipping 27 matching lines...) Expand all Loading... |
| 626 ('repo_2@2', 'src/repo2'), | 628 ('repo_2@2', 'src/repo2'), |
| 627 ('repo_3@1', 'src/repo2/repo3'), | 629 ('repo_3@1', 'src/repo2/repo3'), |
| 628 ('repo_4@2', 'src/repo4')) | 630 ('repo_4@2', 'src/repo4')) |
| 629 tree.update(self.mangle_svn_tree( | 631 tree.update(self.mangle_svn_tree( |
| 630 ('trunk/src@1', 'src'), | 632 ('trunk/src@1', 'src'), |
| 631 ('trunk/third_party/foo@2', 'src/third_party/fpp'), | 633 ('trunk/third_party/foo@2', 'src/third_party/fpp'), |
| 632 ('trunk/other@1', 'src/other'), | 634 ('trunk/other@1', 'src/other'), |
| 633 ('trunk/third_party/foo@2', 'src/third_party/prout'))) | 635 ('trunk/third_party/foo@2', 'src/third_party/prout'))) |
| 634 self.assertTree(tree) | 636 self.assertTree(tree) |
| 635 | 637 |
| 638 def testRevInfo(self): |
| 639 if not self.enabled: |
| 640 return |
| 641 self.gclient(['config', '--spec', |
| 642 'solutions=[' |
| 643 '{"name": "src",' |
| 644 ' "url": "' + self.svn_base + 'trunk/src/"},' |
| 645 '{"name": "src-git",' |
| 646 '"url": "' + self.git_base + 'repo_1"}]']) |
| 647 self.gclient(['sync', '--deps', 'mac']) |
| 648 results = self.gclient(['revinfo', '--deps', 'mac']) |
| 649 out = ('src: %(svn_base)s/src/@2;\n' |
| 650 'src-git: %(git_base)srepo_1@%(hash1)s;\n' |
| 651 'src/other: %(svn_base)s/other@2;\n' |
| 652 'src/repo2: %(git_base)srepo_2@%(hash2)s;\n' |
| 653 'src/repo2/repo_renamed: %(git_base)srepo_3@%(hash3)s;\n' |
| 654 'src/third_party/foo: %(svn_base)s/third_party/foo@1\n') % { |
| 655 'svn_base': self.svn_base + 'trunk', |
| 656 'git_base': self.git_base, |
| 657 'hash1': self.githash('repo_1', 2), |
| 658 'hash2': self.githash('repo_2', 1), |
| 659 'hash3': self.githash('repo_3', 2), |
| 660 } |
| 661 self.check((out, '', 0), results) |
| 662 |
| 636 | 663 |
| 637 if __name__ == '__main__': | 664 if __name__ == '__main__': |
| 638 if '-c' in sys.argv: | 665 if '-c' in sys.argv: |
| 639 COVERAGE = True | 666 COVERAGE = True |
| 640 sys.argv.remove('-c') | 667 sys.argv.remove('-c') |
| 641 if os.path.exists('.coverage'): | 668 if os.path.exists('.coverage'): |
| 642 os.remove('.coverage') | 669 os.remove('.coverage') |
| 643 os.environ['COVERAGE_FILE'] = os.path.join( | 670 os.environ['COVERAGE_FILE'] = os.path.join( |
| 644 os.path.dirname(os.path.dirname(os.path.abspath(__file__))), | 671 os.path.dirname(os.path.dirname(os.path.abspath(__file__))), |
| 645 '.coverage') | 672 '.coverage') |
| 646 unittest.main() | 673 unittest.main() |
| OLD | NEW |