aboutsummaryrefslogtreecommitdiff
path: root/tests/jvm
diff options
context:
space:
mode:
Diffstat (limited to 'tests/jvm')
-rw-r--r--tests/jvm/analysis/compiler_plugin/forbidden_target/BUILD23
-rw-r--r--tests/jvm/analysis/compiler_plugin/provider_ctor/BUILD24
-rw-r--r--tests/jvm/analysis/compiler_plugin/provider_ctor/unittests.bzl34
-rw-r--r--tests/jvm/analysis/jvm_library/plugins/BUILD76
4 files changed, 130 insertions, 27 deletions
diff --git a/tests/jvm/analysis/compiler_plugin/forbidden_target/BUILD b/tests/jvm/analysis/compiler_plugin/forbidden_target/BUILD
new file mode 100644
index 0000000..d21f27c
--- /dev/null
+++ b/tests/jvm/analysis/compiler_plugin/forbidden_target/BUILD
@@ -0,0 +1,23 @@
+# Copyright 2022 Google LLC. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the License);
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+load("//kotlin/common/testing:testing_rules.bzl", "kt_testing_rules")
+load("//kotlin/jvm/testing:for_analysis.bzl", ktfa = "kt_for_analysis")
+
+package(
+ default_applicable_licenses = ["//:license"],
+ default_testonly = True,
+)
+
+licenses(["notice"])
diff --git a/tests/jvm/analysis/compiler_plugin/provider_ctor/BUILD b/tests/jvm/analysis/compiler_plugin/provider_ctor/BUILD
new file mode 100644
index 0000000..0ba8b21
--- /dev/null
+++ b/tests/jvm/analysis/compiler_plugin/provider_ctor/BUILD
@@ -0,0 +1,24 @@
+# Copyright 2022 Google LLC. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the License);
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+load(":unittests.bzl", "unittests")
+
+package(
+ default_applicable_licenses = ["//:license"],
+ default_testonly = True,
+)
+
+licenses(["notice"])
+
+unittests.render(name = "unittests")
diff --git a/tests/jvm/analysis/compiler_plugin/provider_ctor/unittests.bzl b/tests/jvm/analysis/compiler_plugin/provider_ctor/unittests.bzl
new file mode 100644
index 0000000..e43744f
--- /dev/null
+++ b/tests/jvm/analysis/compiler_plugin/provider_ctor/unittests.bzl
@@ -0,0 +1,34 @@
+# Copyright 2022 Google LLC. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the License);
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+"""unittests"""
+
+load("//:visibility.bzl", "RULES_KOTLIN")
+load("//kotlin:compiler_plugin.bzl", "KtCompilerPluginInfo")
+load("//kotlin/common/testing:unittest_suites.bzl", "kt_unittest_suites")
+
+visibility(RULES_KOTLIN)
+
+unittests = kt_unittest_suites.create()
+
+def _cannot_construct_provider(ctx):
+ KtCompilerPluginInfo(
+ plugin_id = "fake",
+ jar = ctx.actions.declare_file("fake.jar"),
+ args = [],
+ )
+
+unittests.expect_fail(_cannot_construct_provider, "Error in fail")
+
+_test, _fail = unittests.close() # @unused
diff --git a/tests/jvm/analysis/jvm_library/plugins/BUILD b/tests/jvm/analysis/jvm_library/plugins/BUILD
index 50cfbc2..3694233 100644
--- a/tests/jvm/analysis/jvm_library/plugins/BUILD
+++ b/tests/jvm/analysis/jvm_library/plugins/BUILD
@@ -12,6 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+load("//kotlin/common/testing:testing_rules.bzl", "kt_testing_rules")
load("//kotlin/jvm/testing:for_analysis.bzl", ktfa = "kt_for_analysis")
load("//kotlin/jvm/testing:jvm_library_analysis_test.bzl", "kt_jvm_library_analysis_test")
@@ -22,15 +23,23 @@ package(
licenses(["notice"])
+DEFAULT_KOTLINC_PLUGINS = [
+ "jvm-abi-gen.jar",
+]
+
kt_jvm_library_analysis_test(
name = "has_plugin_and_only_kt_srcs_test",
expect_processor_classpath = True,
expected_exported_processor_classes = [],
+ expected_kotlinc_plugin_jar_names = DEFAULT_KOTLINC_PLUGINS + ["kt_compiler_plugin.jar"],
expected_processor_classes = ["java.plugin.class"],
target_under_test = ktfa.kt_jvm_library(
name = "has_plugin_and_only_kt_srcs",
srcs = ["Input.kt"],
- plugins = [":java_plugin_with_processor"],
+ plugins = [
+ ":java_plugin",
+ ":kt_compiler_plugin",
+ ],
),
)
@@ -38,34 +47,31 @@ kt_jvm_library_analysis_test(
name = "has_plugin_and_only_java_srcs_test",
expect_processor_classpath = True,
expected_exported_processor_classes = [],
+ expected_kotlinc_plugin_jar_names = [], # No kotlinc action
expected_processor_classes = ["java.plugin.class"],
target_under_test = ktfa.kt_jvm_library(
name = "has_plugin_and_only_java_srcs",
srcs = ["Input.java"],
- plugins = [":java_plugin_with_processor"],
+ plugins = [
+ ":java_plugin",
+ ":kt_compiler_plugin",
+ ],
),
)
kt_jvm_library_analysis_test(
- name = "has_plugin_without_processor_test",
+ name = "has_plugin_without_processor_class_test",
expect_processor_classpath = True,
expected_exported_processor_classes = [],
target_under_test = ktfa.kt_jvm_library(
- name = "has_plugin_without_processor",
+ name = "has_plugin_without_processor_class",
srcs = ["Input.java"],
- plugins = [":java_plugin_without_processor"],
- ),
-)
-
-kt_jvm_library_analysis_test(
- name = "has_exported_plugin_test",
- expect_processor_classpath = False,
- expected_exported_processor_classes = ["java.plugin.class"],
- expected_processor_classes = [], # exported plugin should *not* run on expoter itself
- target_under_test = ktfa.kt_jvm_library(
- name = "has_exported_plugin",
- srcs = ["Input.kt"],
- exported_plugins = [":java_plugin_with_processor"],
+ plugins = [
+ ktfa.java_plugin(
+ name = "java_plugin_without_processor_class",
+ srcs = ["Input.java"],
+ ),
+ ],
),
)
@@ -73,6 +79,7 @@ kt_jvm_library_analysis_test(
kt_jvm_library_analysis_test(
name = "dep_on_" + exporter + "_test",
expect_processor_classpath = True,
+ expected_kotlinc_plugin_jar_names = DEFAULT_KOTLINC_PLUGINS + ["kt_compiler_plugin.jar"],
expected_processor_classes = ["java.plugin.class"],
target_under_test = ktfa.kt_jvm_library(
name = "dep_on_" + exporter,
@@ -94,6 +101,7 @@ kt_jvm_library_analysis_test(
name = "kt_jvm_library_exporting_" + export + "_test",
expect_processor_classpath = False,
expected_exported_processor_classes = ["java.plugin.class"],
+ expected_kotlinc_plugin_jar_names = DEFAULT_KOTLINC_PLUGINS,
expected_processor_classes = [],
target_under_test = ktfa.kt_jvm_library(
name = "kt_jvm_library_exporting_" + export,
@@ -110,22 +118,36 @@ kt_jvm_library_analysis_test(
ktfa.java_library(
name = "java_library_with_exported_plugin",
srcs = ["Input.java"],
- exported_plugins = [":java_plugin_with_processor"],
+ exported_plugins = [
+ ":java_plugin",
+ ":kt_compiler_plugin",
+ ],
)
-ktfa.kt_jvm_library(
- name = "kt_jvm_library_with_exported_plugin",
- srcs = ["Input.kt"],
- exported_plugins = [":java_plugin_with_processor"],
+kt_jvm_library_analysis_test(
+ name = "kt_jvm_library_with_exported_plugin_test",
+ expect_processor_classpath = False,
+ expected_exported_processor_classes = ["java.plugin.class"],
+ expected_kotlinc_plugin_jar_names = DEFAULT_KOTLINC_PLUGINS,
+ expected_processor_classes = [], # exported plugin should *not* run on exporter itself
+ target_under_test = ktfa.kt_jvm_library(
+ name = "kt_jvm_library_with_exported_plugin",
+ srcs = ["Input.kt"],
+ exported_plugins = [
+ ":java_plugin",
+ ":kt_compiler_plugin",
+ ],
+ ),
)
-java_plugin(
- name = "java_plugin_with_processor",
+ktfa.java_plugin(
+ name = "java_plugin",
srcs = ["Input.java"],
processor_class = "java.plugin.class",
)
-java_plugin(
- name = "java_plugin_without_processor",
- srcs = ["Input.java"],
+ktfa.kt_compiler_plugin(
+ name = "kt_compiler_plugin",
+ jar = kt_testing_rules.create_file(name = "kt_compiler_plugin.jar"),
+ plugin_id = "kt.plugin",
)