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

Side by Side Diff: tests/gclient_smoketest.py

Issue 6621013: Clean gclient_smoketest import and call of super class. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Created 9 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | 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/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.
11 """ 11 """
12 12
13 # pylint: disable=E1103,W0403 13 # pylint: disable=E1103,W0403
14 14
15 import logging 15 import logging
16 import os 16 import os
17 import re 17 import re
18 import subprocess 18 import subprocess
19 import sys 19 import sys
20 import unittest 20 import unittest
21 21
22 from fake_repos import check_call, join, write, FakeReposTestBase 22 ROOT_DIR = os.path.dirname(os.path.abspath(__file__))
23 sys.path.insert(0, os.path.dirname(ROOT_DIR))
24 from tests.fake_repos import check_call, join, write, FakeReposTestBase
23 25
24 GCLIENT_PATH = join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), 26 GCLIENT_PATH = os.path.join(os.path.dirname(ROOT_DIR), 'gclient')
25 'gclient')
26 COVERAGE = False 27 COVERAGE = False
27 28
28 29
29 class GClientSmokeBase(FakeReposTestBase): 30 class GClientSmokeBase(FakeReposTestBase):
30 def setUp(self): 31 def setUp(self):
31 FakeReposTestBase.setUp(self) 32 super(GClientSmokeBase, self).setUp()
32 # Make sure it doesn't try to auto update when testing! 33 # Make sure it doesn't try to auto update when testing!
33 self.env = os.environ.copy() 34 self.env = os.environ.copy()
34 self.env['DEPOT_TOOLS_UPDATE'] = '0' 35 self.env['DEPOT_TOOLS_UPDATE'] = '0'
35 36
36 def gclient(self, cmd, cwd=None): 37 def gclient(self, cmd, cwd=None):
37 if not cwd: 38 if not cwd:
38 cwd = self.root_dir 39 cwd = self.root_dir
39 if COVERAGE: 40 if COVERAGE:
40 # Don't use the wrapper script. 41 # Don't use the wrapper script.
41 cmd_base = ['coverage', 'run', '-a', GCLIENT_PATH + '.py'] 42 cmd_base = ['coverage', 'run', '-a', GCLIENT_PATH + '.py']
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 write(join(deps, 'DEPS'), 249 write(join(deps, 'DEPS'),
249 'deps = { "src": "%strunk/src" }' % (self.svn_base)) 250 'deps = { "src": "%strunk/src" }' % (self.svn_base))
250 src = join(self.root_dir, 'src') 251 src = join(self.root_dir, 'src')
251 os.mkdir(src) 252 os.mkdir(src)
252 res = self.gclient(['status', '--jobs', '1'], src) 253 res = self.gclient(['status', '--jobs', '1'], src)
253 self.checkBlock(res[0], [('running', deps), ('running', src)]) 254 self.checkBlock(res[0], [('running', deps), ('running', src)])
254 255
255 256
256 class GClientSmokeSVN(GClientSmokeBase): 257 class GClientSmokeSVN(GClientSmokeBase):
257 def setUp(self): 258 def setUp(self):
258 GClientSmokeBase.setUp(self) 259 super(GClientSmokeSVN, self).setUp()
259 self.enabled = self.FAKE_REPOS.setUpSVN() 260 self.enabled = self.FAKE_REPOS.setUpSVN()
260 261
261 def testSync(self): 262 def testSync(self):
262 # TODO(maruel): safesync. 263 # TODO(maruel): safesync.
263 if not self.enabled: 264 if not self.enabled:
264 return 265 return
265 self.gclient(['config', self.svn_base + 'trunk/src/']) 266 self.gclient(['config', self.svn_base + 'trunk/src/'])
266 # Test unversioned checkout. 267 # Test unversioned checkout.
267 self.parseGclient(['sync', '--deps', 'mac', '--jobs', '1'], 268 self.parseGclient(['sync', '--deps', 'mac', '--jobs', '1'],
268 ['running', 'running', 269 ['running', 'running',
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after
681 # Cripple the checkout. 682 # Cripple the checkout.
682 os.remove(join(self.root_dir, '.gclient_entries')) 683 os.remove(join(self.root_dir, '.gclient_entries'))
683 src = join(self.root_dir, 'src') 684 src = join(self.root_dir, 'src')
684 res = self.gclient(['sync', '--jobs', '1'], src) 685 res = self.gclient(['sync', '--jobs', '1'], src)
685 self.checkBlock(res[0], 686 self.checkBlock(res[0],
686 ['running', 'running', 'running']) 687 ['running', 'running', 'running'])
687 688
688 689
689 class GClientSmokeGIT(GClientSmokeBase): 690 class GClientSmokeGIT(GClientSmokeBase):
690 def setUp(self): 691 def setUp(self):
691 GClientSmokeBase.setUp(self) 692 super(GClientSmokeGIT, self).setUp()
692 self.enabled = self.FAKE_REPOS.setUpGIT() 693 self.enabled = self.FAKE_REPOS.setUpGIT()
693 694
694 def testSync(self): 695 def testSync(self):
695 if not self.enabled: 696 if not self.enabled:
696 return 697 return
697 # TODO(maruel): safesync. 698 # TODO(maruel): safesync.
698 self.gclient(['config', self.git_base + 'repo_1', '--name', 'src']) 699 self.gclient(['config', self.git_base + 'repo_1', '--name', 'src'])
699 # Test unversioned checkout. 700 # Test unversioned checkout.
700 self.parseGclient(['sync', '--deps', 'mac', '--jobs', '1'], 701 self.parseGclient(['sync', '--deps', 'mac', '--jobs', '1'],
701 ['running', 'running', 'running', 'running', 'running']) 702 ['running', 'running', 'running', 'running', 'running'])
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
898 'base': self.git_base, 899 'base': self.git_base,
899 'hash1': self.githash('repo_1', 2), 900 'hash1': self.githash('repo_1', 2),
900 'hash2': self.githash('repo_2', 1), 901 'hash2': self.githash('repo_2', 1),
901 'hash3': self.githash('repo_3', 2), 902 'hash3': self.githash('repo_3', 2),
902 }) 903 })
903 self.check((out, '', 0), results) 904 self.check((out, '', 0), results)
904 905
905 906
906 class GClientSmokeBoth(GClientSmokeBase): 907 class GClientSmokeBoth(GClientSmokeBase):
907 def setUp(self): 908 def setUp(self):
908 GClientSmokeBase.setUp(self) 909 super(GClientSmokeBoth, self).setUp()
909 self.enabled = self.FAKE_REPOS.setUpSVN() and self.FAKE_REPOS.setUpGIT() 910 self.enabled = self.FAKE_REPOS.setUpSVN() and self.FAKE_REPOS.setUpGIT()
910 911
911 def testMultiSolutions(self): 912 def testMultiSolutions(self):
912 if not self.enabled: 913 if not self.enabled:
913 return 914 return
914 self.gclient(['config', '--spec', 915 self.gclient(['config', '--spec',
915 'solutions=[' 916 'solutions=['
916 '{"name": "src",' 917 '{"name": "src",'
917 ' "url": "' + self.svn_base + 'trunk/src/"},' 918 ' "url": "' + self.svn_base + 'trunk/src/"},'
918 '{"name": "src-git",' 919 '{"name": "src-git",'
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
1061 ] 1062 ]
1062 expected = [(scm, bases[scm] + url, os.path.join(self.root_dir, path)) 1063 expected = [(scm, bases[scm] + url, os.path.join(self.root_dir, path))
1063 for (scm, url, path) in expected_source] 1064 for (scm, url, path) in expected_source]
1064 1065
1065 self.assertEquals(sorted(entries), sorted(expected)) 1066 self.assertEquals(sorted(entries), sorted(expected))
1066 1067
1067 1068
1068 class GClientSmokeFromCheckout(GClientSmokeBase): 1069 class GClientSmokeFromCheckout(GClientSmokeBase):
1069 # WebKit abuses this. It has a .gclient and a DEPS from a checkout. 1070 # WebKit abuses this. It has a .gclient and a DEPS from a checkout.
1070 def setUp(self): 1071 def setUp(self):
1071 GClientSmokeBase.setUp(self) 1072 super(GClientSmokeFromCheckout, self).setUp()
1072 self.enabled = self.FAKE_REPOS.setUpSVN() 1073 self.enabled = self.FAKE_REPOS.setUpSVN()
1073 os.rmdir(self.root_dir) 1074 os.rmdir(self.root_dir)
1074 if self.enabled: 1075 if self.enabled:
1075 usr, pwd = self.FAKE_REPOS.USERS[0] 1076 usr, pwd = self.FAKE_REPOS.USERS[0]
1076 check_call( 1077 check_call(
1077 ['svn', 'checkout', 'svn://127.0.0.1/svn/trunk/webkit', 1078 ['svn', 'checkout', 'svn://127.0.0.1/svn/trunk/webkit',
1078 self.root_dir, '-q', 1079 self.root_dir, '-q',
1079 '--non-interactive', '--no-auth-cache', 1080 '--non-interactive', '--no-auth-cache',
1080 '--username', usr, '--password', pwd]) 1081 '--username', usr, '--password', pwd])
1081 1082
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
1153 # TODO(maruel): This is incorrect, it should run on ./ too. 1154 # TODO(maruel): This is incorrect, it should run on ./ too.
1154 self.parseGclient( 1155 self.parseGclient(
1155 ['cleanup', '--deps', 'mac', '--verbose', '--jobs', '1'], 1156 ['cleanup', '--deps', 'mac', '--verbose', '--jobs', '1'],
1156 [('running', join(self.root_dir, 'foo', 'bar'))]) 1157 [('running', join(self.root_dir, 'foo', 'bar'))])
1157 self.parseGclient( 1158 self.parseGclient(
1158 ['diff', '--deps', 'mac', '--verbose', '--jobs', '1'], 1159 ['diff', '--deps', 'mac', '--verbose', '--jobs', '1'],
1159 [('running', join(self.root_dir, 'foo', 'bar'))]) 1160 [('running', join(self.root_dir, 'foo', 'bar'))])
1160 1161
1161 1162
1162 if __name__ == '__main__': 1163 if __name__ == '__main__':
1164 if '-v' in sys.argv:
1165 logging.basicConfig(level=logging.DEBUG)
1166
1163 if '-c' in sys.argv: 1167 if '-c' in sys.argv:
1164 COVERAGE = True 1168 COVERAGE = True
1165 sys.argv.remove('-c') 1169 sys.argv.remove('-c')
1166 if os.path.exists('.coverage'): 1170 if os.path.exists('.coverage'):
1167 os.remove('.coverage') 1171 os.remove('.coverage')
1168 os.environ['COVERAGE_FILE'] = os.path.join( 1172 os.environ['COVERAGE_FILE'] = os.path.join(
1169 os.path.dirname(os.path.dirname(os.path.abspath(__file__))), 1173 os.path.dirname(os.path.dirname(os.path.abspath(__file__))),
1170 '.coverage') 1174 '.coverage')
1171 unittest.main() 1175 unittest.main()
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698