File tree Expand file tree Collapse file tree 3 files changed +39
-1
lines changed
main/java/com/google/devtools/build/lib/analysis Expand file tree Collapse file tree 3 files changed +39
-1
lines changed Original file line number Diff line number Diff line change @@ -2252,6 +2252,8 @@ java_library(
22522252 srcs = ["constraints/IncompatibleTargetChecker.java" ],
22532253 deps = [
22542254 ":analysis_cluster" ,
2255+ ":constraints/environment_collection" ,
2256+ ":constraints/supported_environments" ,
22552257 ":file_provider" ,
22562258 ":incompatible_platform_provider" ,
22572259 ":test/test_configuration" ,
Original file line number Diff line number Diff line change 1818import static com .google .common .collect .ImmutableList .toImmutableList ;
1919
2020import com .google .common .collect .ImmutableList ;
21+ import com .google .common .collect .ImmutableMap ;
2122import com .google .devtools .build .lib .actions .Artifact ;
2223import com .google .devtools .build .lib .analysis .ConfiguredTarget ;
2324import com .google .devtools .build .lib .analysis .ConfiguredTargetValue ;
@@ -234,7 +235,10 @@ private static RuleConfiguredTargetValue createIncompatibleRuleConfiguredTarget(
234235 .put (incompatiblePlatformProvider )
235236 .add (RunfilesProvider .simple (Runfiles .EMPTY ))
236237 .add (fileProvider )
237- .add (filesToRunProvider );
238+ .add (filesToRunProvider )
239+ .add (
240+ new SupportedEnvironments (
241+ EnvironmentCollection .EMPTY , EnvironmentCollection .EMPTY , ImmutableMap .of ()));
238242 if (configuration .hasFragment (TestConfiguration .class )) {
239243 // Create a dummy TestProvider instance so that other parts of the code base stay happy. Even
240244 // though this test will never execute, some code still expects the provider.
Original file line number Diff line number Diff line change @@ -475,6 +475,38 @@ function test_failure_on_incompatible_top_level_target() {
475475 expect_log ' ^FAILED: Build did NOT complete successfully'
476476}
477477
478+ # https://github.com/bazelbuild/bazel/issues/17561 regression test: incompatible
479+ # target skipping doesn't crash with --auto_cpu_environment_group.
480+ function test_failure_on_incompatible_top_level_target_and_auto_cpu_environment_group() {
481+ cat >> target_skipping/BUILD << EOF
482+ sh_test(
483+ name = "always_incompatible",
484+ srcs = [":pass.sh"],
485+ target_compatible_with = [":not_compatible"],
486+ )
487+ EOF
488+
489+ mkdir -p buildenv/cpus
490+ cat >> buildenv/cpus/BUILD << EOF
491+ environment(name = "foo_cpu")
492+ environment_group(
493+ name = "cpus",
494+ defaults = [":foo_cpu"],
495+ environments = [":foo_cpu"],
496+ )
497+ EOF
498+
499+ bazel build \
500+ --nobuild \
501+ --cpu=foo_cpu \
502+ --auto_cpu_environment_group=//buildenv/cpus:cpus \
503+ --build_event_text_file=$TEST_log \
504+ //target_skipping:all & > " ${TEST_log} " \
505+ || fail " Bazel failed unexpectedly."
506+
507+ expect_log ' Target //target_skipping:always_incompatible build was skipped'
508+ }
509+
478510# Crudely validates that the build event protocol contains useful information
479511# when targets are skipped due to incompatibilities.
480512function test_build_event_protocol() {
You can’t perform that action at this time.
0 commit comments