| 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 |
| 11 # Importing for side effects on sys.path? Yes... yes we are :( | 11 # Importing for side effects on sys.path? Yes... yes we are :( |
| 12 import test_env # pylint: disable=W0611,W0403 | 12 import test_env # pylint: disable=W0611,W0403 |
| 13 | 13 |
| 14 from common import annotator | 14 from common import annotator |
| 15 from slave import annotated_run | 15 from slave import annotated_run |
| 16 from slave import recipe_config_types | 16 from slave import recipe_config_types |
| 17 from slave import recipe_loader | 17 from slave import recipe_loader |
| 18 from slave import recipe_util | 18 from slave import recipe_util |
| 19 | 19 |
| 20 import expect_tests # pylint: disable=W0403 | 20 import expect_tests # pylint: disable=W0403 |
| 21 | 21 |
| 22 | 22 |
| 23 def RunRecipe(test_data): | 23 def RunRecipe(test_data): |
| 24 stream = annotator.StructuredAnnotationStream(stream=open(os.devnull, 'w')) | 24 stream = annotator.StructuredAnnotationStream(stream=open(os.devnull, 'w')) |
| 25 recipe_config_types.ResetTostringFns() | 25 recipe_config_types.ResetTostringFns() |
| 26 # TODO(iannucci): Only pass test_data once. | 26 # TODO(iannucci): Only pass test_data once. |
| 27 result = annotated_run.run_steps(stream, test_data.properties, | 27 result = annotated_run.run_steps(stream, test_data.properties, |
| 28 test_data.properties, test_data) | 28 test_data.properties, test_data) |
| 29 | 29 |
| 30 return expect_tests.Result(list(s.step for s in result.steps_ran.values())) | 30 return expect_tests.Result(list(result.steps_ran.values())) |
| 31 | 31 |
| 32 | 32 |
| 33 def test_gen_coverage(): | 33 def test_gen_coverage(): |
| 34 return ( | 34 return ( |
| 35 [os.path.join(x, '*') for x in recipe_util.RECIPE_DIRS()] + | 35 [os.path.join(x, '*') for x in recipe_util.RECIPE_DIRS()] + |
| 36 [os.path.join(x, '*', 'example.py') for x in recipe_util.MODULE_DIRS()] + | 36 [os.path.join(x, '*', 'example.py') for x in recipe_util.MODULE_DIRS()] + |
| 37 [os.path.join(x, '*', 'test_api.py') for x in recipe_util.MODULE_DIRS()] | 37 [os.path.join(x, '*', 'test_api.py') for x in recipe_util.MODULE_DIRS()] |
| 38 ) | 38 ) |
| 39 | 39 |
| 40 @expect_tests.covers(test_gen_coverage) | 40 @expect_tests.covers(test_gen_coverage) |
| (...skipping 29 matching lines...) Expand all Loading... |
| 70 # annotated_run.py has different behavior when these environment variables | 70 # annotated_run.py has different behavior when these environment variables |
| 71 # are set, so unset to make simulation tests environment-invariant. | 71 # are set, so unset to make simulation tests environment-invariant. |
| 72 for env_var in ['TESTING_MASTER_HOST', | 72 for env_var in ['TESTING_MASTER_HOST', |
| 73 'TESTING_MASTER', | 73 'TESTING_MASTER', |
| 74 'TESTING_SLAVENAME']: | 74 'TESTING_SLAVENAME']: |
| 75 if env_var in os.environ: | 75 if env_var in os.environ: |
| 76 logging.warn("Ignoring %s environment variable." % env_var) | 76 logging.warn("Ignoring %s environment variable." % env_var) |
| 77 os.environ.pop(env_var) | 77 os.environ.pop(env_var) |
| 78 | 78 |
| 79 expect_tests.main('recipe_simulation_test', GenerateTests) | 79 expect_tests.main('recipe_simulation_test', GenerateTests) |
| OLD | NEW |