| # Copyright 2020 The Pigweed Authors |
| # |
| # Licensed under the Apache License, Version 2.0 (the "License"); you may not |
| # use this file except in compliance with the License. You may obtain a copy of |
| # the License at |
| # |
| # https://www.apache.org/licenses/LICENSE-2.0 |
| # |
| # Unless required by applicable law or agreed to in writing, software |
| # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| # License for the specific language governing permissions and limitations under |
| # the License. |
| """Full test of environment module.""" |
| |
| from PB.recipe_modules.pigweed.environment.tests.full import InputProperties |
| |
| DEPS = [ |
| 'fuchsia/status_check', |
| 'pigweed/environment', |
| 'recipe_engine/path', |
| 'recipe_engine/platform', |
| 'recipe_engine/properties', |
| ] |
| |
| PROPERTIES = InputProperties |
| |
| PYTHON_VERSION_COMPATIBILITY = "PY3" |
| |
| |
| def RunSteps(api, props): # pylint: disable=invalid-name |
| # pylint: disable=missing-function-docstring |
| env = api.environment.init( |
| checkout_root=api.path['start_dir'], |
| use_constraint_file=False, |
| options=props.environment_options, |
| ) |
| |
| # The next couple lines help cover all of api.py. |
| try: |
| # VIRTUAL_ENV is set in almost all cases, but not in the 'empty' test. |
| _ = env.VIRTUAL_ENV |
| _ = api.environment.VIRTUAL_ENV |
| _ = api.environment.VARIABLE_NAME_UNLIKELY_TO_BE_USED_ELSEWHERE |
| except AttributeError: |
| pass |
| |
| with api.environment(): |
| pass |
| |
| with env(): |
| pass |
| |
| |
| def GenTests(api): # pylint: disable=invalid-name |
| def properties(**kwargs): |
| props = {'environment_options': api.environment.properties()} |
| props.update(kwargs) |
| return api.properties(**props) |
| |
| yield ( |
| api.status_check.test('normal') |
| + properties(**{'$recipe_engine/led': {'led_run_id': '123'}}) |
| + api.platform.name('mac') |
| + api.environment.test_data() |
| ) |
| |
| yield ( |
| api.status_check.test('windows') |
| + properties() |
| + api.platform.name('win') |
| ) |
| |
| yield api.status_check.test('empty') |