blob: 273ba91f595ed04402efb3327211c0e79eef02ef [file] [log] [blame]
# Copyright 2022 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 pipeline module."""
from typing import Generator
from recipe_engine import post_process, recipe_test_api
DEPS = [
'pigweed/pipeline',
'recipe_engine/step',
]
def RunSteps(api):
if not api.pipeline.in_pipeline:
api.step('not in pipeline', None)
return
api.step('in pipeline', None)
api.step(f'round {api.pipeline.round}', None)
prev_builds = api.pipeline.builds_from_previous_iteration
api.step(f'{len(prev_builds)} previous builds', None)
for build in prev_builds:
api.step(f'previous build {build}', None)
def GenTests(api) -> Generator[recipe_test_api.TestData, None, None]:
def ran(x):
return api.post_process(post_process.MustRun, x)
def drop():
return api.post_process(post_process.DropExpectation)
yield api.test('nopipeline') + ran('not in pipeline')
yield (
api.test('round_0')
+ api.pipeline.props(0, [])
+ ran('in pipeline')
+ ran('round 0')
+ ran('0 previous builds')
+ drop()
)
yield (
api.test('round_1')
+ api.pipeline.props(1, [123])
+ ran('in pipeline')
+ ran('round 1')
+ ran('1 previous builds')
+ ran('previous build 123')
+ drop()
)
yield (
api.test('round_4')
+ api.pipeline.props(4, [123, 456, 789])
+ ran('in pipeline')
+ ran('round 4')
+ ran('3 previous builds')
+ ran('previous build 123')
+ ran('previous build 456')
+ ran('previous build 789')
+ drop()
)
yield api.test('empty') + ran('not in pipeline') + drop()