| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2014 The Chromium Authors. All rights reserved. | 2 # Copyright 2014 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 """Provides simulator test coverage for individual recipes.""" | 6 """Provides simulator test coverage for individual recipes.""" |
| 7 | 7 |
| 8 import logging | 8 import logging |
| 9 import os | 9 import os |
| 10 | 10 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 return expect_tests.Result(ret) | 55 return expect_tests.Result(ret) |
| 56 | 56 |
| 57 | 57 |
| 58 def test_gen_coverage(): | 58 def test_gen_coverage(): |
| 59 return ( | 59 return ( |
| 60 [os.path.join(x, '*') for x in recipe_util.RECIPE_DIRS()] + | 60 [os.path.join(x, '*') for x in recipe_util.RECIPE_DIRS()] + |
| 61 [os.path.join(x, '*', 'example.py') for x in recipe_util.MODULE_DIRS()] + | 61 [os.path.join(x, '*', 'example.py') for x in recipe_util.MODULE_DIRS()] + |
| 62 [os.path.join(x, '*', 'test_api.py') for x in recipe_util.MODULE_DIRS()] | 62 [os.path.join(x, '*', 'test_api.py') for x in recipe_util.MODULE_DIRS()] |
| 63 ) | 63 ) |
| 64 | 64 |
| 65 @expect_tests.generator |
| 65 @expect_tests.covers(test_gen_coverage) | 66 @expect_tests.covers(test_gen_coverage) |
| 66 def GenerateTests(): | 67 def GenerateTests(): |
| 67 cover_mods = [] | 68 cover_mods = [] |
| 68 for mod_dir_base in recipe_util.MODULE_DIRS(): | 69 for mod_dir_base in recipe_util.MODULE_DIRS(): |
| 69 if os.path.isdir(mod_dir_base): | 70 if os.path.isdir(mod_dir_base): |
| 70 cover_mods.append(os.path.join(mod_dir_base, '*', '*api.py')) | 71 cover_mods.append(os.path.join(mod_dir_base, '*', '*api.py')) |
| 71 | 72 |
| 72 for recipe_path, recipe_name in recipe_loader.loop_over_recipes(): | 73 for recipe_path, recipe_name in recipe_loader.loop_over_recipes(): |
| 73 recipe = recipe_loader.load_recipe(recipe_name) | 74 recipe = recipe_loader.load_recipe(recipe_name) |
| 74 test_api = recipe_loader.create_test_api(recipe.DEPS) | 75 test_api = recipe_loader.create_test_api(recipe.DEPS) |
| (...skipping 19 matching lines...) Expand all Loading... |
| 94 if __name__ == '__main__': | 95 if __name__ == '__main__': |
| 95 # annotated_run.py has different behavior when these environment variables | 96 # annotated_run.py has different behavior when these environment variables |
| 96 # are set, so unset to make simulation tests environment-invariant. | 97 # are set, so unset to make simulation tests environment-invariant. |
| 97 for env_var in ['TESTING_MASTER_HOST', | 98 for env_var in ['TESTING_MASTER_HOST', |
| 98 'TESTING_MASTER', | 99 'TESTING_MASTER', |
| 99 'TESTING_SLAVENAME']: | 100 'TESTING_SLAVENAME']: |
| 100 if env_var in os.environ: | 101 if env_var in os.environ: |
| 101 logging.warn("Ignoring %s environment variable." % env_var) | 102 logging.warn("Ignoring %s environment variable." % env_var) |
| 102 os.environ.pop(env_var) | 103 os.environ.pop(env_var) |
| 103 | 104 |
| 104 expect_tests.main('recipe_simulation_test', GenerateTests) | 105 expect_tests.main() |
| OLD | NEW |