| 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 ast | 8 import ast |
| 9 import contextlib | 9 import contextlib |
| 10 import copy | 10 import copy |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 with stream.StreamEngineInvariants.wrap(annotator) as stream_engine: | 107 with stream.StreamEngineInvariants.wrap(annotator) as stream_engine: |
| 108 step_runner = step_runner.SimulationStepRunner(stream_engine, test_data, | 108 step_runner = step_runner.SimulationStepRunner(stream_engine, test_data, |
| 109 annotator) | 109 annotator) |
| 110 | 110 |
| 111 props = test_data.properties.copy() | 111 props = test_data.properties.copy() |
| 112 props['recipe'] = recipe_name | 112 props['recipe'] = recipe_name |
| 113 engine = run.RecipeEngine( | 113 engine = run.RecipeEngine( |
| 114 step_runner, props, _UNIVERSE, engine_flags=_ENGINE_FLAGS) | 114 step_runner, props, _UNIVERSE, engine_flags=_ENGINE_FLAGS) |
| 115 recipe_script = _UNIVERSE.load_recipe(recipe_name, engine=engine) | 115 recipe_script = _UNIVERSE.load_recipe(recipe_name, engine=engine) |
| 116 | 116 |
| 117 api = loader.create_recipe_api(recipe_script.LOADED_DEPS, engine, test_data) | 117 api = loader.create_recipe_api( |
| 118 _UNIVERSE.universe.package_deps.root_package, recipe_script.LOADED_DEPS, |
| 119 recipe_script.path, engine, test_data) |
| 118 result = engine.run(recipe_script, api, test_data.properties) | 120 result = engine.run(recipe_script, api, test_data.properties) |
| 119 | 121 |
| 120 raw_expectations = step_runner.steps_ran.copy() | 122 raw_expectations = step_runner.steps_ran.copy() |
| 121 # Don't include tracebacks in expectations because they are too sensitive to | 123 # Don't include tracebacks in expectations because they are too sensitive to |
| 122 # change. | 124 # change. |
| 123 if _ENGINE_FLAGS.use_result_proto: | 125 if _ENGINE_FLAGS.use_result_proto: |
| 124 if result.HasField('failure'): | 126 if result.HasField('failure'): |
| 125 result.failure.ClearField('traceback') | 127 result.failure.ClearField('traceback') |
| 126 result_json = json.loads( | 128 result_json = json.loads( |
| 127 jsonpb.MessageToJson(result, including_default_value_fields=True)) | 129 jsonpb.MessageToJson(result, including_default_value_fields=True)) |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 logging.warn("Ignoring %s environment variable." % env_var) | 223 logging.warn("Ignoring %s environment variable." % env_var) |
| 222 os.environ.pop(env_var) | 224 os.environ.pop(env_var) |
| 223 | 225 |
| 224 global _UNIVERSE | 226 global _UNIVERSE |
| 225 _UNIVERSE = universe | 227 _UNIVERSE = universe |
| 226 global _ENGINE_FLAGS | 228 global _ENGINE_FLAGS |
| 227 _ENGINE_FLAGS = engine_flags | 229 _ENGINE_FLAGS = engine_flags |
| 228 | 230 |
| 229 expect_tests.main('recipe_simulation_test', GenerateTests, | 231 expect_tests.main('recipe_simulation_test', GenerateTests, |
| 230 cover_omit=cover_omit(), args=args) | 232 cover_omit=cover_omit(), args=args) |
| OLD | NEW |