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

Side by Side Diff: tests/gclient_test.py

Issue 7982005: Move dependencies to a locked property. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Not using locks yet since it's having issues Created 9 years, 2 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 | « gclient.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) 2011 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2011 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 """Unit tests for gclient.py. 6 """Unit tests for gclient.py.
7 7
8 See gclient_smoketest.py for integration tests. 8 See gclient_smoketest.py for integration tests.
9 """ 9 """
10 10
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 ' "foo/dir1/dir2": "/dir1/another",\n' 127 ' "foo/dir1/dir2": "/dir1/another",\n'
128 '}') 128 '}')
129 129
130 obj = gclient.GClient.LoadCurrentConfig(options) 130 obj = gclient.GClient.LoadCurrentConfig(options)
131 self._check_requirements(obj.dependencies[0], {}) 131 self._check_requirements(obj.dependencies[0], {})
132 self._check_requirements(obj.dependencies[1], {}) 132 self._check_requirements(obj.dependencies[1], {})
133 obj.RunOnDeps('None', args) 133 obj.RunOnDeps('None', args)
134 # The trick here is to manually process the list to make sure it's out of 134 # The trick here is to manually process the list to make sure it's out of
135 # order. 135 # order.
136 for i in obj.dependencies: 136 for i in obj.dependencies:
137 i.dependencies.sort(key=lambda x: x.name, reverse=reverse) 137 # pylint: disable=W0212
138 i._dependencies.sort(key=lambda x: x.name, reverse=reverse)
138 actual = self._get_processed() 139 actual = self._get_processed()
139 # We don't care of the ordering of these items: 140 # We don't care of the ordering of these items:
140 self.assertEquals( 141 self.assertEquals(
141 ['svn://example.com/bar', 'svn://example.com/foo'], sorted(actual[0:2])) 142 ['svn://example.com/bar', 'svn://example.com/foo'], sorted(actual[0:2]))
142 actual = actual[2:] 143 actual = actual[2:]
143 # Ordering may not be exact in case of parallel jobs. 144 # Ordering may not be exact in case of parallel jobs.
144 self.assertTrue( 145 self.assertTrue(
145 actual.index('svn://example.com/bar/dir1/dir2') > 146 actual.index('svn://example.com/bar/dir1/dir2') >
146 actual.index('svn://example.com/foo/dir1')) 147 actual.index('svn://example.com/foo/dir1'))
147 actual.remove('svn://example.com/bar/dir1/dir2') 148 actual.remove('svn://example.com/bar/dir1/dir2')
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 None, 'name', 'proto://host/path/@revision', None, None, None, 203 None, 'name', 'proto://host/path/@revision', None, None, None,
203 None, '', True) 204 None, '', True)
204 self.assertEquals('proto://host/path@revision', d.url) 205 self.assertEquals('proto://host/path@revision', d.url)
205 206
206 def testStr(self): 207 def testStr(self):
207 # Make sure __str__() works fine. 208 # Make sure __str__() works fine.
208 # pylint: disable=W0212 209 # pylint: disable=W0212
209 parser = gclient.Parser() 210 parser = gclient.Parser()
210 options, _ = parser.parse_args([]) 211 options, _ = parser.parse_args([])
211 obj = gclient.GClient('foo', options) 212 obj = gclient.GClient('foo', options)
212 obj.dependencies.append( 213 obj._dependencies.append(
213 gclient.Dependency(obj, 'foo', 'url', None, None, None, None, 'DEPS', 214 gclient.Dependency(obj, 'foo', 'url', None, None, None, None, 'DEPS',
214 True)) 215 True))
215 obj.dependencies.append( 216 obj._dependencies.append(
216 gclient.Dependency(obj, 'bar', 'url', None, None, None, None, 'DEPS', 217 gclient.Dependency(obj, 'bar', 'url', None, None, None, None, 'DEPS',
217 True)) 218 True))
218 obj.dependencies[0].dependencies.append( 219 obj.dependencies[0]._dependencies.append(
219 gclient.Dependency( 220 gclient.Dependency(
220 obj.dependencies[0], 'foo/dir1', 'url', None, None, None, None, 221 obj.dependencies[0], 'foo/dir1', 'url', None, None, None, None,
221 'DEPS', True)) 222 'DEPS', True))
222 obj.dependencies[0].dependencies.append( 223 obj.dependencies[0]._dependencies.append(
223 gclient.Dependency( 224 gclient.Dependency(
224 obj.dependencies[0], 'foo/dir2', 225 obj.dependencies[0], 'foo/dir2',
225 gclient.GClientKeywords.FromImpl('bar'), None, None, None, None, 226 gclient.GClientKeywords.FromImpl('bar'), None, None, None, None,
226 'DEPS', True)) 227 'DEPS', True))
227 obj.dependencies[0].dependencies.append( 228 obj.dependencies[0]._dependencies.append(
228 gclient.Dependency( 229 gclient.Dependency(
229 obj.dependencies[0], 'foo/dir3', 230 obj.dependencies[0], 'foo/dir3',
230 gclient.GClientKeywords.FileImpl('url'), None, None, None, None, 231 gclient.GClientKeywords.FileImpl('url'), None, None, None, None,
231 'DEPS', True)) 232 'DEPS', True))
232 obj.dependencies[0]._file_list.append('foo') 233 obj.dependencies[0]._file_list.append('foo')
233 self.assertEquals(434, len(str(obj)), '%d\n%s' % (len(str(obj)), str(obj))) 234 self.assertEquals(434, len(str(obj)), '%d\n%s' % (len(str(obj)), str(obj)))
234 235
235 236
236 if __name__ == '__main__': 237 if __name__ == '__main__':
237 logging.basicConfig( 238 logging.basicConfig(
238 level=[logging.ERROR, logging.WARNING, logging.INFO, logging.DEBUG][ 239 level=[logging.ERROR, logging.WARNING, logging.INFO, logging.DEBUG][
239 min(sys.argv.count('-v'), 3)], 240 min(sys.argv.count('-v'), 3)],
240 format='%(asctime).19s %(levelname)s %(filename)s:' 241 format='%(asctime).19s %(levelname)s %(filename)s:'
241 '%(lineno)s %(message)s') 242 '%(lineno)s %(message)s')
242 unittest.main() 243 unittest.main()
OLDNEW
« no previous file with comments | « gclient.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698