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

Side by Side Diff: third_party/recipe_engine/simulation_test.py

Issue 1241323004: Cross-repo recipe package system. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/build
Patch Set: Roll to latest recipes-py Created 5 years, 3 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
OLDNEW
(Empty)
1 # Copyright 2014-2015 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 """Provides simulator test coverage for individual recipes."""
6
7 import logging
8 import re
9 import os
10 import sys
11
12 from . import expect_tests
13
14 # This variable must be set in the dynamic scope of the functions in this file.
15 # We do this instead of passing because the threading system of expect tests
16 # doesn't know how to serialize it.
17 _UNIVERSE = None
18
19 def RunRecipe(test_data):
20 from .third_party import annotator
21 from . import main
22 from . import config_types
23
24 stream = annotator.StructuredAnnotationStream(stream=open(os.devnull, 'w'))
25 config_types.ResetTostringFns()
26 result = main.run_steps(
27 test_data.properties, stream, _UNIVERSE, test_data)
28
29 return expect_tests.Result(list(result.steps_ran.values()))
30
31
32 def test_gen_coverage():
33 return (
34 [os.path.join(x, '*') for x in _UNIVERSE.recipe_dirs] +
35 [os.path.join(x, '*', 'example.py') for x in _UNIVERSE.module_dirs] +
36 [os.path.join(x, '*', 'test_api.py') for x in _UNIVERSE.module_dirs]
37 )
38
39 def cover_omit():
40 omit = [ ]
41 for mod_dir_base in _UNIVERSE.module_dirs:
42 if os.path.isdir(mod_dir_base):
43 omit.append(os.path.join(mod_dir_base, '*', 'resources', '*'))
44 return omit
45
46 @expect_tests.covers(test_gen_coverage)
47 def GenerateTests():
48 from . import loader
49
50 cover_mods = [ ]
51 for mod_dir_base in _UNIVERSE.module_dirs:
52 if os.path.isdir(mod_dir_base):
53 cover_mods.append(os.path.join(mod_dir_base, '*', '*.py'))
54
55 for recipe_path, recipe_name in _UNIVERSE.loop_over_recipes():
56 recipe = _UNIVERSE.load_recipe(recipe_name)
57 test_api = loader.create_test_api(recipe.LOADED_DEPS, _UNIVERSE)
58
59 covers = cover_mods + [recipe_path]
60
61 for test_data in recipe.GenTests(test_api):
62 root, name = os.path.split(recipe_path)
63 name = os.path.splitext(name)[0]
64 expect_path = os.path.join(root, '%s.expected' % name)
65
66 test_data.properties['recipe'] = recipe_name.replace('\\', '/')
67 yield expect_tests.Test(
68 '%s.%s' % (recipe_name, test_data.name),
69 expect_tests.FuncCall(RunRecipe, test_data),
70 expect_dir=expect_path,
71 expect_base=test_data.name,
72 covers=covers,
73 break_funcs=(recipe.RunSteps,)
74 )
75
76
77 def main(universe):
78 """Runs simulation tests on a given repo of recipes.
79
80 Args:
81 universe: a RecipeUniverse to operate on.
82 Returns:
83 Doesn't -- exits with a status code
84 """
85
86 # annotated_run has different behavior when these environment variables
87 # are set, so unset to make simulation tests environment-invariant.
88 for env_var in ['TESTING_MASTER_HOST',
89 'TESTING_MASTER',
90 'TESTING_SLAVENAME']:
91 if env_var in os.environ:
92 logging.warn("Ignoring %s environment variable." % env_var)
93 os.environ.pop(env_var)
94
95 global _UNIVERSE
96 _UNIVERSE = universe
97 expect_tests.main('recipe_simulation_test', GenerateTests,
98 cover_omit=cover_omit())
OLDNEW
« no previous file with comments | « third_party/recipe_engine/recipe_test_api.py ('k') | third_party/recipe_engine/third_party/__init__.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698