| 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 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 # recreated. | 211 # recreated. |
| 212 os.remove(join(self.root_dir, 'src', 'svn_hooked1')) | 212 os.remove(join(self.root_dir, 'src', 'svn_hooked1')) |
| 213 | 213 |
| 214 # Test incremental versioned sync: sync backward. | 214 # Test incremental versioned sync: sync backward. |
| 215 self.parseGclient(['sync', '--revision', 'src@1', '--deps', 'mac', | 215 self.parseGclient(['sync', '--revision', 'src@1', '--deps', 'mac', |
| 216 '--delete_unversioned_trees'], | 216 '--delete_unversioned_trees'], |
| 217 ['running', 'running', 'running', 'running', 'deleting']) | 217 ['running', 'running', 'running', 'running', 'deleting']) |
| 218 tree = self.mangle_svn_tree( | 218 tree = self.mangle_svn_tree( |
| 219 ('trunk/src@1', 'src'), | 219 ('trunk/src@1', 'src'), |
| 220 ('trunk/third_party/foo@2', 'src/third_party/fpp'), | 220 ('trunk/third_party/foo@2', 'src/third_party/fpp'), |
| 221 ('trunk/other@2', 'src/other'), | 221 ('trunk/other@1', 'src/other'), |
| 222 ('trunk/third_party/foo@2', 'src/third_party/prout')) | 222 ('trunk/third_party/foo@2', 'src/third_party/prout')) |
| 223 self.assertTree(tree) | 223 self.assertTree(tree) |
| 224 # Test incremental sync: delete-unversioned_trees isn't there. | 224 # Test incremental sync: delete-unversioned_trees isn't there. |
| 225 self.parseGclient(['sync', '--deps', 'mac'], | 225 self.parseGclient(['sync', '--deps', 'mac'], |
| 226 ['running', 'running', 'running', 'running']) | 226 ['running', 'running', 'running', 'running']) |
| 227 tree = self.mangle_svn_tree( | 227 tree = self.mangle_svn_tree( |
| 228 ('trunk/src@2', 'src'), | 228 ('trunk/src@2', 'src'), |
| 229 ('trunk/third_party/foo@2', 'src/third_party/fpp'), | 229 ('trunk/third_party/foo@2', 'src/third_party/fpp'), |
| 230 ('trunk/third_party/foo@1', 'src/third_party/foo'), | 230 ('trunk/third_party/foo@1', 'src/third_party/foo'), |
| 231 ('trunk/other@2', 'src/other'), | 231 ('trunk/other@2', 'src/other'), |
| (...skipping 17 matching lines...) Expand all Loading... |
| 249 self.assertTree(tree) | 249 self.assertTree(tree) |
| 250 | 250 |
| 251 def testSyncNoSolutionName(self): | 251 def testSyncNoSolutionName(self): |
| 252 # When no solution name is provided, gclient uses the first solution listed. | 252 # When no solution name is provided, gclient uses the first solution listed. |
| 253 self.gclient(['config', self.svn_base + 'trunk/src/']) | 253 self.gclient(['config', self.svn_base + 'trunk/src/']) |
| 254 self.parseGclient(['sync', '--deps', 'mac', '-r', '1'], | 254 self.parseGclient(['sync', '--deps', 'mac', '-r', '1'], |
| 255 ['running', 'running', 'running', 'running']) | 255 ['running', 'running', 'running', 'running']) |
| 256 tree = self.mangle_svn_tree( | 256 tree = self.mangle_svn_tree( |
| 257 ('trunk/src@1', 'src'), | 257 ('trunk/src@1', 'src'), |
| 258 ('trunk/third_party/foo@2', 'src/third_party/fpp'), | 258 ('trunk/third_party/foo@2', 'src/third_party/fpp'), |
| 259 ('trunk/other@2', 'src/other'), | 259 ('trunk/other@1', 'src/other'), |
| 260 ('trunk/third_party/foo@2', 'src/third_party/prout')) | 260 ('trunk/third_party/foo@2', 'src/third_party/prout')) |
| 261 self.assertTree(tree) | 261 self.assertTree(tree) |
| 262 | 262 |
| 263 def testRevertAndStatus(self): | 263 def testRevertAndStatus(self): |
| 264 self.gclient(['config', self.svn_base + 'trunk/src/']) | 264 self.gclient(['config', self.svn_base + 'trunk/src/']) |
| 265 # Tested in testSync. | 265 # Tested in testSync. |
| 266 self.gclient(['sync', '--deps', 'mac']) | 266 self.gclient(['sync', '--deps', 'mac']) |
| 267 write(join(self.root_dir, 'src', 'other', 'hi'), 'Hey!') | 267 write(join(self.root_dir, 'src', 'other', 'hi'), 'Hey!') |
| 268 | 268 |
| 269 out = self.parseGclient(['status', '--deps', 'mac'], | 269 out = self.parseGclient(['status', '--deps', 'mac'], |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 # TODO(maruel): In general, gclient revert output is wrong. It should output | 339 # TODO(maruel): In general, gclient revert output is wrong. It should output |
| 340 # the file list after some ___ running 'svn status' | 340 # the file list after some ___ running 'svn status' |
| 341 results = self.gclient(['revert', '--deps', 'mac']) | 341 results = self.gclient(['revert', '--deps', 'mac']) |
| 342 out = self.splitBlock(results[0]) | 342 out = self.splitBlock(results[0]) |
| 343 self.assertEquals(7, len(out)) | 343 self.assertEquals(7, len(out)) |
| 344 self.checkString('', results[1]) | 344 self.checkString('', results[1]) |
| 345 self.assertEquals(0, results[2]) | 345 self.assertEquals(0, results[2]) |
| 346 tree = self.mangle_svn_tree( | 346 tree = self.mangle_svn_tree( |
| 347 ('trunk/src@1', 'src'), | 347 ('trunk/src@1', 'src'), |
| 348 ('trunk/third_party/foo@2', 'src/third_party/fpp'), | 348 ('trunk/third_party/foo@2', 'src/third_party/fpp'), |
| 349 ('trunk/other@2', 'src/other'), | 349 ('trunk/other@1', 'src/other'), |
| 350 ('trunk/third_party/prout@2', 'src/third_party/prout')) | 350 ('trunk/third_party/prout@2', 'src/third_party/prout')) |
| 351 self.assertTree(tree) | 351 self.assertTree(tree) |
| 352 | 352 |
| 353 out = self.parseGclient(['status', '--deps', 'mac'], | 353 out = self.parseGclient(['status', '--deps', 'mac'], |
| 354 [['running', join(self.root_dir, 'src')]]) | 354 [['running', join(self.root_dir, 'src')]]) |
| 355 out = self.svnBlockCleanup(out) | 355 out = self.svnBlockCleanup(out) |
| 356 self.checkString('other', out[0][1]) | 356 self.checkString('other', out[0][1]) |
| 357 self.checkString(join('third_party', 'fpp'), out[0][2]) | 357 self.checkString(join('third_party', 'fpp'), out[0][2]) |
| 358 self.checkString(join('third_party', 'prout'), out[0][3]) | 358 self.checkString(join('third_party', 'prout'), out[0][3]) |
| 359 self.assertEquals(4, len(out[0])) | 359 self.assertEquals(4, len(out[0])) |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 417 'src@' + self.githash('repo_1', 1), | 417 'src@' + self.githash('repo_1', 1), |
| 418 '--deps', 'mac', '--delete_unversioned_trees']) | 418 '--deps', 'mac', '--delete_unversioned_trees']) |
| 419 # gclient's git output is unparsable and all messed up. Don't look at it, it | 419 # gclient's git output is unparsable and all messed up. Don't look at it, it |
| 420 # hurts the smoke test's eyes. Add "print out" here if you want to dare to | 420 # hurts the smoke test's eyes. Add "print out" here if you want to dare to |
| 421 # parse it. So just assert it's not empty and look at the result on the file | 421 # parse it. So just assert it's not empty and look at the result on the file |
| 422 # system instead. | 422 # system instead. |
| 423 self.assertEquals('', results[1]) | 423 self.assertEquals('', results[1]) |
| 424 self.assertEquals(0, results[2]) | 424 self.assertEquals(0, results[2]) |
| 425 tree = self.mangle_git_tree(('repo_1@1', 'src'), | 425 tree = self.mangle_git_tree(('repo_1@1', 'src'), |
| 426 ('repo_2@2', 'src/repo2'), | 426 ('repo_2@2', 'src/repo2'), |
| 427 ('repo_3@2', 'src/repo2/repo3'), | 427 ('repo_3@1', 'src/repo2/repo3'), |
| 428 ('repo_4@2', 'src/repo4')) | 428 ('repo_4@2', 'src/repo4')) |
| 429 tree['src/git_hooked2'] = 'git_hooked2' | 429 tree['src/git_hooked2'] = 'git_hooked2' |
| 430 self.assertTree(tree) | 430 self.assertTree(tree) |
| 431 # Test incremental sync: delete-unversioned_trees isn't there. | 431 # Test incremental sync: delete-unversioned_trees isn't there. |
| 432 results = self.gclient(['sync', '--deps', 'mac']) | 432 results = self.gclient(['sync', '--deps', 'mac']) |
| 433 # See comment above about parsing gclient's git output. | 433 # See comment above about parsing gclient's git output. |
| 434 self.assertEquals('', results[1]) | 434 self.assertEquals('', results[1]) |
| 435 self.assertEquals(0, results[2]) | 435 self.assertEquals(0, results[2]) |
| 436 tree = self.mangle_git_tree(('repo_1@2', 'src'), | 436 tree = self.mangle_git_tree(('repo_1@2', 'src'), |
| 437 ('repo_2@1', 'src/repo2'), | 437 ('repo_2@1', 'src/repo2'), |
| 438 ('repo_3@2', 'src/repo2/repo3'), | 438 ('repo_3@1', 'src/repo2/repo3'), |
| 439 ('repo_3@2', 'src/repo2/repo_renamed'), | 439 ('repo_3@2', 'src/repo2/repo_renamed'), |
| 440 ('repo_4@2', 'src/repo4')) | 440 ('repo_4@2', 'src/repo4')) |
| 441 tree['src/git_hooked1'] = 'git_hooked1' | 441 tree['src/git_hooked1'] = 'git_hooked1' |
| 442 tree['src/git_hooked2'] = 'git_hooked2' | 442 tree['src/git_hooked2'] = 'git_hooked2' |
| 443 self.assertTree(tree) | 443 self.assertTree(tree) |
| 444 | 444 |
| 445 def testSyncIgnoredSolutionName(self): | 445 def testSyncIgnoredSolutionName(self): |
| 446 """TODO(maruel): This will become an error soon.""" | 446 """TODO(maruel): This will become an error soon.""" |
| 447 if not self.enabled: | 447 if not self.enabled: |
| 448 return | 448 return |
| (...skipping 25 matching lines...) Expand all Loading... |
| 474 results = self.gclient(['sync', '--deps', 'mac', | 474 results = self.gclient(['sync', '--deps', 'mac', |
| 475 '--revision', self.githash('repo_1', 1)]) | 475 '--revision', self.githash('repo_1', 1)]) |
| 476 self.checkBlock(results[0], []) | 476 self.checkBlock(results[0], []) |
| 477 # TODO(maruel): git shouldn't output to stderr... | 477 # TODO(maruel): git shouldn't output to stderr... |
| 478 #self.checkString('Switched to a new branch \'%s\'\n' | 478 #self.checkString('Switched to a new branch \'%s\'\n' |
| 479 # % self.githash('repo_1', 1), results[1]) | 479 # % self.githash('repo_1', 1), results[1]) |
| 480 self.checkString('', results[1]) | 480 self.checkString('', results[1]) |
| 481 self.assertEquals(0, results[2]) | 481 self.assertEquals(0, results[2]) |
| 482 tree = self.mangle_git_tree(('repo_1@1', 'src'), | 482 tree = self.mangle_git_tree(('repo_1@1', 'src'), |
| 483 ('repo_2@2', 'src/repo2'), | 483 ('repo_2@2', 'src/repo2'), |
| 484 ('repo_3@2', 'src/repo2/repo3'), | 484 ('repo_3@1', 'src/repo2/repo3'), |
| 485 ('repo_4@2', 'src/repo4')) | 485 ('repo_4@2', 'src/repo4')) |
| 486 self.assertTree(tree) | 486 self.assertTree(tree) |
| 487 | 487 |
| 488 def testRevertAndStatus(self): | 488 def testRevertAndStatus(self): |
| 489 """TODO(maruel): Remove this line once this test is fixed.""" | 489 """TODO(maruel): Remove this line once this test is fixed.""" |
| 490 if not self.enabled: | 490 if not self.enabled: |
| 491 return | 491 return |
| 492 self.gclient(['config', self.git_base + 'repo_1', '--name', 'src']) | 492 self.gclient(['config', self.git_base + 'repo_1', '--name', 'src']) |
| 493 # Tested in testSync. | 493 # Tested in testSync. |
| 494 self.gclient(['sync', '--deps', 'mac']) | 494 self.gclient(['sync', '--deps', 'mac']) |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 615 '"url": "' + self.git_base + 'repo_1"}]']) | 615 '"url": "' + self.git_base + 'repo_1"}]']) |
| 616 results = self.gclient(['sync', '--deps', 'mac', '--revision', '1', | 616 results = self.gclient(['sync', '--deps', 'mac', '--revision', '1', |
| 617 '-r', 'src-git@' + self.githash('repo_1', 1)]) | 617 '-r', 'src-git@' + self.githash('repo_1', 1)]) |
| 618 self.checkBlock(results[0], ['running', 'running', 'running', 'running']) | 618 self.checkBlock(results[0], ['running', 'running', 'running', 'running']) |
| 619 # TODO(maruel): Something's wrong here. git outputs to stderr 'Switched to | 619 # TODO(maruel): Something's wrong here. git outputs to stderr 'Switched to |
| 620 # new branch \'hash\''. | 620 # new branch \'hash\''. |
| 621 #self.checkString('', results[1]) | 621 #self.checkString('', results[1]) |
| 622 self.assertEquals(0, results[2]) | 622 self.assertEquals(0, results[2]) |
| 623 tree = self.mangle_git_tree(('repo_1@1', 'src-git'), | 623 tree = self.mangle_git_tree(('repo_1@1', 'src-git'), |
| 624 ('repo_2@2', 'src/repo2'), | 624 ('repo_2@2', 'src/repo2'), |
| 625 ('repo_3@2', 'src/repo2/repo3'), | 625 ('repo_3@1', 'src/repo2/repo3'), |
| 626 ('repo_4@2', 'src/repo4')) | 626 ('repo_4@2', 'src/repo4')) |
| 627 tree.update(self.mangle_svn_tree( | 627 tree.update(self.mangle_svn_tree( |
| 628 ('trunk/src@1', 'src'), | 628 ('trunk/src@1', 'src'), |
| 629 ('trunk/third_party/foo@2', 'src/third_party/fpp'), | 629 ('trunk/third_party/foo@2', 'src/third_party/fpp'), |
| 630 ('trunk/other@2', 'src/other'), | 630 ('trunk/other@1', 'src/other'), |
| 631 ('trunk/third_party/foo@2', 'src/third_party/prout'))) | 631 ('trunk/third_party/foo@2', 'src/third_party/prout'))) |
| 632 self.assertTree(tree) | 632 self.assertTree(tree) |
| 633 | 633 |
| 634 | 634 |
| 635 if __name__ == '__main__': | 635 if __name__ == '__main__': |
| 636 if '-c' in sys.argv: | 636 if '-c' in sys.argv: |
| 637 COVERAGE = True | 637 COVERAGE = True |
| 638 sys.argv.remove('-c') | 638 sys.argv.remove('-c') |
| 639 if os.path.exists('.coverage'): | 639 if os.path.exists('.coverage'): |
| 640 os.remove('.coverage') | 640 os.remove('.coverage') |
| 641 os.environ['COVERAGE_FILE'] = os.path.join( | 641 os.environ['COVERAGE_FILE'] = os.path.join( |
| 642 os.path.dirname(os.path.dirname(os.path.abspath(__file__))), | 642 os.path.dirname(os.path.dirname(os.path.abspath(__file__))), |
| 643 '.coverage') | 643 '.coverage') |
| 644 unittest.main() | 644 unittest.main() |
| OLD | NEW |