aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornickreid <nickreid@google.com>2023-10-17 20:25:49 -0700
committerCopybara-Service <copybara-worker@google.com>2023-10-17 20:26:16 -0700
commitecffe6215bb1117daba5caa5a1525fc628fc2cd6 (patch)
tree8a71a1eaba530c2c38ba1b1b653eab0edc86e9eb
parentb0bba1aec080c9872958b23b5b69d56830d87afd (diff)
downloadbazelbuild-kotlin-rules-ecffe6215bb1117daba5caa5a1525fc628fc2cd6.tar.gz
Move compiler_plugin tests under analysis/jvm/compiler_plugin
Some tests are merged into the tests for kt_jvm_library PiperOrigin-RevId: 574339964 Change-Id: I09f465813c685d9ce72a5b44b0b8865efb45ad16
-rw-r--r--kotlin/common/testing/analysis.bzl75
-rw-r--r--kotlin/jvm/testing/for_analysis.bzl3
-rw-r--r--kotlin/jvm/testing/jvm_library_analysis_test.bzl17
-rw-r--r--tests/analysis/compiler_plugin/BUILD23
-rw-r--r--tests/analysis/compiler_plugin/propagation/BUILD79
-rw-r--r--tests/analysis/compiler_plugin/propagation/assert_propagation_test.bzl59
-rw-r--r--tests/analysis/compiler_plugin/provider_output/BUILD58
-rw-r--r--tests/analysis/compiler_plugin/provider_output/assert_compiler_plugin_test.bzl40
-rw-r--r--tests/analysis/util.bzl5
-rw-r--r--tests/jvm/analysis/compiler_plugin/forbidden_target/BUILD (renamed from tests/analysis/compiler_plugin/forbidden_target/BUILD)2
-rw-r--r--tests/jvm/analysis/compiler_plugin/provider_ctor/BUILD (renamed from tests/analysis/compiler_plugin/provider_ctor/BUILD)5
-rw-r--r--tests/jvm/analysis/compiler_plugin/provider_ctor/unittests.bzl (renamed from tests/analysis/compiler_plugin/provider_ctor/fake_compiler_plugin.bzl)32
-rw-r--r--tests/jvm/analysis/jvm_library/plugins/BUILD76
13 files changed, 131 insertions, 343 deletions
diff --git a/kotlin/common/testing/analysis.bzl b/kotlin/common/testing/analysis.bzl
index 711bc69..34cbfae 100644
--- a/kotlin/common/testing/analysis.bzl
+++ b/kotlin/common/testing/analysis.bzl
@@ -22,11 +22,11 @@ def _get_action(actions, mnemonic):
"""Get a specific action
Args:
- actions: [List[Action]]
- mnemonic: [string] Identify the action whose args to search
+ actions: [List[Action]]
+ mnemonic: [string] Identify the action whose args to search
Returns:
- [Optional[action]] The arg value, or None if it couldn't be found
+ [Action|None] The arg value, or None if it couldn't be found
"""
menmonic_actions = [a for a in actions if a.mnemonic == mnemonic]
if len(menmonic_actions) == 0:
@@ -36,42 +36,60 @@ def _get_action(actions, mnemonic):
return menmonic_actions[0]
-def _get_arg(action, arg_name, style = "trim"):
- """Get a named arg from a specific action
+def _get_all_args(action, arg_name, style = "trim"):
+ """Gets values for all instances of an arg name from a specific action.
Args:
- action: [Optional[Action]]
- arg_name: [string]
- style: ["trim"|"next"|"list"] The style of commandline arg
+ action: [Action|None]
+ arg_name: [string]
+ style: ["trim"|"next"|"list"] The style of commandline arg
Returns:
- [Optional[string]] The arg value, or None if it couldn't be found
+ [list[string]|list[list[string]]|None] The list of matching arg values
"""
if not action:
- return None
+ return []
args = action.argv
matches = [(i, a) for (i, a) in enumerate(args) if a.startswith(arg_name)]
- if len(matches) == 0:
- return None
- elif len(matches) > 1:
- fail("Expected a single '%s' arg" % arg_name)
- (index, arg) = matches[0]
-
- if style == "trim":
- return arg[len(arg_name):]
- elif style == "next":
- return args[index + 1]
- elif style == "list":
- result = []
- for i in range(index + 1, len(args)):
- if args[i].startswith("--"):
- break
- result.append(args[i])
- return result
+ result = []
+ for index, arg in matches:
+ if style == "trim":
+ result.append(arg[len(arg_name):])
+ elif style == "next":
+ result.append(args[index + 1])
+ elif style == "list":
+ sub_result = []
+ for i in range(index + 1, len(args)):
+ if args[i].startswith("--"):
+ break
+ sub_result.append(args[i])
+ result.append(sub_result)
+ else:
+ fail("Unrecognized arg style '%s" % style)
+
+ return result
+
+def _get_arg(action, arg_name, style = "trim"):
+ """Gets values for exactly one instance of an arg name from a specific action.
+
+ Args:
+ action: [Action|None]
+ arg_name: [string]
+ style: ["trim"|"next"|"list"] The style of commandline arg
+
+ Returns:
+ [string|list[string]|None] The arg value, or None if it couldn't be found
+ """
+ results = _get_all_args(action, arg_name, style)
+
+ if len(results) == 0:
+ return None
+ elif len(results) == 1:
+ return results[0]
else:
- fail("Unrecognized arg style '%s" % style)
+ fail("Expected a single '%s' arg" % arg_name)
def _check_endswith_test(ctx):
name = ctx.label.name
@@ -90,6 +108,7 @@ kt_analysis = struct(
DEFAULT_LIST = ["__default__"],
check_endswith_test = _check_endswith_test,
get_action = _get_action,
+ get_all_args = _get_all_args,
get_arg = _get_arg,
# go/keep-sorted end
)
diff --git a/kotlin/jvm/testing/for_analysis.bzl b/kotlin/jvm/testing/for_analysis.bzl
index 5172b4e..1ba4fcd 100644
--- a/kotlin/jvm/testing/for_analysis.bzl
+++ b/kotlin/jvm/testing/for_analysis.bzl
@@ -15,6 +15,7 @@
"""kt_for_analysis"""
load("//:visibility.bzl", "RULES_KOTLIN")
+load("//kotlin:compiler_plugin.bzl", "kt_compiler_plugin")
load("//kotlin:jvm_import.bzl", "kt_jvm_import")
load("//kotlin:jvm_library.bzl", "kt_jvm_library")
load("//kotlin/common/testing:testing_rules.bzl", "kt_testing_rules")
@@ -26,6 +27,8 @@ kt_for_analysis = struct(
java_binary = kt_testing_rules.wrap_for_analysis(native.java_binary),
java_import = kt_testing_rules.wrap_for_analysis(native.java_import),
java_library = kt_testing_rules.wrap_for_analysis(native.java_library),
+ java_plugin = kt_testing_rules.wrap_for_analysis(native.java_plugin),
+ kt_compiler_plugin = kt_testing_rules.wrap_for_analysis(kt_compiler_plugin),
kt_jvm_import = kt_testing_rules.wrap_for_analysis(kt_jvm_import),
kt_jvm_library = kt_testing_rules.wrap_for_analysis(kt_jvm_library),
# go/keep-sorted end
diff --git a/kotlin/jvm/testing/jvm_library_analysis_test.bzl b/kotlin/jvm/testing/jvm_library_analysis_test.bzl
index 28dc71d..6e05b28 100644
--- a/kotlin/jvm/testing/jvm_library_analysis_test.bzl
+++ b/kotlin/jvm/testing/jvm_library_analysis_test.bzl
@@ -43,6 +43,10 @@ kt_jvm_library_analysis_test = analysistest.make(
expected_processor_classes = attr.string_list(
doc = "Annotation processors reported as run on the given target",
),
+ expected_kotlinc_plugin_jar_names = attr.string_list(
+ doc = "Names of all -Xplugin= JARs",
+ default = kt_analysis.DEFAULT_LIST,
+ ),
expected_friend_jar_names = attr.string_list(
doc = "Names of all -Xfriend-paths= JARs",
default = kt_analysis.DEFAULT_LIST,
@@ -124,12 +128,21 @@ def _kt_jvm_library_analysis_test_impl(ctx):
friend_paths_arg = kt_analysis.get_arg(kt_2_java_compile, "-Xfriend-paths=")
kt_asserts.list_matches(
env,
- expected = ctx.attr.expected_friend_jar_names,
- actual = ["/" + x for x in (friend_paths_arg.split(",") if friend_paths_arg else [])],
+ expected = ["/" + x for x in ctx.attr.expected_friend_jar_names],
+ actual = friend_paths_arg.split(",") if friend_paths_arg else [],
matcher = lambda expected, actual: actual.endswith(expected),
items_name = "friend JARs",
)
+ if ctx.attr.expected_kotlinc_plugin_jar_names != kt_analysis.DEFAULT_LIST:
+ kt_asserts.list_matches(
+ env,
+ expected = ["/" + x for x in ctx.attr.expected_kotlinc_plugin_jar_names],
+ actual = kt_analysis.get_all_args(kt_2_java_compile, "-Xplugin="),
+ matcher = lambda expected, actual: actual.endswith(expected),
+ items_name = "kotlinc plugin JARs",
+ )
+
asserts.equals(
env,
ctx.attr.expect_neverlink,
diff --git a/tests/analysis/compiler_plugin/BUILD b/tests/analysis/compiler_plugin/BUILD
deleted file mode 100644
index 0c1f9b6..0000000
--- a/tests/analysis/compiler_plugin/BUILD
+++ /dev/null
@@ -1,23 +0,0 @@
-# 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.
-
-licenses(["notice"])
-
-genrule(
- name = "empty_jar",
- outs = ["empty.jar"],
- cmd = """$(location @bazel_tools//tools/zip:zipper) c $@ "assets/_empty=" """,
- tools = ["@bazel_tools//tools/zip:zipper"],
- visibility = ["//tests/analysis/compiler_plugin:__subpackages__"],
-)
diff --git a/tests/analysis/compiler_plugin/propagation/BUILD b/tests/analysis/compiler_plugin/propagation/BUILD
deleted file mode 100644
index 0c6fe19..0000000
--- a/tests/analysis/compiler_plugin/propagation/BUILD
+++ /dev/null
@@ -1,79 +0,0 @@
-# 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:compiler_plugin.bzl", "kt_compiler_plugin")
-load(":assert_propagation_test.bzl", "assert_propagation_test")
-
-licenses(["notice"])
-
-assert_propagation_test(
- name = "f",
- expected_plugin_ids = ["1"],
- deps = [":e"],
-)
-
-assert_propagation_test(
- name = "e",
- expected_plugin_ids = [],
- exports = [":a"],
-)
-
-assert_propagation_test(
- name = "d",
- expected_plugin_ids = [
- "1",
- "2",
- ],
- deps = [
- ":a",
- ":b",
- ],
-)
-
-assert_propagation_test(
- name = "c",
- expected_plugin_ids = ["2"],
- deps = [":b"],
-)
-
-assert_propagation_test(
- name = "b",
- expected_plugin_ids = ["1"],
- exported_plugins = [":2"],
- deps = [":a"],
-)
-
-assert_propagation_test(
- name = "a",
- expected_plugin_ids = [],
- exported_plugins = [":1"],
-)
-
-kt_compiler_plugin(
- name = "1",
- jar = "//tests/analysis/compiler_plugin:empty_jar",
- plugin_id = "1",
-)
-
-kt_compiler_plugin(
- name = "2",
- jar = "//tests/analysis/compiler_plugin:empty_jar",
- plugin_id = "2",
-)
-
-kt_compiler_plugin(
- name = "3",
- jar = "//tests/analysis/compiler_plugin:empty_jar",
- plugin_id = "3",
-)
diff --git a/tests/analysis/compiler_plugin/propagation/assert_propagation_test.bzl b/tests/analysis/compiler_plugin/propagation/assert_propagation_test.bzl
deleted file mode 100644
index fdab497..0000000
--- a/tests/analysis/compiler_plugin/propagation/assert_propagation_test.bzl
+++ /dev/null
@@ -1,59 +0,0 @@
-# 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.
-
-"""Rule for asserting plugin propagation."""
-
-load("//:visibility.bzl", "RULES_KOTLIN")
-load("//kotlin:traverse_exports.bzl", "kt_traverse_exports")
-load("@bazel_skylib//lib:sets.bzl", "sets")
-load("@bazel_skylib//rules:build_test.bzl", "build_test")
-
-visibility(RULES_KOTLIN)
-
-def _assert_propagation_impl(ctx):
- expected_ids = sets.make(ctx.attr.expected_plugin_ids)
- actual_ids = sets.make([
- p.plugin_id
- for p in kt_traverse_exports.expand_compiler_plugins(ctx.attr.deps).to_list()
- ])
-
- if not sets.is_equal(expected_ids, actual_ids):
- fail("Expected IDs %s, actual IDs %s" % (sets.to_list(expected_ids), sets.to_list(actual_ids)))
-
- return [
- # Needed for kt_traverse_exports.aspect
- JavaInfo(
- compile_jar = ctx.file._empty_jar,
- output_jar = ctx.file._empty_jar,
- ),
- ]
-
-_assert_propagation = rule(
- implementation = _assert_propagation_impl,
- attrs = dict(
- exports = attr.label_list(),
- exported_plugins = attr.label_list(),
- expected_plugin_ids = attr.string_list(),
- deps = attr.label_list(aspects = [kt_traverse_exports.aspect]),
- _empty_jar = attr.label(
- allow_single_file = True,
- default = "//tests/analysis/compiler_plugin:empty_jar",
- ),
- ),
-)
-
-def assert_propagation_test(name, **kwargs):
- _assert_propagation(name = name, **kwargs)
-
- build_test(name = name + "_build", targets = [name])
diff --git a/tests/analysis/compiler_plugin/provider_output/BUILD b/tests/analysis/compiler_plugin/provider_output/BUILD
deleted file mode 100644
index 4769965..0000000
--- a/tests/analysis/compiler_plugin/provider_output/BUILD
+++ /dev/null
@@ -1,58 +0,0 @@
-# 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:compiler_plugin.bzl", "kt_compiler_plugin")
-load("//tests/analysis:util.bzl", "create_file")
-load("@bazel_skylib//rules:build_test.bzl", "build_test")
-load(":assert_compiler_plugin_test.bzl", "assert_compiler_plugin_test")
-
-licenses(["notice"])
-
-assert_compiler_plugin_test(
- name = "example_plugin_test",
- expected_args = [
- "plugin:com.google.example:key=value",
- ],
- expected_id = "com.google.example",
- expected_jar = "//tests/analysis/compiler_plugin:empty_jar",
- target_under_test = ":example_plugin",
-)
-
-build_test(
- name = "example_plugin_in_java_library_build_test",
- targets = [
- ":example_plugin_in_java_library",
- ],
-)
-
-java_library(
- name = "example_plugin_in_java_library",
- srcs = [create_file(
- name = "Tmp.java",
- content = """
- @SuppressWarnings("DefaultPackage")
- class Tmp { }
- """,
- )],
- plugins = [":example_plugin"],
-)
-
-kt_compiler_plugin(
- name = "example_plugin",
- args = {
- "key": "value",
- },
- jar = "//tests/analysis/compiler_plugin:empty_jar",
- plugin_id = "com.google.example",
-)
diff --git a/tests/analysis/compiler_plugin/provider_output/assert_compiler_plugin_test.bzl b/tests/analysis/compiler_plugin/provider_output/assert_compiler_plugin_test.bzl
deleted file mode 100644
index 1c14e22..0000000
--- a/tests/analysis/compiler_plugin/provider_output/assert_compiler_plugin_test.bzl
+++ /dev/null
@@ -1,40 +0,0 @@
-# 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.
-
-"""An assertion on kt_compiler_plugin analysis."""
-
-load("//:visibility.bzl", "RULES_KOTLIN")
-load("//kotlin:compiler_plugin.bzl", "KtCompilerPluginInfo")
-load("@bazel_skylib//lib:unittest.bzl", "analysistest", "asserts")
-
-visibility(RULES_KOTLIN)
-
-def _test_impl(ctx):
- env = analysistest.begin(ctx)
- info = ctx.attr.target_under_test[KtCompilerPluginInfo]
-
- asserts.equals(env, info.plugin_id, ctx.attr.expected_id)
- asserts.equals(env, info.jar, ctx.file.expected_jar)
- asserts.equals(env, info.args, ctx.attr.expected_args)
-
- return analysistest.end(env)
-
-assert_compiler_plugin_test = analysistest.make(
- impl = _test_impl,
- attrs = dict(
- expected_id = attr.string(),
- expected_jar = attr.label(allow_single_file = True, cfg = "exec"),
- expected_args = attr.string_list(),
- ),
-)
diff --git a/tests/analysis/util.bzl b/tests/analysis/util.bzl
index a3b97bf..773f0e6 100644
--- a/tests/analysis/util.bzl
+++ b/tests/analysis/util.bzl
@@ -15,7 +15,6 @@
"""Some utils"""
load("//:visibility.bzl", "RULES_KOTLIN")
-load("//kotlin/common/testing:analysis.bzl", "kt_analysis")
load("//kotlin/common/testing:testing_rules.bzl", "kt_testing_rules")
visibility(RULES_KOTLIN)
@@ -26,7 +25,3 @@ ONLY_FOR_ANALYSIS_TEST_TAGS = kt_testing_rules.ONLY_FOR_ANALYSIS_TAGS
create_file = kt_testing_rules.create_file
create_dir = kt_testing_rules.create_dir
-
-get_arg = kt_analysis.get_arg
-
-get_action = kt_analysis.get_action
diff --git a/tests/analysis/compiler_plugin/forbidden_target/BUILD b/tests/jvm/analysis/compiler_plugin/forbidden_target/BUILD
index 79b60f9..d21f27c 100644
--- a/tests/analysis/compiler_plugin/forbidden_target/BUILD
+++ b/tests/jvm/analysis/compiler_plugin/forbidden_target/BUILD
@@ -12,8 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-load("//kotlin:compiler_plugin.bzl", "kt_compiler_plugin")
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"],
diff --git a/tests/analysis/compiler_plugin/provider_ctor/BUILD b/tests/jvm/analysis/compiler_plugin/provider_ctor/BUILD
index 059804d..0ba8b21 100644
--- a/tests/analysis/compiler_plugin/provider_ctor/BUILD
+++ b/tests/jvm/analysis/compiler_plugin/provider_ctor/BUILD
@@ -12,8 +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(":fake_compiler_plugin.bzl", "kt_fake_compiler_plugin")
+load(":unittests.bzl", "unittests")
package(
default_applicable_licenses = ["//:license"],
@@ -21,3 +20,5 @@ package(
)
licenses(["notice"])
+
+unittests.render(name = "unittests")
diff --git a/tests/analysis/compiler_plugin/provider_ctor/fake_compiler_plugin.bzl b/tests/jvm/analysis/compiler_plugin/provider_ctor/unittests.bzl
index 4b7fc45..e43744f 100644
--- a/tests/analysis/compiler_plugin/provider_ctor/fake_compiler_plugin.bzl
+++ b/tests/jvm/analysis/compiler_plugin/provider_ctor/unittests.bzl
@@ -12,29 +12,23 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-"""A fake impl of kt_compiler_plugin."""
+"""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)
-def _kt_fake_compiler_plugin_impl(ctx):
- return [
- KtCompilerPluginInfo(
- plugin_id = "fake",
- jar = ctx.file._jar,
- args = [],
- ),
- ]
+unittests = kt_unittest_suites.create()
-kt_fake_compiler_plugin = rule(
- implementation = _kt_fake_compiler_plugin_impl,
- attrs = dict(
- _jar = attr.label(
- allow_single_file = True,
- default = "//tests/analysis/compiler_plugin:empty_jar",
- ),
- ),
- provides = [KtCompilerPluginInfo],
-)
+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",
)