Chromium Code Reviews

Side by Side Diff: tests/gclient_test.py

Issue 11363036: Allow specificying that only target_os should be used in a gclient file (Closed) Base URL: https://git.chromium.org/chromium/tools/depot_tools.git@master
Patch Set: Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
« 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 289 matching lines...)
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 testTargetOsWithIgnoredHost(self):
311 """Verifies that specifying a target_os and target_os_only pulls in only
312 the relevant dependencies.
313
314 The target_os variable allows specifying the name of an additional OS which
315 should be considered when selecting dependencies from a DEPS' deps_os. With
316 target_os_only also set, the _enforced_os tuple will be set to only the
317 target_os value.
318 """
319
320 write(
321 '.gclient',
322 'solutions = [\n'
323 ' { "name": "foo",\n'
324 ' "url": "svn://example.com/foo",\n'
325 ' }]\n'
326 'target_os = ["baz"]\n'
327 'target_os_only = True')
328 write(
329 os.path.join('foo', 'DEPS'),
330 'deps = {\n'
331 ' "foo/dir1": "/dir1",'
332 '}\n'
333 'deps_os = {\n'
334 ' "unix": { "foo/dir2": "/dir2", },\n'
335 ' "baz": { "foo/dir3": "/dir3", },\n'
336 '}')
337
338 parser = gclient.Parser()
339 options, _ = parser.parse_args(['--jobs', '1'])
340 options.deps_os = "unix"
341
342 obj = gclient.GClient.LoadCurrentConfig(options)
343 self.assertEqual(['baz'], sorted(obj.enforced_os))
344
310 def testTargetOsInDepsFile(self): 345 def testTargetOsInDepsFile(self):
311 """Verifies that specifying a target_os value in a DEPS file pulls in all 346 """Verifies that specifying a target_os value in a DEPS file pulls in all
312 relevant dependencies. 347 relevant dependencies.
313 348
314 The target_os variable in a DEPS file allows specifying the name of an 349 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 350 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. 351 DEPS' deps_os. The value will be appended to the _enforced_os tuple.
317 """ 352 """
318 353
319 write( 354 write(
(...skipping 93 matching lines...)
413 sys.stdout = gclient_utils.MakeFileAutoFlush(sys.stdout) 448 sys.stdout = gclient_utils.MakeFileAutoFlush(sys.stdout)
414 sys.stdout = gclient_utils.MakeFileAnnotated(sys.stdout, include_zero=True) 449 sys.stdout = gclient_utils.MakeFileAnnotated(sys.stdout, include_zero=True)
415 sys.stderr = gclient_utils.MakeFileAutoFlush(sys.stderr) 450 sys.stderr = gclient_utils.MakeFileAutoFlush(sys.stderr)
416 sys.stderr = gclient_utils.MakeFileAnnotated(sys.stderr, include_zero=True) 451 sys.stderr = gclient_utils.MakeFileAnnotated(sys.stderr, include_zero=True)
417 logging.basicConfig( 452 logging.basicConfig(
418 level=[logging.ERROR, logging.WARNING, logging.INFO, logging.DEBUG][ 453 level=[logging.ERROR, logging.WARNING, logging.INFO, logging.DEBUG][
419 min(sys.argv.count('-v'), 3)], 454 min(sys.argv.count('-v'), 3)],
420 format='%(relativeCreated)4d %(levelname)5s %(module)13s(' 455 format='%(relativeCreated)4d %(levelname)5s %(module)13s('
421 '%(lineno)d) %(message)s') 456 '%(lineno)d) %(message)s')
422 unittest.main() 457 unittest.main()
OLDNEW
« gclient.py ('K') | « gclient.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine