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 logging | 9 import logging |
10 import re | 10 import re |
(...skipping 13 matching lines...) Expand all Loading... |
24 class SimulationAnnotatorStreamEngine(stream.AnnotatorStreamEngine): | 24 class SimulationAnnotatorStreamEngine(stream.AnnotatorStreamEngine): |
25 | 25 |
26 def __init__(self): | 26 def __init__(self): |
27 self._step_buffer_map = {} | 27 self._step_buffer_map = {} |
28 super(SimulationAnnotatorStreamEngine, self).__init__( | 28 super(SimulationAnnotatorStreamEngine, self).__init__( |
29 self.step_buffer(None)) | 29 self.step_buffer(None)) |
30 | 30 |
31 def step_buffer(self, step_name): | 31 def step_buffer(self, step_name): |
32 return self._step_buffer_map.setdefault(step_name, StringIO.StringIO()) | 32 return self._step_buffer_map.setdefault(step_name, StringIO.StringIO()) |
33 | 33 |
34 def _new_step_stream(self, step_name, allow_subannotations, nest_level): | 34 def new_step_stream(self, step_config): |
35 return self._create_step_stream( | 35 return self._create_step_stream(step_config, |
36 step_name, | 36 self.step_buffer(step_config.name)) |
37 self.step_buffer(step_name), | |
38 allow_subannotations, | |
39 nest_level) | |
40 | 37 |
41 | 38 |
42 def RunRecipe(test_data): | 39 def RunRecipe(test_data): |
43 from . import config_types | 40 from . import config_types |
44 from . import loader | 41 from . import loader |
45 from . import run | 42 from . import run |
46 from . import step_runner | 43 from . import step_runner |
47 from . import stream | 44 from . import stream |
48 | 45 |
49 config_types.ResetTostringFns() | 46 config_types.ResetTostringFns() |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 'TESTING_SLAVENAME']: | 136 'TESTING_SLAVENAME']: |
140 if env_var in os.environ: | 137 if env_var in os.environ: |
141 logging.warn("Ignoring %s environment variable." % env_var) | 138 logging.warn("Ignoring %s environment variable." % env_var) |
142 os.environ.pop(env_var) | 139 os.environ.pop(env_var) |
143 | 140 |
144 global _UNIVERSE | 141 global _UNIVERSE |
145 _UNIVERSE = universe | 142 _UNIVERSE = universe |
146 | 143 |
147 expect_tests.main('recipe_simulation_test', GenerateTests, | 144 expect_tests.main('recipe_simulation_test', GenerateTests, |
148 cover_omit=cover_omit(), args=args) | 145 cover_omit=cover_omit(), args=args) |
OLD | NEW |