| OLD | NEW |
| 1 # Copyright 2013-2015 The Chromium Authors. All rights reserved. | 1 # Copyright 2013-2015 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import collections | 5 import collections |
| 6 import contextlib | 6 import contextlib |
| 7 import imp | 7 import imp |
| 8 import inspect | 8 import inspect |
| 9 import os | 9 import os |
| 10 import sys | 10 import sys |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 def _load_recipe_module_module(path, universe_view): | 344 def _load_recipe_module_module(path, universe_view): |
| 345 modname = os.path.splitext(os.path.basename(path))[0] | 345 modname = os.path.splitext(os.path.basename(path))[0] |
| 346 fullname = '%s.%s' % (RECIPE_MODULE_PREFIX, modname) | 346 fullname = '%s.%s' % (RECIPE_MODULE_PREFIX, modname) |
| 347 mod = _find_and_load_module(fullname, modname, path) | 347 mod = _find_and_load_module(fullname, modname, path) |
| 348 | 348 |
| 349 # This actually loads the dependencies. | 349 # This actually loads the dependencies. |
| 350 mod.LOADED_DEPS = universe_view.deps_from_spec(getattr(mod, 'DEPS', [])) | 350 mod.LOADED_DEPS = universe_view.deps_from_spec(getattr(mod, 'DEPS', [])) |
| 351 | 351 |
| 352 # Prevent any modules that mess with sys.path from leaking. | 352 # Prevent any modules that mess with sys.path from leaking. |
| 353 with _preserve_path(): | 353 with _preserve_path(): |
| 354 # TODO(luqui): Remove this hack once configs are cleaned. | |
| 355 sys.modules['%s.DEPS' % fullname] = mod.LOADED_DEPS | 354 sys.modules['%s.DEPS' % fullname] = mod.LOADED_DEPS |
| 356 _recursive_import(path, RECIPE_MODULE_PREFIX) | 355 _recursive_import(path, RECIPE_MODULE_PREFIX) |
| 357 _patchup_module(modname, mod, universe_view) | 356 _patchup_module(modname, mod, universe_view) |
| 358 | 357 |
| 359 return mod | 358 return mod |
| 360 | 359 |
| 361 | 360 |
| 362 def _recursive_import(path, prefix): | 361 def _recursive_import(path, prefix): |
| 363 modname = os.path.splitext(os.path.basename(path))[0] | 362 modname = os.path.splitext(os.path.basename(path))[0] |
| 364 fullname = '%s.%s' % (prefix, modname) | 363 fullname = '%s.%s' % (prefix, modname) |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 572 modapi = (getattr(mod, 'TEST_API', None) or RecipeTestApi)(module=mod) | 571 modapi = (getattr(mod, 'TEST_API', None) or RecipeTestApi)(module=mod) |
| 573 for k,v in deps.iteritems(): | 572 for k,v in deps.iteritems(): |
| 574 setattr(modapi.m, k, v) | 573 setattr(modapi.m, k, v) |
| 575 return modapi | 574 return modapi |
| 576 | 575 |
| 577 mapper = DependencyMapper(instantiator) | 576 mapper = DependencyMapper(instantiator) |
| 578 api = RecipeTestApi(module=None) | 577 api = RecipeTestApi(module=None) |
| 579 for k,v in toplevel_deps.iteritems(): | 578 for k,v in toplevel_deps.iteritems(): |
| 580 setattr(api, k, mapper.instantiate(v)) | 579 setattr(api, k, mapper.instantiate(v)) |
| 581 return api | 580 return api |
| OLD | NEW |