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

Side by Side Diff: tests/gclient_test.py

Issue 10127004: Add the ability to specify a target_os for gclient solutions (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools/
Patch Set: Created 8 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 | Annotate | Revision Log
« gclient.py ('K') | « 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) 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 """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 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 items.append(self.processed.get_nowait()) 203 items.append(self.processed.get_nowait())
204 except Queue.Empty: 204 except Queue.Empty:
205 pass 205 pass
206 return items 206 return items
207 207
208 def testAutofix(self): 208 def testAutofix(self):
209 # Invalid urls causes pain when specifying requirements. Make sure it's 209 # Invalid urls causes pain when specifying requirements. Make sure it's
210 # auto-fixed. 210 # auto-fixed.
211 d = gclient.Dependency( 211 d = gclient.Dependency(
212 None, 'name', 'proto://host/path/@revision', None, None, None, 212 None, 'name', 'proto://host/path/@revision', None, None, None,
213 None, '', True) 213 None, '', None, True)
214 self.assertEquals('proto://host/path@revision', d.url) 214 self.assertEquals('proto://host/path@revision', d.url)
215 215
216 def testStr(self): 216 def testStr(self):
217 parser = gclient.Parser() 217 parser = gclient.Parser()
218 options, _ = parser.parse_args([]) 218 options, _ = parser.parse_args([])
219 obj = gclient.GClient('foo', options) 219 obj = gclient.GClient('foo', options)
220 obj.add_dependencies_and_close( 220 obj.add_dependencies_and_close(
221 [ 221 [
222 gclient.Dependency( 222 gclient.Dependency(
223 obj, 'foo', 'url', None, None, None, None, 'DEPS', True), 223 obj, 'foo', 'url', None, None, None, None, 'DEPS', None, True),
224 gclient.Dependency( 224 gclient.Dependency(
225 obj, 'bar', 'url', None, None, None, None, 'DEPS', True), 225 obj, 'bar', 'url', None, None, None, None, 'DEPS', None, True),
226 ], 226 ],
227 []) 227 [])
228 obj.dependencies[0].add_dependencies_and_close( 228 obj.dependencies[0].add_dependencies_and_close(
229 [ 229 [
230 gclient.Dependency( 230 gclient.Dependency(
231 obj.dependencies[0], 'foo/dir1', 'url', None, None, None, None, 231 obj.dependencies[0], 'foo/dir1', 'url', None, None, None, None,
232 'DEPS', True), 232 'DEPS', None, True),
233 gclient.Dependency( 233 gclient.Dependency(
234 obj.dependencies[0], 'foo/dir2', 234 obj.dependencies[0], 'foo/dir2',
235 gclient.GClientKeywords.FromImpl('bar'), None, None, None, None, 235 gclient.GClientKeywords.FromImpl('bar'), None, None, None, None,
236 'DEPS', True), 236 'DEPS', None, True),
237 gclient.Dependency( 237 gclient.Dependency(
238 obj.dependencies[0], 'foo/dir3', 238 obj.dependencies[0], 'foo/dir3',
239 gclient.GClientKeywords.FileImpl('url'), None, None, None, None, 239 gclient.GClientKeywords.FileImpl('url'), None, None, None, None,
240 'DEPS', True), 240 'DEPS', None, True),
241 ], 241 ],
242 []) 242 [])
243 # Make sure __str__() works fine. 243 # Make sure __str__() works fine.
244 # pylint: disable=W0212 244 # pylint: disable=W0212
245 obj.dependencies[0]._file_list.append('foo') 245 obj.dependencies[0]._file_list.append('foo')
246 str_obj = str(obj) 246 str_obj = str(obj)
247 self.assertEquals(471, len(str_obj), '%d\n%s' % (len(str_obj), str_obj)) 247 self.assertEquals(471, len(str_obj), '%d\n%s' % (len(str_obj), str_obj))
248 248
249 def testHooks(self): 249 def testHooks(self):
250 topdir = self.root_dir 250 topdir = self.root_dir
(...skipping 18 matching lines...) Expand all
269 parser = gclient.Parser() 269 parser = gclient.Parser()
270 options, _ = parser.parse_args([]) 270 options, _ = parser.parse_args([])
271 options.force = True 271 options.force = True
272 client = gclient.GClient.LoadCurrentConfig(options) 272 client = gclient.GClient.LoadCurrentConfig(options)
273 work_queue = gclient_utils.ExecutionQueue(options.jobs, None) 273 work_queue = gclient_utils.ExecutionQueue(options.jobs, None)
274 for s in client.dependencies: 274 for s in client.dependencies:
275 work_queue.enqueue(s) 275 work_queue.enqueue(s)
276 work_queue.flush({}, None, [], options=options) 276 work_queue.flush({}, None, [], options=options)
277 self.assertEqual(client.GetHooks(options), [x['action'] for x in hooks]) 277 self.assertEqual(client.GetHooks(options), [x['action'] for x in hooks])
278 278
279 def testTargetOS(self):
280 """Verifies that specifying a target_os pulls in all relevant dependencies.
281
282 The target_os variable allows specifying the name of an additional OS which
283 should be considered when selecting dependencies from a DEPS' deps_os. The
284 value will be appended to the enforced_os tuple.
285 """
286
287 write(
288 '.gclient',
289 """
290 solutions = [
291 { "name": "foo",
292 "url": "svn://example.com/foo",
293 "target_os": "baz"
294 }
295 ]""")
296 write(
297 os.path.join('foo', 'DEPS'),
298 """
299 deps = {
300 "foo/dir1": "/dir1"
301 }
302 deps_os = {
303 "unix": { "foo/dir2": "/dir2" },
304 "baz": { "foo/dir3": "/dir3" }
305 }""")
306
307 parser = gclient.Parser()
308 options, args = parser.parse_args(['--jobs', '1'])
309 options.deps_os = "unix"
310
311 obj = gclient.GClient.LoadCurrentConfig(options)
312 obj.RunOnDeps('None', args)
313
314 self.assertEqual(4, len(self._get_processed()))
315
279 316
280 if __name__ == '__main__': 317 if __name__ == '__main__':
281 sys.stdout = gclient_utils.MakeFileAutoFlush(sys.stdout) 318 sys.stdout = gclient_utils.MakeFileAutoFlush(sys.stdout)
282 sys.stdout = gclient_utils.MakeFileAnnotated(sys.stdout, include_zero=True) 319 sys.stdout = gclient_utils.MakeFileAnnotated(sys.stdout, include_zero=True)
283 sys.stderr = gclient_utils.MakeFileAutoFlush(sys.stderr) 320 sys.stderr = gclient_utils.MakeFileAutoFlush(sys.stderr)
284 sys.stderr = gclient_utils.MakeFileAnnotated(sys.stderr, include_zero=True) 321 sys.stderr = gclient_utils.MakeFileAnnotated(sys.stderr, include_zero=True)
285 logging.basicConfig( 322 logging.basicConfig(
286 level=[logging.ERROR, logging.WARNING, logging.INFO, logging.DEBUG][ 323 level=[logging.ERROR, logging.WARNING, logging.INFO, logging.DEBUG][
287 min(sys.argv.count('-v'), 3)], 324 min(sys.argv.count('-v'), 3)],
288 format='%(relativeCreated)4d %(levelname)5s %(module)13s(' 325 format='%(relativeCreated)4d %(levelname)5s %(module)13s('
289 '%(lineno)d) %(message)s') 326 '%(lineno)d) %(message)s')
290 unittest.main() 327 unittest.main()
OLDNEW
« gclient.py ('K') | « gclient.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698