blob: f7efd15af54ecb2524ba6aa97fde094f855f65b8 [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.
"""Test of rolls of multiple repositories."""
from typing import Generator
from recipe_engine import recipe_test_api
DEPS = [
'pigweed/roll_util',
'recipe_engine/path',
'recipe_engine/step',
]
def RunSteps(api):
# pylint: disable=unnecessary-lambda
path = lambda name: api.path.start_dir / name
rolls = [
api.roll_util.create_roll(
project_name='abc',
old_revision='1' * 40,
new_revision='4' * 40,
proj_dir=path('abc'),
direction=api.roll_util.Direction.FORWARD,
),
api.roll_util.create_roll(
project_name='xyz',
old_revision='9' * 40,
new_revision='c' * 40,
proj_dir=path('xyz'),
direction=api.roll_util.Direction.FORWARD,
),
api.roll_util.create_roll(
project_name='def',
old_revision='5' * 40,
new_revision='8' * 40,
proj_dir=path('def'),
direction=api.roll_util.Direction.FORWARD,
),
]
# For coverage of Account.__lt__.
accounts = [
api.roll_util.Account('bb', 'bb@bb.bb'),
api.roll_util.Account('aa', 'aa@aa.aa'),
]
accounts = sorted(accounts)
message = api.roll_util.message(*rolls)
with api.step.nest('message') as pres:
pres.logs['message'] = message
def GenTests(api) -> Generator[recipe_test_api.TestData, None, None]:
yield (
api.test('single_commits')
+ api.roll_util.commit_data('abc', api.roll_util.commit('4' * 40))
+ api.roll_util.commit_data('def', api.roll_util.commit('8' * 40))
+ api.roll_util.commit_data('xyz', api.roll_util.commit('c' * 40))
)
yield (
api.test('multiple_commits')
+ api.roll_util.commit_data(
'abc',
api.roll_util.commit('2' * 40),
api.roll_util.commit('3' * 40),
api.roll_util.commit('4' * 40),
)
+ api.roll_util.commit_data(
'def',
api.roll_util.commit('6' * 40),
api.roll_util.commit('7' * 40),
api.roll_util.commit('8' * 40),
)
+ api.roll_util.commit_data(
'xyz',
api.roll_util.commit('a' * 40),
api.roll_util.commit('b' * 40),
api.roll_util.commit('c' * 40),
)
)
yield (
api.test('mixed')
+ api.roll_util.properties(commit_divider='--divider--')
+ api.roll_util.commit_data('abc', api.roll_util.commit('4' * 40))
+ api.roll_util.commit_data(
'def',
api.roll_util.commit('6' * 40),
api.roll_util.commit('8' * 40),
)
+ api.roll_util.commit_data(
'xyz',
api.roll_util.commit('a' * 40),
api.roll_util.commit('b' * 40),
api.roll_util.commit('c' * 40),
)
)