Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Unified Diff: third_party/recipe_engine/recipe_simulation_test.py

Issue 1151423002: Move recipe engine to third_party/recipe_engine. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/build
Patch Set: Copyright notices Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/recipe_engine/recipe_simulation_test.py
diff --git a/scripts/slave/unittests/recipe_simulation_test.py b/third_party/recipe_engine/recipe_simulation_test.py
old mode 100755
new mode 100644
similarity index 53%
copy from scripts/slave/unittests/recipe_simulation_test.py
copy to third_party/recipe_engine/recipe_simulation_test.py
index f3f6428f8ba2657cd6eeb9787f4df20d694f31ed..34c1d4450c26d716ff79f828d7b999598cc956d0
--- a/scripts/slave/unittests/recipe_simulation_test.py
+++ b/third_party/recipe_engine/recipe_simulation_test.py
@@ -6,66 +6,57 @@
"""Provides simulator test coverage for individual recipes."""
import logging
+import re
import os
+import sys
-# Importing for side effects on sys.path? Yes... yes we are :(
-import test_env # pylint: disable=W0611,W0403
-
-from slave import recipe_util
-
-import expect_tests # pylint: disable=W0403
-
+from . import recipe_util
+from . import expect_tests # XXX pylint XXX: disable=W0403
iannucci 2015/05/27 02:03:27 ???? this looks fine or move expect_tests to thi
luqui 2015/05/28 21:47:38 Acknowledged.
+# This variable must be set in the dynamic scope of the functions in this file.
+# We do this instead of passing because the threading system of expect tests
+# doesn't know how to serialize it.
_UNIVERSE = None
iannucci 2015/05/27 02:03:27 probably should document that this is a RecipeLoad
luqui 2015/05/28 21:47:38 Done.
-def get_universe():
- from slave import recipe_loader
- global _UNIVERSE
- if _UNIVERSE is None:
- _UNIVERSE = recipe_loader.RecipeUniverse()
- return _UNIVERSE
-
def RunRecipe(test_data):
- from common import annotator
- from slave import annotated_run
- from slave import recipe_config_types
+ from .third_party import annotator
+ from . import annotated_run
+ from . import recipe_config_types
stream = annotator.StructuredAnnotationStream(stream=open(os.devnull, 'w'))
recipe_config_types.ResetTostringFns()
- # TODO(iannucci): Only pass test_data once.
- result = annotated_run.run_steps(stream, test_data.properties,
- test_data.properties,
- get_universe(),
- test_data)
+ result = annotated_run.run_steps(
+ test_data.properties, stream, _UNIVERSE, test_data)
return expect_tests.Result(list(result.steps_ran.values()))
def test_gen_coverage():
return (
- [os.path.join(x, '*') for x in recipe_util.RECIPE_DIRS()] +
- [os.path.join(x, '*', 'example.py') for x in recipe_util.MODULE_DIRS()] +
- [os.path.join(x, '*', 'test_api.py') for x in recipe_util.MODULE_DIRS()] +
- [os.path.join(os.path.dirname(recipe_util.__file__), 'recipe_api.py')]
iannucci 2015/05/27 02:03:27 lost this? but really!! we want tests for the eng
+ [os.path.join(x, '*') for x in _UNIVERSE.recipe_dirs] +
+ [os.path.join(x, '*', 'example.py') for x in _UNIVERSE.module_dirs] +
+ [os.path.join(x, '*', 'test_api.py') for x in _UNIVERSE.module_dirs]
)
+def cover_omit():
+ omit = [ ]
+ for mod_dir_base in _UNIVERSE.module_dirs:
+ if os.path.isdir(mod_dir_base):
+ omit.append(os.path.join(mod_dir_base, '*', 'resources', '*'))
+ return omit
@expect_tests.covers(test_gen_coverage)
def GenerateTests():
- from slave import recipe_loader
+ from . import recipe_loader
- universe = get_universe()
-
- cover_mods = [
- os.path.join(os.path.dirname(recipe_util.__file__), 'recipe_api.py')
- ]
- for mod_dir_base in recipe_util.MODULE_DIRS():
+ cover_mods = [ ]
+ for mod_dir_base in _UNIVERSE.module_dirs:
if os.path.isdir(mod_dir_base):
cover_mods.append(os.path.join(mod_dir_base, '*', '*.py'))
- for recipe_path, recipe_name in recipe_loader.loop_over_recipes():
- recipe = universe.load_recipe(recipe_name)
- test_api = recipe_loader.create_test_api(recipe.LOADED_DEPS, universe)
+ for recipe_path, recipe_name in _UNIVERSE.loop_over_recipes():
+ recipe = _UNIVERSE.load_recipe(recipe_name)
+ test_api = recipe_loader.create_test_api(recipe.LOADED_DEPS, _UNIVERSE)
covers = cover_mods + [recipe_path]
@@ -85,8 +76,8 @@ def GenerateTests():
)
-if __name__ == '__main__':
- # annotated_run.py has different behavior when these environment variables
+def main(universe):
+ # annotated_run has different behavior when these environment variables
iannucci 2015/05/27 02:03:27 maybe assert universe is something that we can dea
luqui 2015/05/28 21:47:38 Added docs is all
# are set, so unset to make simulation tests environment-invariant.
for env_var in ['TESTING_MASTER_HOST',
'TESTING_MASTER',
@@ -95,4 +86,7 @@ if __name__ == '__main__':
logging.warn("Ignoring %s environment variable." % env_var)
os.environ.pop(env_var)
- expect_tests.main('recipe_simulation_test', GenerateTests)
+ global _UNIVERSE
+ _UNIVERSE = universe
+ expect_tests.main('recipe_simulation_test', GenerateTests,
+ cover_omit=cover_omit())

Powered by Google App Engine
This is Rietveld 408576698