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

Side by Side Diff: tests/gclient_smoketest.py

Issue 141633005: Revert of If the destination directory doesn't contain the desired repo, delete it (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Created 6 years, 11 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
« no previous file with comments | « tests/gclient_scm_test.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 socket
17 import subprocess 16 import subprocess
18 import sys 17 import sys
19 import unittest 18 import unittest
20 19
21 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__)))
22 sys.path.insert(0, ROOT_DIR) 21 sys.path.insert(0, ROOT_DIR)
23 22
24 from testing_support.fake_repos import join, write 23 from testing_support.fake_repos import join, write
25 from testing_support.fake_repos import FakeReposTestBase, FakeRepoTransitive 24 from testing_support.fake_repos import FakeReposTestBase, FakeRepoTransitive
26 25
(...skipping 743 matching lines...) Expand 10 before | Expand all | Expand 10 after
770 return 769 return
771 self.gclient(['config', self.svn_base + 'trunk/src/']) 770 self.gclient(['config', self.svn_base + 'trunk/src/'])
772 cmd = ['sync', '--jobs', '1', '--delete_unversioned_trees', '--reset'] 771 cmd = ['sync', '--jobs', '1', '--delete_unversioned_trees', '--reset']
773 self.assertEquals(0, self.gclient(cmd)[-1]) 772 self.assertEquals(0, self.gclient(cmd)[-1])
774 third_party = join(self.root_dir, 'src', 'third_party') 773 third_party = join(self.root_dir, 'src', 'third_party')
775 subprocess2.check_call(['svn', 'propset', '-q', 'svn:ignore', 'foo', '.'], 774 subprocess2.check_call(['svn', 'propset', '-q', 'svn:ignore', 'foo', '.'],
776 cwd=third_party) 775 cwd=third_party)
777 776
778 # Cripple src/third_party/foo and make sure gclient still succeeds. 777 # Cripple src/third_party/foo and make sure gclient still succeeds.
779 gclient_utils.rmtree(join(third_party, 'foo', '.svn')) 778 gclient_utils.rmtree(join(third_party, 'foo', '.svn'))
780 self.assertEquals(0, self.gclient(cmd + ['--force'])[-1]) 779 self.assertEquals(0, self.gclient(cmd)[-1])
781 780
782 781
783 class GClientSmokeSVNTransitive(GClientSmokeBase): 782 class GClientSmokeSVNTransitive(GClientSmokeBase):
784 FAKE_REPOS_CLASS = FakeRepoTransitive 783 FAKE_REPOS_CLASS = FakeRepoTransitive
785 784
786 def setUp(self): 785 def setUp(self):
787 super(GClientSmokeSVNTransitive, self).setUp() 786 super(GClientSmokeSVNTransitive, self).setUp()
788 self.enabled = self.FAKE_REPOS.set_up_svn() 787 self.enabled = self.FAKE_REPOS.set_up_svn()
789 788
790 def testSyncTransitive(self): 789 def testSyncTransitive(self):
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
1097 1096
1098 # Pre-DEPS hooks don't run with runhooks. 1097 # Pre-DEPS hooks don't run with runhooks.
1099 self.gclient(['runhooks', '--deps', 'mac']) 1098 self.gclient(['runhooks', '--deps', 'mac'])
1100 tree = self.mangle_git_tree(('repo_5@2', 'src'), 1099 tree = self.mangle_git_tree(('repo_5@2', 'src'),
1101 ('repo_1@2', 'src/repo1'), 1100 ('repo_1@2', 'src/repo1'),
1102 ('repo_2@1', 'src/repo2') 1101 ('repo_2@1', 'src/repo2')
1103 ) 1102 )
1104 self.assertTree(tree) 1103 self.assertTree(tree)
1105 1104
1106 # Pre-DEPS hooks run when syncing with --nohooks. 1105 # Pre-DEPS hooks run when syncing with --nohooks.
1107 self.gclient(['sync', '--deps', 'mac', '--nohooks', '--force', 1106 self.gclient(['sync', '--deps', 'mac', '--nohooks',
1108 '--revision', 'src@' + self.githash('repo_5', 2)]) 1107 '--revision', 'src@' + self.githash('repo_5', 2)])
1109 tree = self.mangle_git_tree(('repo_5@2', 'src'), 1108 tree = self.mangle_git_tree(('repo_5@2', 'src'),
1110 ('repo_1@2', 'src/repo1'), 1109 ('repo_1@2', 'src/repo1'),
1111 ('repo_2@1', 'src/repo2') 1110 ('repo_2@1', 'src/repo2')
1112 ) 1111 )
1113 tree['src/git_pre_deps_hooked'] = 'git_pre_deps_hooked' 1112 tree['src/git_pre_deps_hooked'] = 'git_pre_deps_hooked'
1114 self.assertTree(tree) 1113 self.assertTree(tree)
1115 1114
1116 os.remove(join(self.root_dir, 'src', 'git_pre_deps_hooked')) 1115 os.remove(join(self.root_dir, 'src', 'git_pre_deps_hooked'))
1117 1116
1118 # Pre-DEPS hooks don't run with --noprehooks 1117 # Pre-DEPS hooks don't run with --noprehooks
1119 self.gclient(['sync', '--deps', 'mac', '--noprehooks', '--force', 1118 self.gclient(['sync', '--deps', 'mac', '--noprehooks',
1120 '--revision', 'src@' + self.githash('repo_5', 2)]) 1119 '--revision', 'src@' + self.githash('repo_5', 2)])
1121 tree = self.mangle_git_tree(('repo_5@2', 'src'), 1120 tree = self.mangle_git_tree(('repo_5@2', 'src'),
1122 ('repo_1@2', 'src/repo1'), 1121 ('repo_1@2', 'src/repo1'),
1123 ('repo_2@1', 'src/repo2') 1122 ('repo_2@1', 'src/repo2')
1124 ) 1123 )
1125 self.assertTree(tree) 1124 self.assertTree(tree)
1126 1125
1127 def testPreDepsHooksError(self): 1126 def testPreDepsHooksError(self):
1128 if not self.enabled: 1127 if not self.enabled:
1129 return 1128 return
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
1337 ('svn', 'trunk/other', 'src/other'), 1336 ('svn', 'trunk/other', 'src/other'),
1338 ('git', 'repo_2@' + self.githash('repo_2', 1)[:7], 'src/repo2'), 1337 ('git', 'repo_2@' + self.githash('repo_2', 1)[:7], 'src/repo2'),
1339 ('git', 'repo_3', 'src/repo2/repo_renamed'), 1338 ('git', 'repo_3', 'src/repo2/repo_renamed'),
1340 ('svn', 'trunk/third_party/foo@1', 'src/third_party/foo'), 1339 ('svn', 'trunk/third_party/foo@1', 'src/third_party/foo'),
1341 ] 1340 ]
1342 expected = [(scm, bases[scm] + url, os.path.join(self.root_dir, path)) 1341 expected = [(scm, bases[scm] + url, os.path.join(self.root_dir, path))
1343 for (scm, url, path) in expected_source] 1342 for (scm, url, path) in expected_source]
1344 1343
1345 self.assertEquals(sorted(entries), sorted(expected)) 1344 self.assertEquals(sorted(entries), sorted(expected))
1346 1345
1347 # TODO(borenet): Enable this at the same time that the guard is removed in
1348 # gclient.
1349 if (os.environ.get('CHROME_HEADLESS') and
1350 socket.gethostname() in ('vm859-m1', 'build1-m1', 'vm630-m1')):
1351 def testDeleteConflictingCheckout(self):
1352 if not self.enabled:
1353 return
1354
1355 # Create an initial svn checkout.
1356 self.gclient(['config', '--spec',
1357 'solutions=['
1358 '{"name": "src",'
1359 ' "url": "' + self.svn_base + 'trunk/src"},'
1360 ']'
1361 ])
1362 results = self.gclient(['sync', '--deps', 'mac'])
1363 self.assertEqual(results[2], 0, 'Sync failed!')
1364
1365 # Verify that we have the expected svn checkout.
1366 results = self.gclient(['revinfo', '--deps', 'mac'])
1367 actual = results[0].splitlines()
1368 expected = [
1369 'src: %strunk/src' % self.svn_base,
1370 'src/file/other: File("%strunk/other/DEPS")' % self.svn_base,
1371 'src/other: %strunk/other' % self.svn_base,
1372 'src/third_party/foo: %strunk/third_party/foo@1' % self.svn_base,
1373 ]
1374 self.assertEquals(actual, expected)
1375
1376 # Change the desired checkout to git.
1377 self.gclient(['config', '--spec',
1378 'solutions=['
1379 '{"name": "src",'
1380 ' "url": "' + self.git_base + 'repo_1"},'
1381 ']'
1382 ])
1383
1384 # Verify that the sync succeeds with --force.
1385 results = self.gclient(['sync', '--deps', 'mac', '--force'])
1386 self.assertEqual(results[2], 0, 'Sync failed!')
1387
1388 # Verify that we got the desired git checkout.
1389 results = self.gclient(['revinfo', '--deps', 'mac'])
1390 actual = results[0].splitlines()
1391 expected = [
1392 'src: %srepo_1' % self.git_base,
1393 'src/repo2: %srepo_2@%s' % (self.git_base,
1394 self.githash('repo_2', 1)[:7]),
1395 'src/repo2/repo_renamed: %srepo_3' % self.git_base,
1396 ]
1397 self.assertEquals(actual, expected)
1398
1399 # Change the desired checkout back to svn.
1400 self.gclient(['config', '--spec',
1401 'solutions=['
1402 '{"name": "src",'
1403 ' "url": "' + self.svn_base + 'trunk/src"},'
1404 ']'
1405 ])
1406
1407 # Verify that the sync succeeds.
1408 results = self.gclient(['sync', '--deps', 'mac', '--force'])
1409 self.assertEqual(results[2], 0, 'Sync failed!')
1410
1411 # Verify that we have the expected svn checkout.
1412 results = self.gclient(['revinfo', '--deps', 'mac'])
1413 actual = results[0].splitlines()
1414 expected = [
1415 'src: %strunk/src' % self.svn_base,
1416 'src/file/other: File("%strunk/other/DEPS")' % self.svn_base,
1417 'src/other: %strunk/other' % self.svn_base,
1418 'src/third_party/foo: %strunk/third_party/foo@1' % self.svn_base,
1419 ]
1420 self.assertEquals(actual, expected)
1421
1422 1346
1423 class GClientSmokeFromCheckout(GClientSmokeBase): 1347 class GClientSmokeFromCheckout(GClientSmokeBase):
1424 # WebKit abuses this. It has a .gclient and a DEPS from a checkout. 1348 # WebKit abuses this. It has a .gclient and a DEPS from a checkout.
1425 def setUp(self): 1349 def setUp(self):
1426 super(GClientSmokeFromCheckout, self).setUp() 1350 super(GClientSmokeFromCheckout, self).setUp()
1427 self.enabled = self.FAKE_REPOS.set_up_svn() 1351 self.enabled = self.FAKE_REPOS.set_up_svn()
1428 os.rmdir(self.root_dir) 1352 os.rmdir(self.root_dir)
1429 if self.enabled: 1353 if self.enabled:
1430 usr, pwd = self.FAKE_REPOS.USERS[0] 1354 usr, pwd = self.FAKE_REPOS.USERS[0]
1431 subprocess2.check_call( 1355 subprocess2.check_call(
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
1520 1444
1521 if '-c' in sys.argv: 1445 if '-c' in sys.argv:
1522 COVERAGE = True 1446 COVERAGE = True
1523 sys.argv.remove('-c') 1447 sys.argv.remove('-c')
1524 if os.path.exists('.coverage'): 1448 if os.path.exists('.coverage'):
1525 os.remove('.coverage') 1449 os.remove('.coverage')
1526 os.environ['COVERAGE_FILE'] = os.path.join( 1450 os.environ['COVERAGE_FILE'] = os.path.join(
1527 os.path.dirname(os.path.dirname(os.path.abspath(__file__))), 1451 os.path.dirname(os.path.dirname(os.path.abspath(__file__))),
1528 '.coverage') 1452 '.coverage')
1529 unittest.main() 1453 unittest.main()
OLDNEW
« no previous file with comments | « tests/gclient_scm_test.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698