1# Copyright 2024 The Bazel Authors. All rights reserved.
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#    http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14"""Starlark tests for py_exec_tools_toolchain rule."""
15
16load("@rules_testing//lib:analysis_test.bzl", "analysis_test")
17load("@rules_testing//lib:test_suite.bzl", "test_suite")
18load("//python/private:py_exec_tools_toolchain.bzl", "py_exec_tools_toolchain")  # buildifier: disable=bzl-visibility
19
20_tests = []
21
22def _test_disable_exec_interpreter(name):
23    py_exec_tools_toolchain(
24        name = name + "_subject",
25        exec_interpreter = "//python/private:sentinel",
26    )
27    analysis_test(
28        name = name,
29        target = name + "_subject",
30        impl = _test_disable_exec_interpreter_impl,
31    )
32
33def _test_disable_exec_interpreter_impl(env, target):
34    exec_tools = target[platform_common.ToolchainInfo].exec_tools
35    env.expect.that_bool(exec_tools.exec_interpreter == None).equals(True)
36
37_tests.append(_test_disable_exec_interpreter)
38
39def py_exec_tools_toolchain_test_suite(name):
40    test_suite(name = name, tests = _tests)
41