blob: 3ec093dceeab3f0ea8c26c43334baad8be9b6311 [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 checkout module."""
DEPS = [
'fuchsia/status_check',
'pigweed/checkout',
'recipe_engine/properties',
'recipe_engine/raw_io',
'recipe_engine/step',
]
def RunSteps(api): # pylint: disable=invalid-name
api.checkout()
def steplog(name, value):
with api.step.nest(name) as pres:
pres.step_summary_text = repr(value)
# These lines are needed for coverage.
steplog('root', api.checkout.root)
steplog('revision', api.checkout.revision)
# Intentional repeat (uses caching).
steplog('revision', api.checkout.revision)
steplog('remote', api.checkout.remote)
steplog('branch', api.checkout.branch)
steplog('manifest file', api.checkout.manifest_file)
steplog('manifest', api.checkout.manifest)
steplog('gerrit_host', api.checkout.gerrit_host())
steplog('gerrit_host_invalid', api.checkout.gerrit_host('bad'))
steplog('gerrit_project', api.checkout.gerrit_project())
steplog('gerrit_project_invalid', api.checkout.gerrit_project('bad'))
def GenTests(api): # pylint: disable=invalid-name
def props(host='https://pigweed.googlesource.com/pigweed/pigweed.git',
branch=None):
return api.properties(**api.checkout.git_properties(remote=host,
branch=branch))
yield (
api.status_check.test('ci')
+ props()
+ api.checkout.ci_test_data()
) # yapf: disable
yield (
api.status_check.test('try')
+ props()
+ api.checkout.try_test_data()
) # yapf: disable
yield (
api.status_check.test('other')
+ props()
) # yapf: disable
submodule_data = api.checkout.submodules(
foo='https://x.googlesource.com/foo',
bar='https://x.googlesource.com/bar',
baz='https://x.googlesource.com/baz.git',
# Using 'b/c/d' instead of 'a/b/c' because an 'a/' prefix is treated
# specially by Gerrit and the buildbucket module.
**{'b/c/d': 'https://x.googlesource.com/b/c/d'})
yield (
api.status_check.test('submodule-try')
+ props()
+ api.checkout.try_test_data(git_repo='https://x.googlesource.com/baz')
+ submodule_data
) # yapf: disable
yield (
api.status_check.test('submodule-ci')
+ props()
+ api.checkout.ci_test_data(git_repo='https://x.googlesource.com/b/c/d')
+ submodule_data
) # yapf: disable
yield (
api.status_check.test('submodule-gibberish', status='infra_failure')
+ props()
+ api.checkout.try_test_data(git_repo='https://x.googlesource.com/baz')
+ api.checkout.submodules(raw_submodule_status='GIBBERISH!')
) # yapf: disable
yield (
api.status_check.test('submodule-not-found', status='infra_failure')
+ props()
+ api.checkout.try_test_data(git_repo='https://x.googlesource.com/xyz')
+ submodule_data
) # yapf: disable