# Copyright 2023 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 enviroment."""

import re

from PB.recipe_modules.pigweed.bazel.options import BazelInvocation, Options
from recipe_engine import recipe_test_api


class BazelTestApi(recipe_test_api.RecipeTestApi):
    """Test API for Bazel."""

    def options(
        self,
        *,
        cipd_json_path='bazel.json',
        args=('test', '...'),
        invocations=(('build', '//...'), ('test', '//...')),
    ):
        opts = Options()
        opts.cipd_json_path = cipd_json_path
        opts.args.extend(args)
        for invocation in invocations:
            invocation_proto = BazelInvocation(args=invocation)
            opts.invocations.append(invocation_proto)
        return opts

    def properties(self, *, name='bazel_options', **kwargs):
        return self.m.properties(**{name: self.options(**kwargs)})
