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

Side by Side Diff: tests/gclient_test.py

Issue 11246004: Allow DEPS file to specify 'target_os'. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Fix a comment Created 8 years, 1 month 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) 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 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 ' "baz": { "foo/dir3": "/dir3", },\n' 300 ' "baz": { "foo/dir3": "/dir3", },\n'
301 '}') 301 '}')
302 302
303 parser = gclient.Parser() 303 parser = gclient.Parser()
304 options, _ = parser.parse_args(['--jobs', '1']) 304 options, _ = parser.parse_args(['--jobs', '1'])
305 options.deps_os = "unix" 305 options.deps_os = "unix"
306 306
307 obj = gclient.GClient.LoadCurrentConfig(options) 307 obj = gclient.GClient.LoadCurrentConfig(options)
308 self.assertEqual(['baz', 'unix'], sorted(obj.enforced_os)) 308 self.assertEqual(['baz', 'unix'], sorted(obj.enforced_os))
309 309
310 def testTargetOsInDepsFile(self):
311 """Verifies that specifying a target_os value in a DEPS file pulls in all
312 relevant dependencies.
313
314 The target_os variable in a DEPS file allows specifying the name of an
315 additional OS which should be considered when selecting dependencies from a
316 DEPS' deps_os. The value will be appended to the _enforced_os tuple.
317 """
318
319 write(
320 '.gclient',
321 'solutions = [\n'
322 ' { "name": "foo",\n'
323 ' "url": "svn://example.com/foo",\n'
324 ' }]\n')
325 write(
326 os.path.join('foo', 'DEPS'),
327 'target_os = ["baz"]\n'
328 'deps_os = {\n'
329 ' "unix": { "foo/unix": "/unix", },\n'
330 ' "baz": { "foo/baz": "/baz", },\n'
331 ' "jaz": { "foo/jaz": "/jaz", },\n'
332 '}')
333
334 parser = gclient.Parser()
335 options, _ = parser.parse_args(['--jobs', '1'])
336 options.deps_os = 'unix'
337
338 obj = gclient.GClient.LoadCurrentConfig(options)
339 obj.RunOnDeps('None', [])
340 self.assertEqual(['unix'], sorted(obj.enforced_os))
341 self.assertEquals(
342 [
343 'svn://example.com/foo',
344 'svn://example.com/foo/baz',
345 'svn://example.com/foo/unix',
346 ],
347 sorted(self._get_processed()))
348
310 def testRecursionOverride(self): 349 def testRecursionOverride(self):
311 """Verifies gclient respects the recursion var syntax. 350 """Verifies gclient respects the recursion var syntax.
312 351
313 We check several things here: 352 We check several things here:
314 - recursion = 3 sets recursion on the foo dep to exactly 3 353 - recursion = 3 sets recursion on the foo dep to exactly 3
315 (we pull /fizz, but not /fuzz) 354 (we pull /fizz, but not /fuzz)
316 - pulling foo/bar at recursion level 1 (in .gclient) is overriden by 355 - pulling foo/bar at recursion level 1 (in .gclient) is overriden by
317 a later pull of foo/bar at recursion level 2 (in the dep tree) 356 a later pull of foo/bar at recursion level 2 (in the dep tree)
318 """ 357 """
319 write( 358 write(
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 sys.stdout = gclient_utils.MakeFileAutoFlush(sys.stdout) 401 sys.stdout = gclient_utils.MakeFileAutoFlush(sys.stdout)
363 sys.stdout = gclient_utils.MakeFileAnnotated(sys.stdout, include_zero=True) 402 sys.stdout = gclient_utils.MakeFileAnnotated(sys.stdout, include_zero=True)
364 sys.stderr = gclient_utils.MakeFileAutoFlush(sys.stderr) 403 sys.stderr = gclient_utils.MakeFileAutoFlush(sys.stderr)
365 sys.stderr = gclient_utils.MakeFileAnnotated(sys.stderr, include_zero=True) 404 sys.stderr = gclient_utils.MakeFileAnnotated(sys.stderr, include_zero=True)
366 logging.basicConfig( 405 logging.basicConfig(
367 level=[logging.ERROR, logging.WARNING, logging.INFO, logging.DEBUG][ 406 level=[logging.ERROR, logging.WARNING, logging.INFO, logging.DEBUG][
368 min(sys.argv.count('-v'), 3)], 407 min(sys.argv.count('-v'), 3)],
369 format='%(relativeCreated)4d %(levelname)5s %(module)13s(' 408 format='%(relativeCreated)4d %(levelname)5s %(module)13s('
370 '%(lineno)d) %(message)s') 409 '%(lineno)d) %(message)s')
371 unittest.main() 410 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