• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (C) 2017 The Dagger Authors.
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15# Description:
16#   Tests for the Dagger compiler/codegen
17
18load("@io_bazel_rules_kotlin//kotlin:jvm.bzl", "kt_jvm_library")
19load("@rules_java//java:defs.bzl", "java_library")
20load("//:build_defs.bzl", "DOCLINT_HTML_AND_SYNTAX")
21load("//:test_defs.bzl", "GenJavaTests")
22
23package(default_visibility = ["//:src"])
24
25# These sources are purposely compiled without the Dagger compiler for certain tests.
26kt_jvm_library(
27    name = "kt_lib_no_dagger_compiler",
28    srcs = [
29        "KotlinInjectedQualifier.kt",
30        "KotlinObjectWithMemberInjection.kt",
31    ],
32    deps = [
33        "//java/dagger:core",
34    ],
35)
36
37# These sources are purposely compiled without the Dagger compiler for certain tests.
38java_library(
39    name = "java_lib_no_dagger_compiler",
40    srcs = [
41        "ComponentProcessorTestClasses.java",
42        "InvalidInjectConstructor.java",
43    ],
44    deps = [
45        "//third_party/java/jsr330_inject",
46    ],
47)
48
49# TODO(bcorso): Move this into a subpackage.
50java_library(
51    name = "compilers",
52    srcs = [
53        "CompilerMode.java",
54        "Compilers.java",
55        "ComponentCreatorTestHelper.java",
56        "DaggerModuleMethodSubject.java",
57        "GeneratingProcessingStep.java",
58        "JavaFileBuilder.java",
59        "TestUtils.java",
60    ],
61    deps = [
62        "//java/dagger:core",
63        "//java/dagger/internal/codegen:package_info",
64        "//java/dagger/internal/codegen:processor",
65        "//java/dagger/internal/codegen/base",
66        "//java/dagger/internal/codegen/binding",
67        "//java/dagger/internal/codegen/xprocessing",
68        "//java/dagger/internal/codegen/xprocessing:xprocessing-testing",
69        "//java/dagger/producers",
70        "//java/dagger/testing/compile",
71        "//third_party/java/compile_testing",
72        "//third_party/java/guava/base",
73        "//third_party/java/guava/collect",
74        "//third_party/java/javapoet",
75        "//third_party/java/truth",
76        "@maven//:com_google_auto_value_auto_value",
77    ],
78)
79
80# These are tests with over 25 test cases.
81LARGE_TESTS = [
82    "ComponentCreatorTest.java",
83    "ComponentProcessorTest.java",
84    "InjectConstructorFactoryGeneratorTest.java",
85    "MembersInjectionTest.java",
86    "MissingBindingValidationTest.java",
87    "ModuleFactoryGeneratorTest.java",
88    "ProducerModuleFactoryGeneratorTest.java",
89    "SubcomponentCreatorValidationTest.java",
90]
91
92# These are tests with over 10 test cases
93MEDIUM_TESTS = [
94    "BindsMethodValidationTest.java",
95    "DaggerSuperficialValidationTest.java",
96    "DelegateRequestRepresentationTest.java",
97    "DuplicateBindingsValidationTest.java",
98    "IgnoreProvisionKeyWildcardsTest.java",
99    "MapMultibindingValidationTest.java",
100    "MultibindsValidationTest.java",
101    "ProductionComponentProcessorTest.java",
102    "ProductionGraphValidationTest.java",
103    "SubcomponentValidationTest.java",
104]
105
106DEPS = [
107    ":compilers",
108    ":java_lib_no_dagger_compiler",
109    ":kt_lib_no_dagger_compiler",
110    "//third_party/java/guava/base",
111    "//third_party/java/guava/collect",
112    "//third_party/java/guava/util/concurrent",
113    "//third_party/java/auto:value",
114    "@maven//:com_google_auto_value_auto_value",
115    "//third_party/java/auto:common",
116    "//third_party/java/compile_testing",
117    "//third_party/java/javapoet",
118    "//third_party/java/jsr250_annotations",  # Include @Generated in generated files.
119    "//third_party/java/jsr330_inject",
120    "//third_party/java/junit",
121    "//third_party/java/mockito",
122    "//third_party/java/truth",
123    "//java/dagger:core",
124    "//java/dagger/internal/codegen:package_info",
125    "//java/dagger/internal/codegen:processor",
126    "//java/dagger/internal/codegen/base",
127    "//java/dagger/internal/codegen/binding",
128    "//java/dagger/internal/codegen/bindinggraphvalidation",
129    "//java/dagger/internal/codegen/compileroption",
130    "//java/dagger/internal/codegen/extension",
131    "//java/dagger/internal/codegen/javac",
132    "//java/dagger/internal/codegen/javapoet",
133    "//java/dagger/internal/codegen/kotlin",
134    "//java/dagger/internal/codegen/langmodel",
135    "//java/dagger/internal/codegen/model",
136    "//java/dagger/internal/codegen/validation",
137    "//java/dagger/internal/codegen/writing",
138    "//java/dagger/internal/codegen/xprocessing",
139    "//java/dagger/internal/codegen/xprocessing:xprocessing-testing",
140    "//java/dagger/model/testing",
141    "//java/dagger/producers",
142    "//java/dagger/spi",
143    "//java/dagger/spi/model/testing",
144    "//java/dagger/testing/compile",
145    "//java/dagger/testing/golden",
146]
147
148GenJavaTests(
149    name = "large_compiler_tests",
150    srcs = LARGE_TESTS,
151    functional = False,
152    javacopts = DOCLINT_HTML_AND_SYNTAX,
153    plugins = ["//java/dagger/internal/codegen/bootstrap"],
154    shard_count = 7,
155    deps = DEPS,
156)
157
158GenJavaTests(
159    name = "medium_compiler_tests",
160    srcs = MEDIUM_TESTS,
161    functional = False,
162    javacopts = DOCLINT_HTML_AND_SYNTAX,
163    plugins = ["//java/dagger/internal/codegen/bootstrap"],
164    shard_count = 3,
165    deps = DEPS,
166)
167
168GenJavaTests(
169    name = "compiler_tests",
170    srcs = glob(
171        ["*.java"],
172        exclude = [
173            "CompilerMode.java",
174            "Compilers.java",
175            "ComponentCreatorTestHelper.java",
176            "ComponentProcessorTestClasses.java",
177            "DaggerModuleMethodSubject.java",
178            "GeneratingProcessingStep.java",
179            "InvalidInjectConstructor.java",
180            "JavaFileBuilder.java",
181            "TestUtils.java",
182        ] + LARGE_TESTS + MEDIUM_TESTS,
183    ),
184    functional = False,
185    javacopts = DOCLINT_HTML_AND_SYNTAX,
186    plugins = ["//java/dagger/internal/codegen/bootstrap"],
187    deps = DEPS,
188)
189