forked from bazelbuild/rules_java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjava_plugin_tests.bzl
More file actions
85 lines (76 loc) · 3.01 KB
/
Copy pathjava_plugin_tests.bzl
File metadata and controls
85 lines (76 loc) · 3.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
"""Tests for the java_plugin rule"""
load("@rules_testing//lib:analysis_test.bzl", "analysis_test", "test_suite")
load("@rules_testing//lib:util.bzl", "util")
load("//java:java_library.bzl", "java_library")
load("//java:java_plugin.bzl", "java_plugin")
load("//java/common:java_plugin_info.bzl", "JavaPluginInfo")
load("//test/java/testutil:java_info_subject.bzl", "java_plugin_info_subject")
def _test_exposes_plugins_to_starlark(name):
target_name = name + "/plugin"
util.helper_target(
java_library,
name = target_name + "/plugin_dep",
srcs = ["ProcessorDep.java"],
data = ["depfile.dat"],
)
util.helper_target(
java_plugin,
name = target_name,
srcs = ["AnnotationProcessor.java"],
data = ["pluginfile.dat"],
processor_class = "com.google.process.stuff",
deps = [target_name + "/plugin_dep"],
)
analysis_test(
name = name,
impl = _test_exposes_plugins_to_starlark_impl,
target = target_name,
)
def _test_exposes_plugins_to_starlark_impl(env, target):
assert_plugin_data = java_plugin_info_subject.from_target(env, target).plugins()
assert_plugin_data.processor_classes().contains_exactly(["com.google.process.stuff"])
assert_plugin_data.processor_jars().contains_exactly([
"{package}/lib{name}.jar",
"{package}/lib{name}/plugin_dep.jar",
])
assert_plugin_data.processor_data().contains_exactly(["{package}/pluginfile.dat"])
java_plugin_info_subject.from_target(env, target).api_generating_plugins().is_empty()
def _test_exposes_api_generating_plugins_to_starlark(name):
target_name = name + "/plugin"
util.helper_target(
java_library,
name = target_name + "/plugin_dep",
srcs = ["ProcessorDep.java"],
data = ["depfile.dat"],
)
util.helper_target(
java_plugin,
name = target_name,
srcs = ["AnnotationProcessor.java"],
data = ["pluginfile.dat"],
processor_class = "com.google.process.stuff",
deps = [target_name + "/plugin_dep"],
generates_api = True,
)
analysis_test(
name = name,
impl = _test_exposes_api_generating_plugins_to_starlark_impl,
target = target_name,
)
def _test_exposes_api_generating_plugins_to_starlark_impl(env, target):
assert_api_plugin_data = java_plugin_info_subject.from_target(env, target).api_generating_plugins()
assert_api_plugin_data.processor_classes().contains_exactly(["com.google.process.stuff"])
assert_api_plugin_data.processor_jars().contains_exactly([
"{package}/lib{name}.jar",
"{package}/lib{name}/plugin_dep.jar",
])
assert_api_plugin_data.processor_data().contains_exactly(["{package}/pluginfile.dat"])
assert_api_plugin_data.equals(target[JavaPluginInfo].plugins)
def java_plugin_tests(name):
test_suite(
name = name,
tests = [
_test_exposes_plugins_to_starlark,
_test_exposes_api_generating_plugins_to_starlark,
],
)