blob: f490176b407fe916a797074d60fd08bd17c93a7f [file]
# Copyright 2024 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 non-repo non-submodule functionality of checkout module."""
from __future__ import annotations
from collections.abc import Iterator
from recipe_engine import recipe_api, recipe_test_api
from PB.recipe_modules.pigweed.checkout.tests.workspace import InputProperties
DEPS = [
'pigweed/checkout',
'recipe_engine/properties',
'recipe_engine/step',
]
INLINE_PROPERTIES_PROTO = """
import "recipe_modules/pigweed/checkout/options.proto";
message InputProperties {
// Checkout module options.
recipe_modules.pigweed.checkout.Options checkout_options = 1;
}
"""
PROPERTIES = InputProperties
def RunSteps(api: recipe_api.RecipeScriptApi, props: InputProperties):
checkout = api.checkout(props.checkout_options)
def steplog(name, value): # pylint: disable=invalid-name
with api.step.nest(name) as pres:
pres.step_summary_text = repr(value)
steplog('applied_changes', checkout.applied_changes())
def GenTests(api) -> Iterator[recipe_test_api.TestData]:
def properties(**kwargs):
kwargs.setdefault('eligible_workspace_paths', ('WORKSPACE',))
kwargs.setdefault('remote', 'https://pigweed.googlesource.com/foo')
kwargs.setdefault('branch', None)
return api.properties(
InputProperties(checkout_options=api.checkout.git_options(**kwargs))
)
yield api.test(
'found',
properties(),
api.checkout.try_test_data(),
)
yield api.test(
'not-found',
properties(),
api.checkout.try_test_data(git_repo='https://x.googlesource.com/bar'),
status='INFRA_FAILURE',
)