@@ -734,4 +734,54 @@ public void dependencyHasConflict_keepGoing_bothTopLevelTargetsFail(
734
734
assertThat (eventListener .failedTargetNames )
735
735
.containsExactly ("//foo:top_level_a" , "//foo:top_level_b" );
736
736
}
737
+
738
+ private void setupStrictConflictChecksTest () throws IOException {
739
+ write (
740
+ "foo/conflict.bzl" ,
741
+ "def _impl(ctx):" ,
742
+ " dir = ctx.actions.declare_directory(ctx.label.name + '.dir')" ,
743
+ " file = ctx.actions.declare_file(ctx.label.name + '.dir/file.txt')" ,
744
+ " ctx.actions.run_shell(" ,
745
+ " outputs = [dir, file]," ,
746
+ " command = 'mkdir -p $1 && touch $2'," ,
747
+ " arguments = [dir.path, file.path]," ,
748
+ " )" ,
749
+ " return [DefaultInfo(files = depset([dir, file]))]" ,
750
+ "" ,
751
+ "my_rule = rule(implementation = _impl)" );
752
+ write ("foo/BUILD" , "load(':conflict.bzl', 'my_rule')" , "my_rule(name = 'bar')" );
753
+ }
754
+
755
+ @ Test
756
+ public void laxFollowedByStrictConflictChecks (@ TestParameter boolean mergedAnalysisExecution )
757
+ throws Exception {
758
+ setupStrictConflictChecksTest ();
759
+ addOptions ("--experimental_merged_skyframe_analysis_execution=" + mergedAnalysisExecution );
760
+
761
+ addOptions ("--noincompatible_strict_conflict_checks" );
762
+ buildTarget ("//foo:bar" );
763
+ assertNoEvents (events .errors ());
764
+
765
+ addOptions ("--incompatible_strict_conflict_checks" );
766
+ assertThrows (ViewCreationFailedException .class , () -> buildTarget ("//foo:bar" ));
767
+ events .assertContainsError ("One of the output paths" );
768
+ events .assertContainsError ("is a prefix of the other" );
769
+ }
770
+
771
+ @ Test
772
+ public void strictFollowedByLaxConflictChecks (@ TestParameter boolean mergedAnalysisExecution )
773
+ throws Exception {
774
+ setupStrictConflictChecksTest ();
775
+ addOptions ("--experimental_merged_skyframe_analysis_execution=" + mergedAnalysisExecution );
776
+
777
+ addOptions ("--incompatible_strict_conflict_checks" );
778
+ assertThrows (ViewCreationFailedException .class , () -> buildTarget ("//foo:bar" ));
779
+ events .assertContainsError ("One of the output paths" );
780
+ events .assertContainsError ("is a prefix of the other" );
781
+
782
+ events .clear ();
783
+ addOptions ("--noincompatible_strict_conflict_checks" );
784
+ buildTarget ("//foo:bar" );
785
+ assertNoEvents (events .errors ());
786
+ }
737
787
}
0 commit comments