From 623b994e38d5b7813274d7bc8c8f8caa38f5b13d Mon Sep 17 00:00:00 2001 From: A Googler Date: Mon, 28 Oct 2024 15:22:50 -0700 Subject: [PATCH] ...text exposed to open source public git repo... PiperOrigin-RevId: 690768905 --- lib/unittest.bzl | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/unittest.bzl b/lib/unittest.bzl index 4ca3c30..7fd41a7 100644 --- a/lib/unittest.bzl +++ b/lib/unittest.bzl @@ -227,6 +227,7 @@ def _make_analysis_test( fragments = [], config_settings = {}, extra_target_under_test_aspects = [], + target_under_test_for_dependency_resolution = False, doc = ""): """Creates an analysis test rule from its implementation function. @@ -267,6 +268,9 @@ def _make_analysis_test( flags in a single build extra_target_under_test_aspects: An optional list of aspects to apply to the target_under_test in addition to those set up by default for the test harness itself. + target_under_test_for_dependency_resolution: If true, the target_under_test will be used for + dependency resolution. See + https://bazel.build/rules/lib/toplevel/attr#label.for_dependency_resolution for more info. doc: A description of the rule that can be extracted by documentation generating tools. Returns: @@ -287,6 +291,9 @@ def _make_analysis_test( ) target_attr_kwargs["cfg"] = test_transition + if target_under_test_for_dependency_resolution: + target_attr_kwargs["for_dependency_resolution"] = True + attrs["target_under_test"] = attr.label( aspects = [_action_retrieving_aspect] + extra_target_under_test_aspects, mandatory = True,