# Copyright 2021 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 API for build."""

from __future__ import annotations

from PB.recipe_modules.pigweed.build import options
from recipe_engine import recipe_test_api


class BuildTestApi(recipe_test_api.RecipeTestApi):
    """Test API for build."""

    def options(self, *, packages=(), gn_args=(), ninja_targets=()):
        assert isinstance(packages, (list, tuple))
        assert isinstance(gn_args, (list, tuple))
        assert isinstance(ninja_targets, (list, tuple))

        opts = options.Options()
        opts.packages.extend(packages)
        opts.gn_args.extend(gn_args)
        opts.ninja_targets.extend(ninja_targets)
        return opts
