Commit 546e9e2 1 parent b3a254d commit 546e9e2 Copy full SHA for 546e9e2
File tree 3 files changed +39
-1
lines changed
main/java/com/google/devtools/build/lib/analysis
3 files changed +39
-1
lines changed Original file line number Diff line number Diff line change @@ -2252,6 +2252,8 @@ java_library(
2252
2252
srcs = ["constraints/IncompatibleTargetChecker.java" ],
2253
2253
deps = [
2254
2254
":analysis_cluster" ,
2255
+ ":constraints/environment_collection" ,
2256
+ ":constraints/supported_environments" ,
2255
2257
":file_provider" ,
2256
2258
":incompatible_platform_provider" ,
2257
2259
":test/test_configuration" ,
Original file line number Diff line number Diff line change 18
18
import static com .google .common .collect .ImmutableList .toImmutableList ;
19
19
20
20
import com .google .common .collect .ImmutableList ;
21
+ import com .google .common .collect .ImmutableMap ;
21
22
import com .google .devtools .build .lib .actions .Artifact ;
22
23
import com .google .devtools .build .lib .analysis .ConfiguredTarget ;
23
24
import com .google .devtools .build .lib .analysis .ConfiguredTargetValue ;
@@ -234,7 +235,10 @@ private static RuleConfiguredTargetValue createIncompatibleRuleConfiguredTarget(
234
235
.put (incompatiblePlatformProvider )
235
236
.add (RunfilesProvider .simple (Runfiles .EMPTY ))
236
237
.add (fileProvider )
237
- .add (filesToRunProvider );
238
+ .add (filesToRunProvider )
239
+ .add (
240
+ new SupportedEnvironments (
241
+ EnvironmentCollection .EMPTY , EnvironmentCollection .EMPTY , ImmutableMap .of ()));
238
242
if (configuration .hasFragment (TestConfiguration .class )) {
239
243
// Create a dummy TestProvider instance so that other parts of the code base stay happy. Even
240
244
// 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() {
475
475
expect_log ' ^FAILED: Build did NOT complete successfully'
476
476
}
477
477
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
+
478
510
# Crudely validates that the build event protocol contains useful information
479
511
# when targets are skipped due to incompatibilities.
480
512
function test_build_event_protocol() {
You can’t perform that action at this time.
0 commit comments