blob: cffa121a8c75dafac29f3aea02628f718cca3aca [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 the cq_deps module."""
from recipe_engine.config import List
from recipe_engine.recipe_api import Property
DEPS = [
'fuchsia/status_check',
'pigweed/cq_deps',
'recipe_engine/properties',
'recipe_engine/step',
]
PROPERTIES = {
'revision': Property(kind=str, default=None),
'statuses': Property(kind=List(str), default=('NEW',)),
}
def RunSteps(api, revision, statuses):
deps, errors = api.cq_deps.resolve(
'pigweed', revision or 1, statuses=statuses,
)
with api.step.nest('final deps'):
for dep in deps:
with api.step.nest(dep.name) as pres:
pres.step_summary_text = dep.remote
_ = dep.gerrit_url # For coverage.
if errors:
with api.step.nest('errors'):
for error in errors:
with api.step.nest(error.name):
pass
def GenTests(api):
yield (
api.status_check.test('hash')
+ api.properties(revision='b' * 40)
+ api.cq_deps.lookup_cl('b' * 40, 1)
+ api.cq_deps.details('pigweed:1', '')
)
yield (
api.status_check.test('cl-not-found')
+ api.properties(revision='b' * 40)
+ api.cq_deps.lookup_cl('b' * 40, found=False)
)
yield (
api.status_check.test('one')
+ api.cq_deps.details('pigweed:1', 'Requires: pigweed:2')
+ api.cq_deps.has_deps('pigweed:2')
+ api.cq_deps.lacks_deps('pigweed:1')
)
yield (
api.status_check.test('disabled')
+ api.properties(**api.cq_deps.properties(disabled=True))
+ api.cq_deps.assert_disabled()
)
yield (
api.status_check.test('ignore_errors')
+ api.properties(**api.cq_deps.properties(ignore_errors=True))
+ api.cq_deps.details('pigweed:1', 'Requires: invalid')
)
yield (
api.status_check.test('two')
+ api.cq_deps.details('pigweed:1', 'Requires: pigweed:2, pigweed:3')
+ api.cq_deps.has_deps('pigweed:2', 'pigweed:3')
)
yield (
api.status_check.test('no_space')
+ api.cq_deps.details('pigweed:1', 'Requires: pigweed:2,pigweed:3')
+ api.cq_deps.has_deps('pigweed:2', 'pigweed:3')
)
yield (
api.status_check.test('no_gerrit_name')
+ api.cq_deps.details('pigweed:1', 'Requires: 2')
+ api.cq_deps.has_deps('pigweed:2')
)
yield (
api.status_check.test('loop_two')
+ api.cq_deps.details('pigweed:1', 'Requires: pigweed:2')
+ api.cq_deps.details('pigweed:2', 'Requires: pigweed:1')
+ api.cq_deps.has_deps('pigweed:2')
)
yield (
api.status_check.test('loop_three')
+ api.cq_deps.details('pigweed:1', 'Requires: pigweed:2')
+ api.cq_deps.details('pigweed:2', 'Requires: pigweed:3')
+ api.cq_deps.details('pigweed:3', 'Requires: pigweed:1')
+ api.cq_deps.has_deps('pigweed:2', 'pigweed:3')
)
yield (
api.status_check.test('abandoned')
+ api.cq_deps.details('pigweed:1', 'Requires: pigweed:2')
+ api.cq_deps.details(
'pigweed:2', 'Requires: pigweed:3', status='ABANDONED'
)
+ api.cq_deps.lacks_deps('pigweed:2')
)
yield (
api.status_check.test('merged_skipped')
+ api.properties()
+ api.cq_deps.details('pigweed:1', 'Requires: pigweed:2')
+ api.cq_deps.details(
'pigweed:2', 'Requires: pigweed:3', status='MERGED'
)
+ api.cq_deps.lacks_deps('pigweed:2', 'pigweed:3')
)
yield (
api.status_check.test('merged_ok')
+ api.properties(statuses=('NEW', 'MERGED'))
+ api.cq_deps.details('pigweed:1', 'Requires: pigweed:2')
+ api.cq_deps.details(
'pigweed:2', 'Requires: pigweed:3', status='MERGED'
)
+ api.cq_deps.has_deps('pigweed:2', 'pigweed:3')
)
yield (
api.status_check.test('bad_field_name')
+ api.cq_deps.details('pigweed:1', 'Depends: pigweed:2')
+ api.cq_deps.lacks_deps('pigweed:2')
)
yield (
api.status_check.test('commas')
+ api.cq_deps.details('pigweed:1', 'Requires: ,,pigweed:2,')
+ api.cq_deps.has_deps('pigweed:2')
)
yield (
api.status_check.test('error')
+ api.cq_deps.details('pigweed:1', 'Requires: pigweed:2')
+ api.cq_deps.transient('pigweed:2')
+ api.cq_deps.transient('pigweed:2', n=2)
+ api.cq_deps.lacks_deps('forbidden:1')
)
yield (
api.status_check.test('error_recovery')
+ api.cq_deps.details('pigweed:1', 'Requires: pigweed:2')
+ api.cq_deps.transient('pigweed:2')
+ api.cq_deps.details('pigweed:2', '', n=2)
+ api.cq_deps.has_deps('pigweed:2')
)
yield (
api.status_check.test('forbidden')
+ api.cq_deps.details('pigweed:1', 'Requires: forbidden:1')
+ api.cq_deps.forbidden('forbidden:1')
+ api.cq_deps.lacks_deps('forbidden:1')
)
yield (
api.status_check.test('multiline')
+ api.cq_deps.details(
'pigweed:1', 'Requires: pigweed:2\nRequires: pigweed:3'
)
+ api.cq_deps.has_deps('pigweed:2', 'pigweed:3')
)
yield (
api.status_check.test('unsubmitted-parent-dependencies')
+ api.cq_deps.details('pigweed:1', '', parent='PIGWEED2')
+ api.cq_deps.lookup_cl('PIGWEED2', 2)
+ api.cq_deps.details(
'pigweed:2', 'Requires: pigweed:3', commit_hash='PIGWEED2',
)
+ api.cq_deps.has_deps('pigweed:3')
)
yield (
api.status_check.test('dependency-requires-parent')
+ api.cq_deps.details(
'pigweed:1', 'Requires: pigweed:3', parent='PIGWEED2',
)
+ api.cq_deps.lookup_cl('PIGWEED2', 2)
+ api.cq_deps.details('pigweed:3', 'Requires: pigweed:2',)
+ api.cq_deps.lacks_deps('pigweed:2')
+ api.cq_deps.has_deps('pigweed:3')
)
yield (
api.status_check.test('out-of-date-parent', status='failure')
+ api.cq_deps.details('pigweed:1', '', parent='OUTOFDATE')
+ api.cq_deps.lookup_cl('OUTOFDATE', 2)
+ api.cq_deps.details('pigweed:2', commit_hash='CURRENT')
)
yield (
api.status_check.test('no-parent-cl')
+ api.cq_deps.details('pigweed:1', '', parent='NOCL')
+ api.cq_deps.lookup_cl('NOCL')
)
yield (
api.status_check.test('gibberish-requirement', status='failure')
+ api.cq_deps.details('pigweed:1', 'Requires: GIBBERISH')
)