Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: tests/gclient_smoketest.py

Issue 13814012: Changed the behaviour of '--transitive' in gclient.py to use revision instead of timestamp for iden… (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« testing_support/fake_repos.py ('K') | « testing_support/fake_repos.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 # TODO(maruel): safesync.
M-A Ruel 2013/04/17 14:54:09 Na, I disown this TODO.
kustermann 2013/04/18 08:28:40 Well, it was there in the old code as well. But I
778 if not self.enabled:
779 return
780
781 self.gclient(['config', self.svn_base + 'trunk/src/'])
782
783 def test_case(parent, timestamp, fixed, output):
784 # We check out revision 'parent' and expect the following:
785 # - src/ is checked out at r'parent'
786 # - src/same_repo is checked out at r'parent' (due to --transitive)
787 # - src/same_repo_fixed is checked out at r'fixed'
788 # - src/different_repo is checked out at r'timestamp'
789 # (due to --transitive)
790 # - src/different_repo_fixed is checked out at r'fixed'
791
792 revisions = self.FAKE_REPOS.svn_revs
793 self.parseGclient(
794 ['sync', '--transitive', '--revision', 'src@%d' % parent,
795 '--jobs', '1'], output)
796 self.assertTree({
797 'src/origin': revisions[parent]['trunk/src/origin'],
798 'src/DEPS': revisions[parent]['trunk/src/DEPS'],
799 'src/same_repo/origin': revisions[parent]['trunk/third_party/origin'],
800 'src/same_repo_fixed/origin':
801 revisions[fixed]['trunk/third_party/origin'],
802 'src/different_repo/origin':
803 revisions[timestamp]['trunk/third_party/origin'],
804 'src/different_repo_fixed/origin':
805 revisions[fixed]['trunk/third_party/origin'],
806 })
807
808 # Here are the test cases for checking out 'trunk/src' at r1, r2 and r3
809 # r1: Everything is normal
810 test_case(parent=1, timestamp=1, fixed=1,
811 output=['running', 'running', 'running', 'running', 'running'])
812 # r2: Svn will scan from r1 upwards until it finds a revision matching the
813 # given timestamp or it takes the next smallest one (which is r2 in this
814 # case).
815 test_case(parent=2, timestamp=2, fixed=1,
816 output=['running', 'running', 'running'])
817 # r3: Svn will scan from r1 upwards until it finds a revision matching the
818 # given timestamp or it takes the next smallest one. Since
819 # timestamp(r3) < timestamp(r2) svn will checkout r1.
M-A Ruel 2013/04/17 14:54:09 Add a note about why this could happen: # This can
ricow1 2013/04/18 07:11:30 Probably: # This happens all the time on http://go
kustermann 2013/04/18 08:28:40 Done.
820 test_case(parent=3, timestamp=1, fixed=1,
821 output=['running', 'running', 'running'])
822
823
804 class GClientSmokeGIT(GClientSmokeBase): 824 class GClientSmokeGIT(GClientSmokeBase):
805 def setUp(self): 825 def setUp(self):
806 super(GClientSmokeGIT, self).setUp() 826 super(GClientSmokeGIT, self).setUp()
807 self.enabled = self.FAKE_REPOS.set_up_git() 827 self.enabled = self.FAKE_REPOS.set_up_git()
808 828
809 def testSync(self): 829 def testSync(self):
810 if not self.enabled: 830 if not self.enabled:
811 return 831 return
812 # TODO(maruel): safesync. 832 # TODO(maruel): safesync.
813 self.gclient(['config', self.git_base + 'repo_1', '--name', 'src']) 833 self.gclient(['config', self.git_base + 'repo_1', '--name', 'src'])
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after
1298 1318
1299 if '-c' in sys.argv: 1319 if '-c' in sys.argv:
1300 COVERAGE = True 1320 COVERAGE = True
1301 sys.argv.remove('-c') 1321 sys.argv.remove('-c')
1302 if os.path.exists('.coverage'): 1322 if os.path.exists('.coverage'):
1303 os.remove('.coverage') 1323 os.remove('.coverage')
1304 os.environ['COVERAGE_FILE'] = os.path.join( 1324 os.environ['COVERAGE_FILE'] = os.path.join(
1305 os.path.dirname(os.path.dirname(os.path.abspath(__file__))), 1325 os.path.dirname(os.path.dirname(os.path.abspath(__file__))),
1306 '.coverage') 1326 '.coverage')
1307 unittest.main() 1327 unittest.main()
OLDNEW
« testing_support/fake_repos.py ('K') | « testing_support/fake_repos.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698