|
16 | 16 | import static com.google.common.truth.Truth.assertThat; |
17 | 17 | import static com.google.common.truth.Truth.assertWithMessage; |
18 | 18 | import static com.google.devtools.build.lib.actions.util.ActionsTestUtil.prettyArtifactNames; |
19 | | -import static com.google.devtools.build.lib.rules.java.JavaCompileActionTestHelper.getProcessorNames; |
20 | | -import static com.google.devtools.build.lib.rules.java.JavaCompileActionTestHelper.getProcessorPath; |
21 | 19 | import static com.google.devtools.build.lib.rules.java.JavaInfo.PROVIDER; |
22 | 20 | import static com.google.devtools.build.lib.skyframe.BzlLoadValue.keyForBuild; |
23 | 21 | import static java.util.Arrays.stream; |
|
27 | 25 | import com.google.devtools.build.lib.actions.Artifact; |
28 | 26 | import com.google.devtools.build.lib.analysis.ConfiguredTarget; |
29 | 27 | import com.google.devtools.build.lib.analysis.actions.SpawnAction; |
30 | | -import com.google.devtools.build.lib.analysis.test.InstrumentedFilesInfo; |
31 | 28 | import com.google.devtools.build.lib.analysis.util.AnalysisMock; |
32 | 29 | import com.google.devtools.build.lib.analysis.util.BuildViewTestCase; |
33 | 30 | import com.google.devtools.build.lib.cmdline.Label; |
@@ -745,125 +742,6 @@ def _impl(ctx): |
745 | 742 | assertThat(prettyArtifactNames(files.toList(Artifact.class))).containsExactly("a/a.txt"); |
746 | 743 | } |
747 | 744 |
|
748 | | - @Test |
749 | | - public void testJavaLibraryCollectsCoverageDependenciesFromResources() throws Exception { |
750 | | - useConfiguration("--collect_code_coverage"); |
751 | | - |
752 | | - scratch.file( |
753 | | - "java/BUILD", |
754 | | - """ |
755 | | - load("@rules_cc//cc:cc_binary.bzl", "cc_binary") |
756 | | - load("@rules_java//java:defs.bzl", "java_library") |
757 | | - java_library( |
758 | | - name = "lib", |
759 | | - resources = [":libjni.so"], |
760 | | - ) |
761 | | -
|
762 | | - cc_binary( |
763 | | - name = "libjni.so", |
764 | | - srcs = ["jni.cc"], |
765 | | - linkshared = 1, |
766 | | - ) |
767 | | - """); |
768 | | - |
769 | | - InstrumentedFilesInfo target = getInstrumentedFilesProvider("//java:lib"); |
770 | | - |
771 | | - assertThat(prettyArtifactNames(target.getInstrumentedFiles())).containsExactly("java/jni.cc"); |
772 | | - assertThat(prettyArtifactNames(target.getInstrumentationMetadataFiles())) |
773 | | - .containsExactly("java/_objs/libjni.so/jni.gcno"); |
774 | | - } |
775 | | - |
776 | | - @Test |
777 | | - public void testSkipAnnotationProcessing() throws Exception { |
778 | | - JavaTestUtil.writeBuildFileForJavaToolchain(scratch); |
779 | | - scratch.file( |
780 | | - "foo/custom_rule.bzl", |
781 | | - "load('@rules_java//java:defs.bzl', 'java_common', 'JavaInfo'," |
782 | | - + " 'JavaPluginInfo')", |
783 | | - "def _impl(ctx):", |
784 | | - " output_jar = ctx.actions.declare_file('lib' + ctx.label.name + '.jar')", |
785 | | - " compilation_provider = java_common.compile(", |
786 | | - " ctx,", |
787 | | - " source_files = ctx.files.srcs,", |
788 | | - " output = output_jar,", |
789 | | - " java_toolchain = ctx.attr._java_toolchain[java_common.JavaToolchainInfo],", |
790 | | - " deps = [p[JavaInfo] for p in ctx.attr.deps],", |
791 | | - " plugins = [p[JavaPluginInfo] for p in ctx.attr.plugins],", |
792 | | - " enable_annotation_processing = False,", |
793 | | - " )", |
794 | | - " return [DefaultInfo(files = depset([output_jar])), compilation_provider]", |
795 | | - "java_custom_library = rule(", |
796 | | - " implementation = _impl,", |
797 | | - " outputs = {", |
798 | | - " 'my_output': 'lib%{name}.jar'", |
799 | | - " },", |
800 | | - " attrs = {", |
801 | | - " 'srcs': attr.label_list(allow_files=True),", |
802 | | - " 'deps': attr.label_list(providers=[JavaInfo]),", |
803 | | - " 'plugins': attr.label_list(providers=[JavaPluginInfo]),", |
804 | | - " '_java_toolchain': attr.label(default = Label('//java/com/google/test:toolchain')),", |
805 | | - " },", |
806 | | - " toolchains = ['" + TestConstants.JAVA_TOOLCHAIN_TYPE + "'],", |
807 | | - " fragments = ['java']", |
808 | | - ")"); |
809 | | - scratch.file( |
810 | | - "foo/BUILD", |
811 | | - """ |
812 | | - load(":custom_rule.bzl", "java_custom_library") |
813 | | - load("@rules_java//java:defs.bzl", "java_library", "java_plugin") |
814 | | -
|
815 | | - java_plugin( |
816 | | - name = "processor", |
817 | | - srcs = ["processor.java"], |
818 | | - data = ["processor_data.txt"], |
819 | | - generates_api = 1, # so Turbine would normally run it |
820 | | - processor_class = "Foo", |
821 | | - ) |
822 | | -
|
823 | | - java_library( |
824 | | - name = "exports_processor", |
825 | | - exported_plugins = [":processor"], |
826 | | - ) |
827 | | -
|
828 | | - java_custom_library( |
829 | | - name = "custom", |
830 | | - srcs = ["custom.java"], |
831 | | - plugins = [":processor"], |
832 | | - deps = [":exports_processor"], |
833 | | - ) |
834 | | -
|
835 | | - java_custom_library( |
836 | | - name = "custom_noproc", |
837 | | - srcs = ["custom.java"], |
838 | | - ) |
839 | | - """); |
840 | | - |
841 | | - ConfiguredTarget custom = getConfiguredTarget("//foo:custom"); |
842 | | - ConfiguredTarget customNoproc = getConfiguredTarget("//foo:custom_noproc"); |
843 | | - assertNoEvents(); |
844 | | - |
845 | | - JavaCompileAction javacAction = |
846 | | - (JavaCompileAction) getGeneratingActionForLabel("//foo:libcustom.jar"); |
847 | | - assertThat(javacAction.getMnemonic()).isEqualTo("Javac"); |
848 | | - assertThat(getProcessorNames(javacAction)).isEmpty(); |
849 | | - assertThat(getProcessorPath(javacAction)).isNotEmpty(); |
850 | | - assertThat(artifactFilesNames(javacAction.getInputs())).contains("processor_data.txt"); |
851 | | - |
852 | | - JavaCompileAction turbineAction = |
853 | | - (JavaCompileAction) getGeneratingAction(getBinArtifact("libcustom-hjar.jar", custom)); |
854 | | - assertThat(turbineAction.getMnemonic()).isEqualTo("JavacTurbine"); |
855 | | - ImmutableList<String> args = turbineAction.getArguments(); |
856 | | - assertThat(args).doesNotContain("--processors"); |
857 | | - |
858 | | - // enable_annotation_processing=False shouldn't disable direct classpaths if there are no |
859 | | - // annotation processors that need to be disabled |
860 | | - SpawnAction turbineActionNoProc = |
861 | | - (SpawnAction) |
862 | | - getGeneratingAction(getBinArtifact("libcustom_noproc-hjar.jar", customNoproc)); |
863 | | - assertThat(turbineActionNoProc.getMnemonic()).isEqualTo("Turbine"); |
864 | | - assertThat(turbineActionNoProc.getArguments()).doesNotContain("--processors"); |
865 | | - } |
866 | | - |
867 | 745 | @Test |
868 | 746 | public void testCompileWithDisablingCompileJarIsPrivateApi() throws Exception { |
869 | 747 | JavaTestUtil.writeBuildFileForJavaToolchain(scratch); |
@@ -1297,10 +1175,6 @@ def _impl(ctx): |
1297 | 1175 | assertThat(provider.toFlags()).containsExactly("--add-exports=java.base/java.lang=ALL-UNNAMED"); |
1298 | 1176 | } |
1299 | 1177 |
|
1300 | | - private InstrumentedFilesInfo getInstrumentedFilesProvider(String label) throws Exception { |
1301 | | - return getConfiguredTarget(label).get(InstrumentedFilesInfo.STARLARK_CONSTRUCTOR); |
1302 | | - } |
1303 | | - |
1304 | 1178 | @Test |
1305 | 1179 | public void hermeticStaticLibs() throws Exception { |
1306 | 1180 | scratch.file("a/libStatic.a"); |
|
0 commit comments