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"""DefaultInfo testing subject.""" 15 16# TODO: Load this through truth.bzl#subjects when made available 17# https://github.com/bazelbuild/rules_testing/issues/54 18load("@rules_testing//lib/private:runfiles_subject.bzl", "RunfilesSubject") # buildifier: disable=bzl-visibility 19 20# TODO: Use rules_testing's DefaultInfoSubject once it's available 21# https://github.com/bazelbuild/rules_testing/issues/52 22def default_info_subject(info, *, meta): 23 # buildifier: disable=uninitialized 24 public = struct( 25 runfiles = lambda *a, **k: _default_info_subject_runfiles(self, *a, **k), 26 ) 27 self = struct(actual = info, meta = meta) 28 return public 29 30def _default_info_subject_runfiles(self): 31 return RunfilesSubject.new( 32 self.actual.default_runfiles, 33 meta = self.meta.derive("runfiles()"), 34 ) 35