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 """ |
| 289 solutions = [ |
| 290 { "name": "foo", |
| 291 "url": "svn://example.com/foo", |
| 292 } |
| 293 ] |
| 294 target_os = ["baz"]""") |
| 295 write( |
| 296 os.path.join('foo', 'DEPS'), |
| 297 """ |
| 298 deps = { |
| 299 "foo/dir1": "/dir1" |
| 300 } |
| 301 deps_os = { |
| 302 "unix": { "foo/dir2": "/dir2" }, |
| 303 "baz": { "foo/dir3": "/dir3" } |
| 304 }""") |
| 305 |
| 306 parser = gclient.Parser() |
| 307 options, args = parser.parse_args(['--jobs', '1']) |
| 308 options.deps_os = "unix" |
| 309 |
| 310 obj = gclient.GClient.LoadCurrentConfig(options) |
| 311 obj.RunOnDeps('None', args) |
| 312 |
| 313 self.assertEqual(4, len(self._get_processed())) |
| 314 |
278 | 315 |
279 if __name__ == '__main__': | 316 if __name__ == '__main__': |
280 sys.stdout = gclient_utils.MakeFileAutoFlush(sys.stdout) | 317 sys.stdout = gclient_utils.MakeFileAutoFlush(sys.stdout) |
281 sys.stdout = gclient_utils.MakeFileAnnotated(sys.stdout, include_zero=True) | 318 sys.stdout = gclient_utils.MakeFileAnnotated(sys.stdout, include_zero=True) |
282 sys.stderr = gclient_utils.MakeFileAutoFlush(sys.stderr) | 319 sys.stderr = gclient_utils.MakeFileAutoFlush(sys.stderr) |
283 sys.stderr = gclient_utils.MakeFileAnnotated(sys.stderr, include_zero=True) | 320 sys.stderr = gclient_utils.MakeFileAnnotated(sys.stderr, include_zero=True) |
284 logging.basicConfig( | 321 logging.basicConfig( |
285 level=[logging.ERROR, logging.WARNING, logging.INFO, logging.DEBUG][ | 322 level=[logging.ERROR, logging.WARNING, logging.INFO, logging.DEBUG][ |
286 min(sys.argv.count('-v'), 3)], | 323 min(sys.argv.count('-v'), 3)], |
287 format='%(relativeCreated)4d %(levelname)5s %(module)13s(' | 324 format='%(relativeCreated)4d %(levelname)5s %(module)13s(' |
288 '%(lineno)d) %(message)s') | 325 '%(lineno)d) %(message)s') |
289 unittest.main() | 326 unittest.main() |
OLD | NEW |