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

Side by Side Diff: scripts/slave/unittests/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: Moved field_composer_test with its buddies Created 5 years, 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « scripts/slave/unittests/recipe_lint_test.py ('k') | scripts/tools/runit.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2014 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2013 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 """Provides simulator test coverage for individual recipes.""" 6 import os
7 import sys
7 8
8 import logging 9 import test_env # pylint: disable=W0403,W0611
9 import os
10 10
11 # Importing for side effects on sys.path? Yes... yes we are :( 11 from recipe_engine import simulation_test
12 import test_env # pylint: disable=W0611,W0403 12 from slave import recipe_universe
13
14 from slave import recipe_util
15
16 import expect_tests # pylint: disable=W0403
17
18
19 _UNIVERSE = None
20 def get_universe():
21 from slave import recipe_loader
22 global _UNIVERSE
23 if _UNIVERSE is None:
24 _UNIVERSE = recipe_loader.RecipeUniverse()
25 return _UNIVERSE
26
27
28 def RunRecipe(test_data):
29 from common import annotator
30 from slave import annotated_run
31 from slave import recipe_config_types
32
33 stream = annotator.StructuredAnnotationStream(stream=open(os.devnull, 'w'))
34 recipe_config_types.ResetTostringFns()
35 # TODO(iannucci): Only pass test_data once.
36 result = annotated_run.run_steps(stream, test_data.properties,
37 test_data.properties,
38 get_universe(),
39 test_data)
40
41 return expect_tests.Result(list(result.steps_ran.values()))
42
43
44 def test_gen_coverage():
45 return (
46 [os.path.join(x, '*') for x in recipe_util.RECIPE_DIRS()] +
47 [os.path.join(x, '*', 'example.py') for x in recipe_util.MODULE_DIRS()] +
48 [os.path.join(x, '*', 'test_api.py') for x in recipe_util.MODULE_DIRS()] +
49 [os.path.join(os.path.dirname(recipe_util.__file__), 'recipe_api.py')]
50 )
51
52
53 @expect_tests.covers(test_gen_coverage)
54 def GenerateTests():
55 from slave import recipe_loader
56
57 universe = get_universe()
58
59 cover_mods = [
60 os.path.join(os.path.dirname(recipe_util.__file__), 'recipe_api.py')
61 ]
62 for mod_dir_base in recipe_util.MODULE_DIRS():
63 if os.path.isdir(mod_dir_base):
64 cover_mods.append(os.path.join(mod_dir_base, '*', '*.py'))
65
66 for recipe_path, recipe_name in recipe_loader.loop_over_recipes():
67 recipe = universe.load_recipe(recipe_name)
68 test_api = recipe_loader.create_test_api(recipe.LOADED_DEPS, universe)
69
70 covers = cover_mods + [recipe_path]
71
72 for test_data in recipe.GenTests(test_api):
73 root, name = os.path.split(recipe_path)
74 name = os.path.splitext(name)[0]
75 expect_path = os.path.join(root, '%s.expected' % name)
76
77 test_data.properties['recipe'] = recipe_name.replace('\\', '/')
78 yield expect_tests.Test(
79 '%s.%s' % (recipe_name, test_data.name),
80 expect_tests.FuncCall(RunRecipe, test_data),
81 expect_dir=expect_path,
82 expect_base=test_data.name,
83 covers=covers,
84 break_funcs=(recipe.GenSteps,)
85 )
86
87 13
88 if __name__ == '__main__': 14 if __name__ == '__main__':
89 # annotated_run.py has different behavior when these environment variables 15 simulation_test.main(recipe_universe.get_universe())
90 # are set, so unset to make simulation tests environment-invariant.
91 for env_var in ['TESTING_MASTER_HOST',
92 'TESTING_MASTER',
93 'TESTING_SLAVENAME']:
94 if env_var in os.environ:
95 logging.warn("Ignoring %s environment variable." % env_var)
96 os.environ.pop(env_var)
97
98 expect_tests.main('recipe_simulation_test', GenerateTests)
OLDNEW
« no previous file with comments | « scripts/slave/unittests/recipe_lint_test.py ('k') | scripts/tools/runit.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698