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

Side by Side Diff: tests/gclient_smoketest.py

Issue 61623008: 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: Fix line length 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
16 import subprocess 17 import subprocess
17 import sys 18 import sys
18 import unittest 19 import unittest
19 20
20 ROOT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) 21 ROOT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
21 sys.path.insert(0, ROOT_DIR) 22 sys.path.insert(0, ROOT_DIR)
22 23
23 from testing_support.fake_repos import join, write 24 from testing_support.fake_repos import join, write
24 from testing_support.fake_repos import FakeReposTestBase, FakeRepoTransitive 25 from testing_support.fake_repos import FakeReposTestBase, FakeRepoTransitive
25 26
(...skipping 743 matching lines...) Expand 10 before | Expand all | Expand 10 after
769 return 770 return
770 self.gclient(['config', self.svn_base + 'trunk/src/']) 771 self.gclient(['config', self.svn_base + 'trunk/src/'])
771 cmd = ['sync', '--jobs', '1', '--delete_unversioned_trees', '--reset'] 772 cmd = ['sync', '--jobs', '1', '--delete_unversioned_trees', '--reset']
772 self.assertEquals(0, self.gclient(cmd)[-1]) 773 self.assertEquals(0, self.gclient(cmd)[-1])
773 third_party = join(self.root_dir, 'src', 'third_party') 774 third_party = join(self.root_dir, 'src', 'third_party')
774 subprocess2.check_call(['svn', 'propset', '-q', 'svn:ignore', 'foo', '.'], 775 subprocess2.check_call(['svn', 'propset', '-q', 'svn:ignore', 'foo', '.'],
775 cwd=third_party) 776 cwd=third_party)
776 777
777 # Cripple src/third_party/foo and make sure gclient still succeeds. 778 # Cripple src/third_party/foo and make sure gclient still succeeds.
778 gclient_utils.rmtree(join(third_party, 'foo', '.svn')) 779 gclient_utils.rmtree(join(third_party, 'foo', '.svn'))
779 self.assertEquals(0, self.gclient(cmd)[-1]) 780 self.assertEquals(0, self.gclient(cmd + ['--force'])[-1])
780 781
781 782
782 class GClientSmokeSVNTransitive(GClientSmokeBase): 783 class GClientSmokeSVNTransitive(GClientSmokeBase):
783 FAKE_REPOS_CLASS = FakeRepoTransitive 784 FAKE_REPOS_CLASS = FakeRepoTransitive
784 785
785 def setUp(self): 786 def setUp(self):
786 super(GClientSmokeSVNTransitive, self).setUp() 787 super(GClientSmokeSVNTransitive, self).setUp()
787 self.enabled = self.FAKE_REPOS.set_up_svn() 788 self.enabled = self.FAKE_REPOS.set_up_svn()
788 789
789 def testSyncTransitive(self): 790 def testSyncTransitive(self):
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
1096 1097
1097 # Pre-DEPS hooks don't run with runhooks. 1098 # Pre-DEPS hooks don't run with runhooks.
1098 self.gclient(['runhooks', '--deps', 'mac']) 1099 self.gclient(['runhooks', '--deps', 'mac'])
1099 tree = self.mangle_git_tree(('repo_5@2', 'src'), 1100 tree = self.mangle_git_tree(('repo_5@2', 'src'),
1100 ('repo_1@2', 'src/repo1'), 1101 ('repo_1@2', 'src/repo1'),
1101 ('repo_2@1', 'src/repo2') 1102 ('repo_2@1', 'src/repo2')
1102 ) 1103 )
1103 self.assertTree(tree) 1104 self.assertTree(tree)
1104 1105
1105 # Pre-DEPS hooks run when syncing with --nohooks. 1106 # Pre-DEPS hooks run when syncing with --nohooks.
1106 self.gclient(['sync', '--deps', 'mac', '--nohooks', 1107 self.gclient(['sync', '--deps', 'mac', '--nohooks', '--force',
1107 '--revision', 'src@' + self.githash('repo_5', 2)]) 1108 '--revision', 'src@' + self.githash('repo_5', 2)])
1108 tree = self.mangle_git_tree(('repo_5@2', 'src'), 1109 tree = self.mangle_git_tree(('repo_5@2', 'src'),
1109 ('repo_1@2', 'src/repo1'), 1110 ('repo_1@2', 'src/repo1'),
1110 ('repo_2@1', 'src/repo2') 1111 ('repo_2@1', 'src/repo2')
1111 ) 1112 )
1112 tree['src/git_pre_deps_hooked'] = 'git_pre_deps_hooked' 1113 tree['src/git_pre_deps_hooked'] = 'git_pre_deps_hooked'
1113 self.assertTree(tree) 1114 self.assertTree(tree)
1114 1115
1115 os.remove(join(self.root_dir, 'src', 'git_pre_deps_hooked')) 1116 os.remove(join(self.root_dir, 'src', 'git_pre_deps_hooked'))
1116 1117
1117 # Pre-DEPS hooks don't run with --noprehooks 1118 # Pre-DEPS hooks don't run with --noprehooks
1118 self.gclient(['sync', '--deps', 'mac', '--noprehooks', 1119 self.gclient(['sync', '--deps', 'mac', '--noprehooks', '--force',
1119 '--revision', 'src@' + self.githash('repo_5', 2)]) 1120 '--revision', 'src@' + self.githash('repo_5', 2)])
1120 tree = self.mangle_git_tree(('repo_5@2', 'src'), 1121 tree = self.mangle_git_tree(('repo_5@2', 'src'),
1121 ('repo_1@2', 'src/repo1'), 1122 ('repo_1@2', 'src/repo1'),
1122 ('repo_2@1', 'src/repo2') 1123 ('repo_2@1', 'src/repo2')
1123 ) 1124 )
1124 self.assertTree(tree) 1125 self.assertTree(tree)
1125 1126
1126 def testPreDepsHooksError(self): 1127 def testPreDepsHooksError(self):
1127 if not self.enabled: 1128 if not self.enabled:
1128 return 1129 return
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
1336 ('svn', 'trunk/other', 'src/other'), 1337 ('svn', 'trunk/other', 'src/other'),
1337 ('git', 'repo_2@' + self.githash('repo_2', 1)[:7], 'src/repo2'), 1338 ('git', 'repo_2@' + self.githash('repo_2', 1)[:7], 'src/repo2'),
1338 ('git', 'repo_3', 'src/repo2/repo_renamed'), 1339 ('git', 'repo_3', 'src/repo2/repo_renamed'),
1339 ('svn', 'trunk/third_party/foo@1', 'src/third_party/foo'), 1340 ('svn', 'trunk/third_party/foo@1', 'src/third_party/foo'),
1340 ] 1341 ]
1341 expected = [(scm, bases[scm] + url, os.path.join(self.root_dir, path)) 1342 expected = [(scm, bases[scm] + url, os.path.join(self.root_dir, path))
1342 for (scm, url, path) in expected_source] 1343 for (scm, url, path) in expected_source]
1343 1344
1344 self.assertEquals(sorted(entries), sorted(expected)) 1345 self.assertEquals(sorted(entries), sorted(expected))
1345 1346
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
1346 1422
1347 class GClientSmokeFromCheckout(GClientSmokeBase): 1423 class GClientSmokeFromCheckout(GClientSmokeBase):
1348 # WebKit abuses this. It has a .gclient and a DEPS from a checkout. 1424 # WebKit abuses this. It has a .gclient and a DEPS from a checkout.
1349 def setUp(self): 1425 def setUp(self):
1350 super(GClientSmokeFromCheckout, self).setUp() 1426 super(GClientSmokeFromCheckout, self).setUp()
1351 self.enabled = self.FAKE_REPOS.set_up_svn() 1427 self.enabled = self.FAKE_REPOS.set_up_svn()
1352 os.rmdir(self.root_dir) 1428 os.rmdir(self.root_dir)
1353 if self.enabled: 1429 if self.enabled:
1354 usr, pwd = self.FAKE_REPOS.USERS[0] 1430 usr, pwd = self.FAKE_REPOS.USERS[0]
1355 subprocess2.check_call( 1431 subprocess2.check_call(
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
1444 1520
1445 if '-c' in sys.argv: 1521 if '-c' in sys.argv:
1446 COVERAGE = True 1522 COVERAGE = True
1447 sys.argv.remove('-c') 1523 sys.argv.remove('-c')
1448 if os.path.exists('.coverage'): 1524 if os.path.exists('.coverage'):
1449 os.remove('.coverage') 1525 os.remove('.coverage')
1450 os.environ['COVERAGE_FILE'] = os.path.join( 1526 os.environ['COVERAGE_FILE'] = os.path.join(
1451 os.path.dirname(os.path.dirname(os.path.abspath(__file__))), 1527 os.path.dirname(os.path.dirname(os.path.abspath(__file__))),
1452 '.coverage') 1528 '.coverage')
1453 unittest.main() 1529 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