blob: d4937b773c14c078513b150b711a85980c1f5821 [file] [log] [blame]
# Copyright 2024 The Bazel Authors. All rights reserved.
#
# 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
#
# http://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.
"""Tests for the cc_args rule."""
load(
"//cc/toolchains:cc_toolchain_info.bzl",
"ActionTypeInfo",
"ArgsInfo",
"ArgsListInfo",
)
visibility("private")
_SIMPLE_FILES = [
"tests/rule_based_toolchain/testdata/file1",
"tests/rule_based_toolchain/testdata/multiple1",
"tests/rule_based_toolchain/testdata/multiple2",
]
def _test_simple_args_impl(env, targets):
simple = env.expect.that_target(targets.simple).provider(ArgsInfo)
simple.actions().contains_exactly([
targets.c_compile.label,
targets.cpp_compile.label,
])
simple.args().contains_exactly([targets.simple.label])
simple.env().contains_exactly({"BAR": "bar"})
simple.files().contains_exactly(_SIMPLE_FILES)
c_compile = env.expect.that_target(targets.simple).provider(ArgsListInfo).by_action().get(
targets.c_compile[ActionTypeInfo],
)
c_compile.args().contains_exactly([targets.simple[ArgsInfo]])
c_compile.files().contains_exactly(_SIMPLE_FILES)
TARGETS = [
":simple",
"//tests/rule_based_toolchain/actions:c_compile",
"//tests/rule_based_toolchain/actions:cpp_compile",
]
TESTS = {
"simple_test": _test_simple_args_impl,
}