Skip to content

Commit

Permalink
Update target_compatible_with_test to use the standard `:incompatible…
Browse files Browse the repository at this point in the history
…` constraint.

PiperOrigin-RevId: 522120725
Change-Id: Ia9eac33fcd97f799f04fc593fe39391c81d93767
  • Loading branch information
katre authored and copybara-github committed Apr 5, 2023
1 parent 18aeb52 commit 2af4d58
Showing 1 changed file with 10 additions and 19 deletions.
29 changes: 10 additions & 19 deletions src/test/shell/integration/target_compatible_with_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -865,7 +856,7 @@ sh_test(
target_compatible_with = select({
":foo1": [],
":foo2": [],
"//conditions:default": [":not_compatible"],
"//conditions:default": ["@platforms//:incompatible"],
}),
)
EOF
Expand Down Expand Up @@ -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": [],
}),
)
Expand Down Expand Up @@ -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
Expand All @@ -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 \
Expand All @@ -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'
}

Expand All @@ -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
Expand Down Expand Up @@ -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": [],
}),
)
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 2af4d58

Please sign in to comment.