From eba66dc47563d4d626708d4710424004565c5e68 Mon Sep 17 00:00:00 2001 From: Bocete Date: Tue, 19 Nov 2024 16:03:42 -0800 Subject: [PATCH] Update unittest_tests.bzl to not have a dormant deps test if the current blaze version doesn't support dormant deps yet --- tests/unittest_tests.bzl | 38 ++++++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/tests/unittest_tests.bzl b/tests/unittest_tests.bzl index c103e94..f5ba0d7 100644 --- a/tests/unittest_tests.bzl +++ b/tests/unittest_tests.bzl @@ -264,6 +264,10 @@ inspect_aspect_test = analysistest.make( ########################################### ####### inspect_dormant_target_test ####### ########################################### +def _dormant_deps_supported(): + # Dormant deps are only supported in newer versions of Blaze. + return hasattr(attr, "dormant_label") + _DormantTargetTestDormantInfo = provider( doc = "Example provider that contains a dormant target", fields = { @@ -282,6 +286,9 @@ inspect_dormant_target_fake_rule = rule( implementation = _inspect_dormant_target_fake_rule_impl, attrs = { "dormant_dep": attr.dormant_label(), + } if _dormant_deps_supported() else { + # To keep skylib compatible with blaze versions that don't support dormant deps yet + "dormant_dep": attr.label(), }, dependency_resolution_rule = True, ) @@ -320,6 +327,8 @@ inspect_dormant_target_test = analysistest.make( _inspect_dormant_target_test, attrs = { "_materialized_dormant_dep": attr.label(materializer = _dormant_dep_materializer), + } if _dormant_deps_supported() else { + # To keep skylib compatible with blaze versions that don't support dormant deps yet }, target_under_test_for_dependency_resolution = True, ) @@ -438,20 +447,21 @@ def unittest_passing_tests_suite(): name = "inspect_aspect_fake_target", tags = ["manual"], ) - - inspect_dormant_target_test( - name = "inspect_dormant_target_test", - target_under_test = ":inspect_dormant_target_fake_target", - ) - inspect_dormant_target_fake_rule( - name = "inspect_dormant_target_fake_target", - dormant_dep = ":inspect_dormant_target_fake_dependency_target", - tags = ["manual"], - ) - inspect_dormant_target_fake_dependency_rule( - name = "inspect_dormant_target_fake_dependency_target", - tags = ["manual"], - ) + + if _dormant_deps_supported(): + inspect_dormant_target_test( + name = "inspect_dormant_target_test", + target_under_test = ":inspect_dormant_target_fake_target", + ) + inspect_dormant_target_fake_rule( + name = "inspect_dormant_target_fake_target", + dormant_dep = ":inspect_dormant_target_fake_dependency_target", + tags = ["manual"], + ) + inspect_dormant_target_fake_dependency_rule( + name = "inspect_dormant_target_fake_dependency_target", + tags = ["manual"], + ) inspect_output_dirs_test( name = "inspect_output_dirs_test",