1# Copyright 2023 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"""PyCcToolchainInfo testing subject.""" 15 16load("@rules_testing//lib:truth.bzl", "subjects") 17 18def _py_cc_toolchain_info_subject_new(info, *, meta): 19 # buildifier: disable=uninitialized 20 public = struct( 21 headers = lambda *a, **k: _py_cc_toolchain_info_subject_headers(self, *a, **k), 22 python_version = lambda *a, **k: _py_cc_toolchain_info_subject_python_version(self, *a, **k), 23 actual = info, 24 ) 25 self = struct(actual = info, meta = meta) 26 return public 27 28def _py_cc_toolchain_info_subject_headers(self): 29 return subjects.struct( 30 self.actual.headers, 31 meta = self.meta.derive("headers()"), 32 attrs = dict( 33 providers_map = subjects.dict, 34 ), 35 ) 36 37def _py_cc_toolchain_info_subject_python_version(self): 38 return subjects.str( 39 self.actual.python_version, 40 meta = self.meta.derive("python_version()"), 41 ) 42 43# Disable this to aid doc generation 44# buildifier: disable=name-conventions 45PyCcToolchainInfoSubject = struct( 46 new = _py_cc_toolchain_info_subject_new, 47) 48