Chromium Code Reviews| Index: recipe_engine/run.py |
| diff --git a/recipe_engine/run.py b/recipe_engine/run.py |
| index 6949ee70212269c415831ca60fb64b10cbd630e9..b17e3d4c106858538600415055cef3c33120d060 100644 |
| --- a/recipe_engine/run.py |
| +++ b/recipe_engine/run.py |
| @@ -72,6 +72,7 @@ import os |
| import re |
| import subprocess |
| import sys |
| +import tempfile |
| import threading |
| import traceback |
| @@ -81,6 +82,7 @@ import cStringIO |
| from . import loader |
| from . import recipe_api |
| from . import recipe_test_api |
| +from . import types |
| from . import util |
| @@ -433,7 +435,7 @@ def run_steps(properties, |
| 'TESTING_SLAVENAME' in os.environ)): |
| properties['use_mirror'] = False |
| - engine = RecipeEngine(stream, properties, test_data) |
| + engine = RecipeEngine(stream, properties, test_data, universe) |
| # Create all API modules and top level RunSteps function. It doesn't launch |
| # any recipe code yet; RunSteps needs to be called. |
| @@ -750,16 +752,21 @@ class RecipeEngine(object): |
| * step - uses engine.create_step(...). |
| """ |
| - def __init__(self, stream, properties, test_data): |
| + def __init__(self, stream, properties, test_data, universe): |
| self._stream = stream |
| self._properties = properties |
| self._test_data = test_data |
| self._step_history = collections.OrderedDict() |
| + self._universe = universe |
| self._previous_step_annotation = None |
| self._previous_step_result = None |
| self._api = None |
| + def clone(self, stream=None, properties=None, universe=None): |
| + return RecipeEngine(stream or self._stream, properties or self._properties, |
| + self._test_data, universe or self._universe) |
|
luqui
2015/11/16 20:48:00
Hmm, isn't test_data mutable, in order for example
martiniss
2015/11/18 01:00:00
Deleted this method. Not needed anymore.
|
| + |
| @property |
| def properties(self): |
| return self._properties |
| @@ -861,11 +868,12 @@ class RecipeEngine(object): |
| raise exc(step['name'], step_result) |
| - |
| def run(self, recipe_script, api): |
| """Run a recipe represented by a recipe_script object. |
| This function blocks until recipe finishes. |
| + It mainly executes the recipe, and has some exception handling logic, and |
| + adds the step history to the result. |
| Args: |
| recipe_script: The recipe to run, as represented by a RecipeScript object. |
| @@ -940,4 +948,34 @@ class RecipeEngine(object): |
| """ |
| return step.as_jsonish() |
| + def depend_on(self, recipe, properties, distributor=None): |
| + return self.depend_on_multi( |
| + ((recipe, properties),), distributor=distributor) |
| + |
| + def depend_on_multi(self, dependencies, distributor=None): |
| + if self._test_data.enabled: |
| + # TODO(martiniss) test properties against the recipe |
| + for recipe, properties in dependencies: |
| + recipe_script = self._universe.load_recipe(recipe) |
|
luqui
2015/11/16 20:48:00
This precludes one use case, which is that the rec
|
| + loader._invoke_with_properties( |
| + lambda *args, **kwargs: None, properties, recipe_script.PROPERTIES, |
| + properties.keys()) |
| + |
| + return self._test_data.depend_on_data[types.freeze((recipe, properties),)] |
|
luqui
2015/11/16 20:48:00
line wrap
|
| + |
| + # TODO(martiniss) Add DM integration |
| + for recipe, properties in dependencies: |
| + recipes_py_loc = os.path.join( |
| + self._universe.package_deps._context.repo_root, 'recipes.py') |
| + |
| + with tempfile.NamedTemporaryFile() as f: |
| + cmd = [sys.executable, recipes_py_loc, |
| + '--package=%s' % self._universe._config_file, 'run', |
| + '--result-file=%s' % f.name, recipe] |
|
luqui
2015/11/16 20:48:00
The convention for this argument has been --output
martiniss
2015/11/18 01:00:00
Fixed.
|
| + cmd.extend(['%s=%s' % (k, v) for k, v in properties.iteritems()]) |
| + |
| + rval = subprocess.call(cmd) |
|
estaab
2015/11/17 23:07:16
We should probably throw an exception when rval is
martiniss
2015/11/18 01:00:00
Good idea. Raising an InfraFailure.
|
| + return json.load(f) |
| + |
| + |