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 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 parser = gclient.Parser() | 268 parser = gclient.Parser() |
269 options, _ = parser.parse_args([]) | 269 options, _ = parser.parse_args([]) |
270 options.force = True | 270 options.force = True |
271 client = gclient.GClient.LoadCurrentConfig(options) | 271 client = gclient.GClient.LoadCurrentConfig(options) |
272 work_queue = gclient_utils.ExecutionQueue(options.jobs, None) | 272 work_queue = gclient_utils.ExecutionQueue(options.jobs, None) |
273 for s in client.dependencies: | 273 for s in client.dependencies: |
274 work_queue.enqueue(s) | 274 work_queue.enqueue(s) |
275 work_queue.flush({}, None, [], options=options) | 275 work_queue.flush({}, None, [], options=options) |
276 self.assertEqual(client.GetHooks(options), [x['action'] for x in hooks]) | 276 self.assertEqual(client.GetHooks(options), [x['action'] for x in hooks]) |
277 | 277 |
| 278 def testTargetOS(self): |
| 279 """Verifies that specifying a target_os pulls in all relevant dependencies. |
| 280 |
| 281 The target_os variable allows specifying the name of an additional OS which |
| 282 should be considered when selecting dependencies from a DEPS' deps_os. The |
| 283 value will be appended to the _enforced_os tuple. |
| 284 """ |
| 285 |
| 286 write( |
| 287 '.gclient', |
| 288 'solutions = [\n' |
| 289 ' { "name": "foo",\n' |
| 290 ' "url": "svn://example.com/foo",\n' |
| 291 ' }]\n' |
| 292 'target_os = ["baz"]') |
| 293 write( |
| 294 os.path.join('foo', 'DEPS'), |
| 295 'deps = {\n' |
| 296 ' "foo/dir1": "/dir1",' |
| 297 '}\n' |
| 298 'deps_os = {\n' |
| 299 ' "unix": { "foo/dir2": "/dir2", },\n' |
| 300 ' "baz": { "foo/dir3": "/dir3", },\n' |
| 301 '}') |
| 302 |
| 303 parser = gclient.Parser() |
| 304 options, _ = parser.parse_args(['--jobs', '1']) |
| 305 options.deps_os = "unix" |
| 306 |
| 307 obj = gclient.GClient.LoadCurrentConfig(options) |
| 308 self.assertEqual(['baz', 'unix'], sorted(obj.enforced_os)) |
| 309 |
278 | 310 |
279 if __name__ == '__main__': | 311 if __name__ == '__main__': |
280 sys.stdout = gclient_utils.MakeFileAutoFlush(sys.stdout) | 312 sys.stdout = gclient_utils.MakeFileAutoFlush(sys.stdout) |
281 sys.stdout = gclient_utils.MakeFileAnnotated(sys.stdout, include_zero=True) | 313 sys.stdout = gclient_utils.MakeFileAnnotated(sys.stdout, include_zero=True) |
282 sys.stderr = gclient_utils.MakeFileAutoFlush(sys.stderr) | 314 sys.stderr = gclient_utils.MakeFileAutoFlush(sys.stderr) |
283 sys.stderr = gclient_utils.MakeFileAnnotated(sys.stderr, include_zero=True) | 315 sys.stderr = gclient_utils.MakeFileAnnotated(sys.stderr, include_zero=True) |
284 logging.basicConfig( | 316 logging.basicConfig( |
285 level=[logging.ERROR, logging.WARNING, logging.INFO, logging.DEBUG][ | 317 level=[logging.ERROR, logging.WARNING, logging.INFO, logging.DEBUG][ |
286 min(sys.argv.count('-v'), 3)], | 318 min(sys.argv.count('-v'), 3)], |
287 format='%(relativeCreated)4d %(levelname)5s %(module)13s(' | 319 format='%(relativeCreated)4d %(levelname)5s %(module)13s(' |
288 '%(lineno)d) %(message)s') | 320 '%(lineno)d) %(message)s') |
289 unittest.main() | 321 unittest.main() |
OLD | NEW |