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 """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. |
11 """ | 11 """ |
12 | 12 |
13 import logging | 13 import logging |
14 import os | 14 import os |
15 import re | 15 import re |
16 import subprocess | 16 import subprocess |
17 import sys | 17 import sys |
18 import unittest | 18 import unittest |
19 | 19 |
20 ROOT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) | 20 ROOT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) |
21 sys.path.insert(0, ROOT_DIR) | 21 sys.path.insert(0, ROOT_DIR) |
22 | 22 |
23 from testing_support.fake_repos import join, write, FakeReposTestBase | 23 from testing_support.fake_repos import join, write |
| 24 from testing_support.fake_repos import FakeReposTestBase, FakeRepoTransitive |
| 25 |
24 import gclient_utils | 26 import gclient_utils |
25 | 27 |
26 import subprocess2 | 28 import subprocess2 |
27 | 29 |
28 GCLIENT_PATH = os.path.join(ROOT_DIR, 'gclient') | 30 GCLIENT_PATH = os.path.join(ROOT_DIR, 'gclient') |
29 COVERAGE = False | 31 COVERAGE = False |
30 | 32 |
31 | 33 |
32 class GClientSmokeBase(FakeReposTestBase): | 34 class GClientSmokeBase(FakeReposTestBase): |
33 def setUp(self): | 35 def setUp(self): |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
341 ('trunk/src@2', 'src'), | 343 ('trunk/src@2', 'src'), |
342 ('trunk/third_party/foo@2', 'src/third_party/fpp'), | 344 ('trunk/third_party/foo@2', 'src/third_party/fpp'), |
343 ('trunk/third_party/foo@1', 'src/third_party/foo'), | 345 ('trunk/third_party/foo@1', 'src/third_party/foo'), |
344 ('trunk/other@2', 'src/other'), | 346 ('trunk/other@2', 'src/other'), |
345 ('trunk/third_party/foo@2', 'src/third_party/prout')) | 347 ('trunk/third_party/foo@2', 'src/third_party/prout')) |
346 tree['src/file/other/DEPS'] = ( | 348 tree['src/file/other/DEPS'] = ( |
347 self.FAKE_REPOS.svn_revs[2]['trunk/other/DEPS']) | 349 self.FAKE_REPOS.svn_revs[2]['trunk/other/DEPS']) |
348 tree['src/svn_hooked1'] = 'svn_hooked1' | 350 tree['src/svn_hooked1'] = 'svn_hooked1' |
349 self.assertTree(tree) | 351 self.assertTree(tree) |
350 | 352 |
351 def testSyncTransitive(self): | |
352 # TODO(maruel): safesync. | |
353 if not self.enabled: | |
354 return | |
355 self.gclient(['config', self.svn_base + 'trunk/src/']) | |
356 | |
357 # Make sure we can populate a new repository with --transitive. | |
358 self.parseGclient( | |
359 ['sync', '--transitive', '--revision', 'src@1', '--deps', 'mac', | |
360 '--jobs', '1'], | |
361 ['running', 'running', 'running', 'running']) | |
362 tree = self.mangle_svn_tree( | |
363 ('trunk/src@1', 'src'), | |
364 ('trunk/third_party/foo@1', 'src/third_party/fpp'), | |
365 ('trunk/other@1', 'src/other'), | |
366 ('trunk/third_party/foo@1', 'src/third_party/prout')) | |
367 | |
368 # Get up to date, so we can test synching back. | |
369 self.gclient(['sync', '--deps', 'mac', '--jobs', '1']) | |
370 | |
371 # Manually remove svn_hooked1 before synching to make sure it's not | |
372 # recreated. | |
373 os.remove(join(self.root_dir, 'src', 'svn_hooked1')) | |
374 | |
375 self.parseGclient( | |
376 ['sync', '--transitive', '--revision', 'src@1', '--deps', 'mac', | |
377 '--delete_unversioned_trees', '--jobs', '1'], | |
378 ['running', 'running', 'running', 'running', 'deleting']) | |
379 tree = self.mangle_svn_tree( | |
380 ('trunk/src@1', 'src'), | |
381 ('trunk/third_party/foo@1', 'src/third_party/fpp'), | |
382 ('trunk/other@1', 'src/other'), | |
383 ('trunk/third_party/foo@1', 'src/third_party/prout')) | |
384 tree['src/file/other/DEPS'] = ( | |
385 self.FAKE_REPOS.svn_revs[2]['trunk/other/DEPS']) | |
386 self.assertTree(tree) | |
387 | |
388 def testSyncIgnoredSolutionName(self): | 353 def testSyncIgnoredSolutionName(self): |
389 """TODO(maruel): This will become an error soon.""" | 354 """TODO(maruel): This will become an error soon.""" |
390 if not self.enabled: | 355 if not self.enabled: |
391 return | 356 return |
392 self.gclient(['config', self.svn_base + 'trunk/src/']) | 357 self.gclient(['config', self.svn_base + 'trunk/src/']) |
393 results = self.gclient( | 358 results = self.gclient( |
394 ['sync', '--deps', 'mac', '-r', 'invalid@1', '--jobs', '1']) | 359 ['sync', '--deps', 'mac', '-r', 'invalid@1', '--jobs', '1']) |
395 self.checkBlock(results[0], [ | 360 self.checkBlock(results[0], [ |
396 'running', 'running', | 361 'running', 'running', |
397 # This is due to the way svn update is called for a single file when | 362 # This is due to the way svn update is called for a single file when |
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
794 self.assertEquals(0, self.gclient(cmd)[-1]) | 759 self.assertEquals(0, self.gclient(cmd)[-1]) |
795 third_party = join(self.root_dir, 'src', 'third_party') | 760 third_party = join(self.root_dir, 'src', 'third_party') |
796 subprocess2.check_call(['svn', 'propset', '-q', 'svn:ignore', 'foo', '.'], | 761 subprocess2.check_call(['svn', 'propset', '-q', 'svn:ignore', 'foo', '.'], |
797 cwd=third_party) | 762 cwd=third_party) |
798 | 763 |
799 # Cripple src/third_party/foo and make sure gclient still succeeds. | 764 # Cripple src/third_party/foo and make sure gclient still succeeds. |
800 gclient_utils.rmtree(join(third_party, 'foo', '.svn')) | 765 gclient_utils.rmtree(join(third_party, 'foo', '.svn')) |
801 self.assertEquals(0, self.gclient(cmd)[-1]) | 766 self.assertEquals(0, self.gclient(cmd)[-1]) |
802 | 767 |
803 | 768 |
| 769 class GClientSmokeSVNTransitive(GClientSmokeBase): |
| 770 FAKE_REPOS_CLASS = FakeRepoTransitive |
| 771 |
| 772 def setUp(self): |
| 773 super(GClientSmokeSVNTransitive, self).setUp() |
| 774 self.enabled = self.FAKE_REPOS.set_up_svn() |
| 775 |
| 776 def testSyncTransitive(self): |
| 777 if not self.enabled: |
| 778 return |
| 779 |
| 780 self.gclient(['config', self.svn_base + 'trunk/src/']) |
| 781 |
| 782 def test_case(parent, timestamp, fixed, output): |
| 783 # We check out revision 'parent' and expect the following: |
| 784 # - src/ is checked out at r'parent' |
| 785 # - src/same_repo is checked out at r'parent' (due to --transitive) |
| 786 # - src/same_repo_fixed is checked out at r'fixed' |
| 787 # - src/different_repo is checked out at r'timestamp' |
| 788 # (due to --transitive) |
| 789 # - src/different_repo_fixed is checked out at r'fixed' |
| 790 |
| 791 revisions = self.FAKE_REPOS.svn_revs |
| 792 self.parseGclient( |
| 793 ['sync', '--transitive', '--revision', 'src@%d' % parent, |
| 794 '--jobs', '1'], output) |
| 795 self.assertTree({ |
| 796 'src/origin': revisions[parent]['trunk/src/origin'], |
| 797 'src/DEPS': revisions[parent]['trunk/src/DEPS'], |
| 798 'src/same_repo/origin': revisions[parent]['trunk/third_party/origin'], |
| 799 'src/same_repo_fixed/origin': |
| 800 revisions[fixed]['trunk/third_party/origin'], |
| 801 'src/different_repo/origin': |
| 802 revisions[timestamp]['trunk/third_party/origin'], |
| 803 'src/different_repo_fixed/origin': |
| 804 revisions[fixed]['trunk/third_party/origin'], |
| 805 }) |
| 806 |
| 807 # Here are the test cases for checking out 'trunk/src' at r1, r2 and r3 |
| 808 # r1: Everything is normal |
| 809 test_case(parent=1, timestamp=1, fixed=1, |
| 810 output=['running', 'running', 'running', 'running', 'running']) |
| 811 # r2: Svn will scan from r1 upwards until it finds a revision matching the |
| 812 # given timestamp or it takes the next smallest one (which is r2 in this |
| 813 # case). |
| 814 test_case(parent=2, timestamp=2, fixed=1, |
| 815 output=['running', 'running', 'running']) |
| 816 # r3: Svn will scan from r1 upwards until it finds a revision matching the |
| 817 # given timestamp or it takes the next smallest one. Since |
| 818 # timestamp(r3) < timestamp(r2) svn will checkout r1. |
| 819 # This happens often on http://googlecode.com but is unexpected to happen |
| 820 # with svnserve (unless you manually change 'svn:date') |
| 821 test_case(parent=3, timestamp=1, fixed=1, |
| 822 output=['running', 'running', 'running']) |
| 823 |
| 824 |
804 class GClientSmokeGIT(GClientSmokeBase): | 825 class GClientSmokeGIT(GClientSmokeBase): |
805 def setUp(self): | 826 def setUp(self): |
806 super(GClientSmokeGIT, self).setUp() | 827 super(GClientSmokeGIT, self).setUp() |
807 self.enabled = self.FAKE_REPOS.set_up_git() | 828 self.enabled = self.FAKE_REPOS.set_up_git() |
808 | 829 |
809 def testSync(self): | 830 def testSync(self): |
810 if not self.enabled: | 831 if not self.enabled: |
811 return | 832 return |
812 # TODO(maruel): safesync. | 833 # TODO(maruel): safesync. |
813 self.gclient(['config', self.git_base + 'repo_1', '--name', 'src']) | 834 self.gclient(['config', self.git_base + 'repo_1', '--name', 'src']) |
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1298 | 1319 |
1299 if '-c' in sys.argv: | 1320 if '-c' in sys.argv: |
1300 COVERAGE = True | 1321 COVERAGE = True |
1301 sys.argv.remove('-c') | 1322 sys.argv.remove('-c') |
1302 if os.path.exists('.coverage'): | 1323 if os.path.exists('.coverage'): |
1303 os.remove('.coverage') | 1324 os.remove('.coverage') |
1304 os.environ['COVERAGE_FILE'] = os.path.join( | 1325 os.environ['COVERAGE_FILE'] = os.path.join( |
1305 os.path.dirname(os.path.dirname(os.path.abspath(__file__))), | 1326 os.path.dirname(os.path.dirname(os.path.abspath(__file__))), |
1306 '.coverage') | 1327 '.coverage') |
1307 unittest.main() | 1328 unittest.main() |
OLD | NEW |