@@ -713,6 +713,134 @@ public void testDefaultInfoWithRunfilesConstructor() throws Exception {
713
713
assertThat (getConfiguredTarget ("//src:r_tools" )).isNotNull ();
714
714
}
715
715
716
+ @ Test
717
+ public void testDefaultInfoFilesAddedToCcBinaryTargetRunfiles () throws Exception {
718
+ scratch .file (
719
+ "test/starlark/extension.bzl" ,
720
+ "def custom_rule_impl(ctx):" ,
721
+ " out = ctx.actions.declare_file(ctx.attr.name + '.out')" ,
722
+ " ctx.actions.write(out, 'foobar')" ,
723
+ " return [DefaultInfo(files = depset([out]))]" ,
724
+ "" ,
725
+ "custom_rule = rule(implementation = custom_rule_impl)" );
726
+
727
+ scratch .file (
728
+ "test/starlark/BUILD" ,
729
+ "load('//test/starlark:extension.bzl', 'custom_rule')" ,
730
+ "" ,
731
+ "custom_rule(name = 'cr')" ,
732
+ "cc_binary(name = 'binary', data = [':cr'])" );
733
+
734
+ useConfiguration ("--incompatible_always_include_files_in_data" );
735
+ ConfiguredTarget target = getConfiguredTarget ("//test/starlark:binary" );
736
+
737
+ assertThat (target .getLabel ().toString ()).isEqualTo ("//test/starlark:binary" );
738
+ assertThat (
739
+ ActionsTestUtil .baseArtifactNames (
740
+ target .getProvider (RunfilesProvider .class ).getDefaultRunfiles ().getAllArtifacts ()))
741
+ .contains ("cr.out" );
742
+ assertThat (
743
+ ActionsTestUtil .baseArtifactNames (
744
+ target .getProvider (RunfilesProvider .class ).getDataRunfiles ().getAllArtifacts ()))
745
+ .contains ("cr.out" );
746
+ }
747
+
748
+ @ Test
749
+ public void testDefaultInfoFilesAddedToJavaBinaryTargetRunfiles () throws Exception {
750
+ scratch .file (
751
+ "test/starlark/extension.bzl" ,
752
+ "def custom_rule_impl(ctx):" ,
753
+ " out = ctx.actions.declare_file(ctx.attr.name + '.out')" ,
754
+ " ctx.actions.write(out, 'foobar')" ,
755
+ " return [DefaultInfo(files = depset([out]))]" ,
756
+ "" ,
757
+ "custom_rule = rule(implementation = custom_rule_impl)" );
758
+
759
+ scratch .file (
760
+ "test/starlark/BUILD" ,
761
+ "load('//test/starlark:extension.bzl', 'custom_rule')" ,
762
+ "" ,
763
+ "custom_rule(name = 'cr')" ,
764
+ "java_binary(name = 'binary', data = [':cr'], srcs = ['Foo.java'], main_class = 'Foo')" );
765
+
766
+ useConfiguration ("--incompatible_always_include_files_in_data" );
767
+ ConfiguredTarget target = getConfiguredTarget ("//test/starlark:binary" );
768
+
769
+ assertThat (target .getLabel ().toString ()).isEqualTo ("//test/starlark:binary" );
770
+ assertThat (
771
+ ActionsTestUtil .baseArtifactNames (
772
+ target .getProvider (RunfilesProvider .class ).getDefaultRunfiles ().getAllArtifacts ()))
773
+ .contains ("cr.out" );
774
+ assertThat (
775
+ ActionsTestUtil .baseArtifactNames (
776
+ target .getProvider (RunfilesProvider .class ).getDataRunfiles ().getAllArtifacts ()))
777
+ .contains ("cr.out" );
778
+ }
779
+
780
+ @ Test
781
+ public void testDefaultInfoFilesAddedToPyBinaryTargetRunfiles () throws Exception {
782
+ scratch .file (
783
+ "test/starlark/extension.bzl" ,
784
+ "def custom_rule_impl(ctx):" ,
785
+ " out = ctx.actions.declare_file(ctx.attr.name + '.out')" ,
786
+ " ctx.actions.write(out, 'foobar')" ,
787
+ " return [DefaultInfo(files = depset([out]))]" ,
788
+ "" ,
789
+ "custom_rule = rule(implementation = custom_rule_impl)" );
790
+
791
+ scratch .file (
792
+ "test/starlark/BUILD" ,
793
+ "load('//test/starlark:extension.bzl', 'custom_rule')" ,
794
+ "" ,
795
+ "custom_rule(name = 'cr')" ,
796
+ "py_binary(name = 'binary', data = [':cr'], srcs = ['binary.py'])" );
797
+
798
+ useConfiguration ("--incompatible_always_include_files_in_data" );
799
+ ConfiguredTarget target = getConfiguredTarget ("//test/starlark:binary" );
800
+
801
+ assertThat (target .getLabel ().toString ()).isEqualTo ("//test/starlark:binary" );
802
+ assertThat (
803
+ ActionsTestUtil .baseArtifactNames (
804
+ target .getProvider (RunfilesProvider .class ).getDefaultRunfiles ().getAllArtifacts ()))
805
+ .contains ("cr.out" );
806
+ assertThat (
807
+ ActionsTestUtil .baseArtifactNames (
808
+ target .getProvider (RunfilesProvider .class ).getDataRunfiles ().getAllArtifacts ()))
809
+ .contains ("cr.out" );
810
+ }
811
+
812
+ @ Test
813
+ public void testDefaultInfoFilesAddedToShBinaryTargetRunfiles () throws Exception {
814
+ scratch .file (
815
+ "test/starlark/extension.bzl" ,
816
+ "def custom_rule_impl(ctx):" ,
817
+ " out = ctx.actions.declare_file(ctx.attr.name + '.out')" ,
818
+ " ctx.actions.write(out, 'foobar')" ,
819
+ " return [DefaultInfo(files = depset([out]))]" ,
820
+ "" ,
821
+ "custom_rule = rule(implementation = custom_rule_impl)" );
822
+
823
+ scratch .file (
824
+ "test/starlark/BUILD" ,
825
+ "load('//test/starlark:extension.bzl', 'custom_rule')" ,
826
+ "" ,
827
+ "custom_rule(name = 'cr')" ,
828
+ "sh_binary(name = 'binary', data = [':cr'], srcs = ['script.sh'])" );
829
+
830
+ useConfiguration ("--incompatible_always_include_files_in_data" );
831
+ ConfiguredTarget target = getConfiguredTarget ("//test/starlark:binary" );
832
+
833
+ assertThat (target .getLabel ().toString ()).isEqualTo ("//test/starlark:binary" );
834
+ assertThat (
835
+ ActionsTestUtil .baseArtifactNames (
836
+ target .getProvider (RunfilesProvider .class ).getDefaultRunfiles ().getAllArtifacts ()))
837
+ .contains ("cr.out" );
838
+ assertThat (
839
+ ActionsTestUtil .baseArtifactNames (
840
+ target .getProvider (RunfilesProvider .class ).getDataRunfiles ().getAllArtifacts ()))
841
+ .contains ("cr.out" );
842
+ }
843
+
716
844
@ Test
717
845
public void testInstrumentedFilesProviderWithCodeCoverageDisabled () throws Exception {
718
846
setBuildLanguageOptions ("--incompatible_disallow_struct_provider_syntax=false" );
0 commit comments