From 2af4d58294459635e5c7842a030f7ca41375cc14 Mon Sep 17 00:00:00 2001 From: Googler Date: Wed, 5 Apr 2023 12:15:57 -0700 Subject: [PATCH] Update target_compatible_with_test to use the standard `:incompatible` constraint. PiperOrigin-RevId: 522120725 Change-Id: Ia9eac33fcd97f799f04fc593fe39391c81d93767 --- .../target_compatible_with_test.sh | 29 +++++++------------ 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/src/test/shell/integration/target_compatible_with_test.sh b/src/test/shell/integration/target_compatible_with_test.sh index 1c7e53bf430c9f..5ab03e507c5f69 100755 --- a/src/test/shell/integration/target_compatible_with_test.sh +++ b/src/test/shell/integration/target_compatible_with_test.sh @@ -81,15 +81,6 @@ EOF # We're not validating visibility here. Let everything access these targets. package(default_visibility = ["//visibility:public"]) -# TODO(philsc): Get rid of this and use @platforms//:incompatible instead. -# Right now it's problematic because Google CI doesn't support @platforms. -constraint_setting(name = "not_compatible_setting") - -constraint_value( - name = "not_compatible", - constraint_setting = ":not_compatible_setting", -) - constraint_setting(name = "foo_version") constraint_value( @@ -484,7 +475,7 @@ function test_failure_on_incompatible_top_level_target_and_auto_cpu_environment_ sh_test( name = "always_incompatible", srcs = [":pass.sh"], - target_compatible_with = [":not_compatible"], + target_compatible_with = ["@platforms//:incompatible"], ) EOF @@ -865,7 +856,7 @@ sh_test( target_compatible_with = select({ ":foo1": [], ":foo2": [], - "//conditions:default": [":not_compatible"], + "//conditions:default": ["@platforms//:incompatible"], }), ) EOF @@ -914,7 +905,7 @@ sh_test( name = "pass_on_everything_but_foo1_and_foo2", srcs = [":pass.sh"], target_compatible_with = selects.with_or({ - (":foo1", ":foo2"): [":not_compatible"], + (":foo1", ":foo2"): ["@platforms//:incompatible"], "//conditions:default": [], }), ) @@ -966,10 +957,10 @@ sh_test( srcs = [":pass.sh"], target_compatible_with = select({ ":foo3": [], - "//conditions:default": [":not_compatible"], + "//conditions:default": ["@platforms//:incompatible"], }) + select({ ":bar2": [], - "//conditions:default": [":not_compatible"], + "//conditions:default": ["@platforms//:incompatible"], }), ) EOF @@ -986,7 +977,7 @@ EOF expect_log '^//target_skipping:pass_on_foo3_and_bar2 * PASSED in' # Validate that we get an error about the target being incompatible. Make - # sure that the ":not_compatible" constraint is only listed once even though + # sure that the ":incompatible" constraint is only listed once even though # it appears twice in the configured "target_compatible_with" attribute. bazel test \ --show_result=10 \ @@ -996,7 +987,7 @@ EOF && fail "Bazel passed unexpectedly." expect_log 'ERROR: Target //target_skipping:pass_on_foo3_and_bar2 is incompatible and cannot be built, but was explicitly requested' - expect_log "^ //target_skipping:pass_on_foo3_and_bar2 (.*) <-- target platform (//target_skipping:foo1_bar1_platform) didn't satisfy constraint //target_skipping:not_compatible$" + expect_log "^ //target_skipping:pass_on_foo3_and_bar2 (.*) <-- target platform (//target_skipping:foo1_bar1_platform) didn't satisfy constraint @platforms//:incompatible$" expect_log 'ERROR: Build did NOT complete successfully' } @@ -1016,7 +1007,7 @@ cc_library( name = "some_library", target_compatible_with = select({ ":also_foo3": [":again_foo3"], - "//conditions:default": [":not_compatible"], + "//conditions:default": ["@platforms//:incompatible"], }), ) EOF @@ -1091,7 +1082,7 @@ custom_binary( name = "custom2", src = "custom.txt", target_compatible_with = select({ - ":using_custom_toolchain": [":not_compatible"], + ":using_custom_toolchain": ["@platforms//:incompatible"], "//conditions:default": [], }), ) @@ -1334,7 +1325,7 @@ sh_test( sh_binary( name = "never_compatible", srcs = [":never_used.sh"], - target_compatible_with = [":not_compatible"], + target_compatible_with = ["@platforms//:incompatible"], ) EOF