blob: 75e869bab70e112e9b356cc807c77bf6d7f98080 [file] [log] [blame]
# 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."""
import attr
from PB.recipe_modules.pigweed.environment.tests.full import InputProperties
DEPS = [
'pigweed/environment',
'recipe_engine/path',
'recipe_engine/platform',
'recipe_engine/properties',
]
PROPERTIES = InputProperties
@attr.s
class _FakeCheckoutContext:
root = attr.ib()
changes_json = attr.ib(default=None)
def RunSteps(api, props): # pylint: disable=invalid-name
# pylint: disable=missing-function-docstring
env = api.environment.init(
checkout=_FakeCheckoutContext(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
_ = env.VARIABLE_NAME_UNLIKELY_TO_BE_USED_ELSEWHERE
except AttributeError:
pass
with env():
pass
def GenTests(api): # pylint: disable=invalid-name
yield (
api.test('normal')
+ api.environment.properties(skip_submodule_check=True)
+ api.properties(**{'$recipe_engine/led': {'led_run_id': '123'}})
+ api.platform.name('mac')
)
yield (
api.test('doctor-fail')
+ api.environment.properties(
skip_submodule_check=True, additional_cipd_files=('override.json',),
)
+ api.platform.name('linux')
+ api.step_data('environment.doctor', retcode=1)
)
yield (
api.test('windows')
+ api.environment.properties(additional_variables=dict(ABC=123))
+ api.platform.name('win')
)
yield (
api.test('override-cipd')
+ api.environment.properties(skip_submodule_check=True)
+ api.environment.override_clang(source='cipd', version='latest')
)
yield (
api.test('override-cas')
+ api.environment.properties(skip_submodule_check=True)
+ api.environment.override_clang(source='isolated', version='123456')
)
yield api.test('empty')