From 1ab97222ce1db886a631b2ef343e86c8544aece8 Mon Sep 17 00:00:00 2001 From: Fabian Meumertzheim Date: Wed, 31 Jul 2024 19:15:28 +0200 Subject: [PATCH] Fix compatibility with Bazel 6.5.0 --- tests/bcr/go_mod/MODULE.bazel | 1 + tests/bcr/go_mod/tests.bzl | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/tests/bcr/go_mod/MODULE.bazel b/tests/bcr/go_mod/MODULE.bazel index b03c33fd6..bd2e0d083 100644 --- a/tests/bcr/go_mod/MODULE.bazel +++ b/tests/bcr/go_mod/MODULE.bazel @@ -14,6 +14,7 @@ local_path_override( path = "test_dep", ) +bazel_dep(name = "bazel_features", version = "1.14.0") bazel_dep(name = "protobuf", version = "23.1", repo_name = "my_protobuf") bazel_dep(name = "rules_go", version = "0.42.0", repo_name = "my_rules_go") bazel_dep(name = "rules_license", version = "0.0.8") diff --git a/tests/bcr/go_mod/tests.bzl b/tests/bcr/go_mod/tests.bzl index e77dc029e..ba5d75da8 100644 --- a/tests/bcr/go_mod/tests.bzl +++ b/tests/bcr/go_mod/tests.bzl @@ -1,3 +1,4 @@ +load("@bazel_features//:features.bzl", "bazel_features") load("@rules_license//rules:providers.bzl", "PackageInfo") load("@rules_testing//lib:analysis_test.bzl", "analysis_test", "test_suite") load("@rules_testing//lib:truth.bzl", "subjects") @@ -14,6 +15,12 @@ def _test_package_info(name): ) def _test_package_info_impl(env, target): + # The package_info functionality requires REPO.bazel support, which is only + # available in Bazel 7 and higher. Use this unrelated feature launched in + # Bazel 7 as a hacky signal to skip the test if the feature is not + # available. + if not bazel_features.proto.starlark_proto_info: + return env.expect.that_target(target).has_provider(PackageInfo) subject = env.expect.that_target(target).provider(PackageInfo) subject.package_name().equals("github.com/fmeum/dep_on_gazelle")