| OLD | NEW |
| 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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 annotator = SimulationAnnotatorStreamEngine() | 83 annotator = SimulationAnnotatorStreamEngine() |
| 84 stream_engine = stream.ProductStreamEngine( | 84 with stream.StreamEngineInvariants.wrap(annotator) as stream_engine: |
| 85 stream.StreamEngineInvariants(), | |
| 86 annotator) | |
| 87 with stream_engine: | |
| 88 step_runner = step_runner.SimulationStepRunner(stream_engine, test_data, | 85 step_runner = step_runner.SimulationStepRunner(stream_engine, test_data, |
| 89 annotator) | 86 annotator) |
| 90 | 87 |
| 91 engine = run.RecipeEngine(step_runner, test_data.properties, _UNIVERSE) | 88 engine = run.RecipeEngine(step_runner, test_data.properties, _UNIVERSE) |
| 92 recipe_script = _UNIVERSE.load_recipe(test_data.properties['recipe']) | 89 recipe_script = _UNIVERSE.load_recipe(test_data.properties['recipe']) |
| 93 api = loader.create_recipe_api(recipe_script.LOADED_DEPS, engine, test_data) | 90 api = loader.create_recipe_api(recipe_script.LOADED_DEPS, engine, test_data) |
| 94 result = engine.run(recipe_script, api) | 91 result = engine.run(recipe_script, api) |
| 95 | 92 |
| 96 # Don't include tracebacks in expectations because they are too sensitive to | 93 # Don't include tracebacks in expectations because they are too sensitive to |
| 97 # change. | 94 # change. |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 'TESTING_SLAVENAME']: | 190 'TESTING_SLAVENAME']: |
| 194 if env_var in os.environ: | 191 if env_var in os.environ: |
| 195 logging.warn("Ignoring %s environment variable." % env_var) | 192 logging.warn("Ignoring %s environment variable." % env_var) |
| 196 os.environ.pop(env_var) | 193 os.environ.pop(env_var) |
| 197 | 194 |
| 198 global _UNIVERSE | 195 global _UNIVERSE |
| 199 _UNIVERSE = universe | 196 _UNIVERSE = universe |
| 200 | 197 |
| 201 expect_tests.main('recipe_simulation_test', GenerateTests, | 198 expect_tests.main('recipe_simulation_test', GenerateTests, |
| 202 cover_omit=cover_omit(), args=args) | 199 cover_omit=cover_omit(), args=args) |
| OLD | NEW |