OLD | NEW |
1 # Copyright 2014-2015 The Chromium Authors. All rights reserved. | 1 # Copyright 2014-2015 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # 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 logging | 7 import logging |
8 import re | 8 import re |
9 import os | 9 import os |
10 import sys | 10 import sys |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 yield expect_tests.Test( | 67 yield expect_tests.Test( |
68 '%s.%s' % (recipe_name, test_data.name), | 68 '%s.%s' % (recipe_name, test_data.name), |
69 expect_tests.FuncCall(RunRecipe, test_data), | 69 expect_tests.FuncCall(RunRecipe, test_data), |
70 expect_dir=expect_path, | 70 expect_dir=expect_path, |
71 expect_base=test_data.name, | 71 expect_base=test_data.name, |
72 covers=covers, | 72 covers=covers, |
73 break_funcs=(recipe.RunSteps,) | 73 break_funcs=(recipe.RunSteps,) |
74 ) | 74 ) |
75 | 75 |
76 | 76 |
77 def main(universe): | 77 def main(package_cfg, args=None): |
78 """Runs simulation tests on a given repo of recipes. | 78 """Runs simulation tests on a given repo of recipes. |
79 | 79 |
80 Args: | 80 Args: |
81 universe: a RecipeUniverse to operate on. | 81 package_cfg: the path to a recipes.cfg to operate on, or |
| 82 an existing PackageDeps object |
| 83 args: command line arguments to expect_tests |
82 Returns: | 84 Returns: |
83 Doesn't -- exits with a status code | 85 Doesn't -- exits with a status code |
84 """ | 86 """ |
| 87 from . import loader |
| 88 from . import package |
85 | 89 |
86 # annotated_run has different behavior when these environment variables | 90 # annotated_run has different behavior when these environment variables |
87 # are set, so unset to make simulation tests environment-invariant. | 91 # are set, so unset to make simulation tests environment-invariant. |
88 for env_var in ['TESTING_MASTER_HOST', | 92 for env_var in ['TESTING_MASTER_HOST', |
89 'TESTING_MASTER', | 93 'TESTING_MASTER', |
90 'TESTING_SLAVENAME']: | 94 'TESTING_SLAVENAME']: |
91 if env_var in os.environ: | 95 if env_var in os.environ: |
92 logging.warn("Ignoring %s environment variable." % env_var) | 96 logging.warn("Ignoring %s environment variable." % env_var) |
93 os.environ.pop(env_var) | 97 os.environ.pop(env_var) |
94 | 98 |
95 global _UNIVERSE | 99 global _UNIVERSE |
96 _UNIVERSE = universe | 100 if isinstance(package_cfg, package.PackageDeps): |
| 101 package_deps = package_cfg |
| 102 else: |
| 103 package_deps = package.PackageDeps.create(package_cfg) |
| 104 _UNIVERSE = loader.RecipeUniverse(package_deps) |
| 105 |
97 expect_tests.main('recipe_simulation_test', GenerateTests, | 106 expect_tests.main('recipe_simulation_test', GenerateTests, |
98 cover_omit=cover_omit()) | 107 cover_omit=cover_omit(), args=args) |
OLD | NEW |