| 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 copy | 8 import copy |
| 9 import json | 9 import json |
| 10 import logging | 10 import logging |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 # Make sure disabling strict coverage also disables our additional check | 166 # Make sure disabling strict coverage also disables our additional check |
| 167 # for module coverage. Note that coverage will still raise an error if | 167 # for module coverage. Note that coverage will still raise an error if |
| 168 # the module is executed by any of the tests, but having less than 100% | 168 # the module is executed by any of the tests, but having less than 100% |
| 169 # coverage. | 169 # coverage. |
| 170 for module in all_modules: | 170 for module in all_modules: |
| 171 mod = _UNIVERSE_VIEW.load_recipe_module(module) | 171 mod = _UNIVERSE_VIEW.load_recipe_module(module) |
| 172 # Recipe modules can only be covered by tests inside the same module. | 172 # Recipe modules can only be covered by tests inside the same module. |
| 173 # To make transition possible for existing code (which will require | 173 # To make transition possible for existing code (which will require |
| 174 # writing tests), a temporary escape hatch is added. | 174 # writing tests), a temporary escape hatch is added. |
| 175 # TODO(phajdan.jr): remove DISABLE_STRICT_COVERAGE (crbug/693058). | 175 # TODO(phajdan.jr): remove DISABLE_STRICT_COVERAGE (crbug/693058). |
| 176 if (getattr(mod, 'DISABLE_STRICT_COVERAGE', False)): | 176 if mod.DISABLE_STRICT_COVERAGE: |
| 177 covered_modules.add(module) | 177 covered_modules.add(module) |
| 178 base_covers.append(os.path.join( | 178 base_covers.append(os.path.join( |
| 179 _UNIVERSE_VIEW.module_dir, module, '*.py')) | 179 _UNIVERSE_VIEW.module_dir, module, '*.py')) |
| 180 | 180 |
| 181 for recipe_path, recipe_name in _UNIVERSE_VIEW.loop_over_recipes(): | 181 for recipe_path, recipe_name in _UNIVERSE_VIEW.loop_over_recipes(): |
| 182 try: | 182 try: |
| 183 recipe = _UNIVERSE_VIEW.load_recipe(recipe_name) | 183 recipe = _UNIVERSE_VIEW.load_recipe(recipe_name) |
| 184 test_api = loader.create_test_api(recipe.LOADED_DEPS, _UNIVERSE_VIEW) | 184 test_api = loader.create_test_api(recipe.LOADED_DEPS, _UNIVERSE_VIEW) |
| 185 | 185 |
| 186 covers = [recipe_path] + base_covers | 186 covers = [recipe_path] + base_covers |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 logging.warn("Ignoring %s environment variable." % env_var) | 233 logging.warn("Ignoring %s environment variable." % env_var) |
| 234 os.environ.pop(env_var) | 234 os.environ.pop(env_var) |
| 235 | 235 |
| 236 global _UNIVERSE_VIEW | 236 global _UNIVERSE_VIEW |
| 237 _UNIVERSE_VIEW = universe_view | 237 _UNIVERSE_VIEW = universe_view |
| 238 global _ENGINE_FLAGS | 238 global _ENGINE_FLAGS |
| 239 _ENGINE_FLAGS = engine_flags | 239 _ENGINE_FLAGS = engine_flags |
| 240 | 240 |
| 241 expect_tests_main('recipe_simulation_test', GenerateTests, | 241 expect_tests_main('recipe_simulation_test', GenerateTests, |
| 242 cover_omit=cover_omit(), args=args) | 242 cover_omit=cover_omit(), args=args) |
| OLD | NEW |