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

Side by Side Diff: recipe_engine/simulation_test.py

Issue 2415793003: Setup basic Runtime with properties and platform.
Patch Set: Created 4 years, 2 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
OLDNEW
1 # Copyright 2014 The LUCI Authors. All rights reserved. 1 # Copyright 2014 The LUCI Authors. All rights reserved.
2 # Use of this source code is governed under the Apache License, Version 2.0 2 # Use of this source code is governed under the Apache License, Version 2.0
3 # that can be found in the LICENSE file. 3 # that can be found in the LICENSE file.
4 4
5 """Provides simulator test coverage for individual recipes.""" 5 """Provides simulator test coverage for individual recipes."""
6 6
7 import StringIO 7 import StringIO
8 import contextlib 8 import contextlib
9 import json 9 import json
10 import logging 10 import logging
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 def RunRecipe(test_data): 73 def RunRecipe(test_data):
74 """Actually runs the recipe given the GenTests-supplied test_data.""" 74 """Actually runs the recipe given the GenTests-supplied test_data."""
75 from . import config_types 75 from . import config_types
76 from . import loader 76 from . import loader
77 from . import run 77 from . import run
78 from . import step_runner 78 from . import step_runner
79 from . import stream 79 from . import stream
80 80
81 config_types.ResetTostringFns() 81 config_types.ResetTostringFns()
82 82
83 rt = run.Runtime(test_data.properties)
83 annotator = SimulationAnnotatorStreamEngine() 84 annotator = SimulationAnnotatorStreamEngine()
84 with stream.StreamEngineInvariants.wrap(annotator) as stream_engine: 85 with stream.StreamEngineInvariants.wrap(annotator) as stream_engine:
85 step_runner = step_runner.SimulationStepRunner(stream_engine, test_data, 86 step_runner = step_runner.SimulationStepRunner(stream_engine, test_data,
86 annotator) 87 annotator)
87 88
88 engine = run.RecipeEngine(step_runner, test_data.properties, _UNIVERSE) 89 engine = run.RecipeEngine(step_runner, rt, _UNIVERSE)
89 recipe_script = _UNIVERSE.load_recipe(test_data.properties['recipe'], 90 recipe_script = _UNIVERSE.load_recipe(test_data.properties['recipe'],
90 engine=engine) 91 engine=engine)
91 api = loader.create_recipe_api(recipe_script.LOADED_DEPS, engine, test_data) 92 api = loader.create_recipe_api(recipe_script.LOADED_DEPS, engine, test_data)
92 result = engine.run(recipe_script, api, test_data.properties) 93 result = engine.run(recipe_script, api, test_data.properties)
93 94
94 # Don't include tracebacks in expectations because they are too sensitive to 95 # Don't include tracebacks in expectations because they are too sensitive to
95 # change. 96 # change.
96 result.result.pop('traceback', None) 97 result.result.pop('traceback', None)
97 raw_expectations = step_runner.steps_ran + [result.result] 98 raw_expectations = step_runner.steps_ran + [result.result]
98 99
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 'TESTING_SLAVENAME']: 192 'TESTING_SLAVENAME']:
192 if env_var in os.environ: 193 if env_var in os.environ:
193 logging.warn("Ignoring %s environment variable." % env_var) 194 logging.warn("Ignoring %s environment variable." % env_var)
194 os.environ.pop(env_var) 195 os.environ.pop(env_var)
195 196
196 global _UNIVERSE 197 global _UNIVERSE
197 _UNIVERSE = universe 198 _UNIVERSE = universe
198 199
199 expect_tests.main('recipe_simulation_test', GenerateTests, 200 expect_tests.main('recipe_simulation_test', GenerateTests,
200 cover_omit=cover_omit(), args=args) 201 cover_omit=cover_omit(), args=args)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698