OLD | NEW |
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 Loading... |
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 pulls in all relevant dependencies. |
| 312 |
| 313 The target_os variable allows specifying the name of an additional OS which |
| 314 should be considered when selecting dependencies from a DEPS' deps_os. The |
| 315 value will be appended to the _enforced_os tuple. |
| 316 """ |
| 317 |
| 318 write( |
| 319 '.gclient', |
| 320 'solutions = [\n' |
| 321 ' { "name": "foo",\n' |
| 322 ' "url": "svn://example.com/foo",\n' |
| 323 ' }]\n') |
| 324 write( |
| 325 os.path.join('foo', 'DEPS'), |
| 326 'deps = {\n' |
| 327 ' "foo/dir1": "/dir1",' |
| 328 '}\n' |
| 329 'target_os = ["baz", "jaz"]\n' |
| 330 'deps_os = {\n' |
| 331 ' "unix": { "foo/dir2": "/dir2", },\n' |
| 332 ' "baz": { "foo/dir3": "/dir3", },\n' |
| 333 ' "jaz": { "foo/dir4": "/dir4", },\n' |
| 334 ' "maz": { "foo/dir5": "/dir5", },\n' |
| 335 '}') |
| 336 |
| 337 parser = gclient.Parser() |
| 338 options, _ = parser.parse_args(['--jobs', '1']) |
| 339 options.deps_os = "unix" |
| 340 |
| 341 obj = gclient.GClient.LoadCurrentConfig(options) |
| 342 obj.RunOnDeps(None, None) |
| 343 self.assertEqual(['baz', 'jaz', 'unix'], sorted(obj.enforced_os)) |
| 344 |
310 def testRecursionOverride(self): | 345 def testRecursionOverride(self): |
311 """Verifies gclient respects the recursion var syntax. | 346 """Verifies gclient respects the recursion var syntax. |
312 | 347 |
313 We check several things here: | 348 We check several things here: |
314 - recursion = 3 sets recursion on the foo dep to exactly 3 | 349 - recursion = 3 sets recursion on the foo dep to exactly 3 |
315 (we pull /fizz, but not /fuzz) | 350 (we pull /fizz, but not /fuzz) |
316 - pulling foo/bar at recursion level 1 (in .gclient) is overriden by | 351 - 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) | 352 a later pull of foo/bar at recursion level 2 (in the dep tree) |
318 """ | 353 """ |
319 write( | 354 write( |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
362 sys.stdout = gclient_utils.MakeFileAutoFlush(sys.stdout) | 397 sys.stdout = gclient_utils.MakeFileAutoFlush(sys.stdout) |
363 sys.stdout = gclient_utils.MakeFileAnnotated(sys.stdout, include_zero=True) | 398 sys.stdout = gclient_utils.MakeFileAnnotated(sys.stdout, include_zero=True) |
364 sys.stderr = gclient_utils.MakeFileAutoFlush(sys.stderr) | 399 sys.stderr = gclient_utils.MakeFileAutoFlush(sys.stderr) |
365 sys.stderr = gclient_utils.MakeFileAnnotated(sys.stderr, include_zero=True) | 400 sys.stderr = gclient_utils.MakeFileAnnotated(sys.stderr, include_zero=True) |
366 logging.basicConfig( | 401 logging.basicConfig( |
367 level=[logging.ERROR, logging.WARNING, logging.INFO, logging.DEBUG][ | 402 level=[logging.ERROR, logging.WARNING, logging.INFO, logging.DEBUG][ |
368 min(sys.argv.count('-v'), 3)], | 403 min(sys.argv.count('-v'), 3)], |
369 format='%(relativeCreated)4d %(levelname)5s %(module)13s(' | 404 format='%(relativeCreated)4d %(levelname)5s %(module)13s(' |
370 '%(lineno)d) %(message)s') | 405 '%(lineno)d) %(message)s') |
371 unittest.main() | 406 unittest.main() |
OLD | NEW |