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:kotlin.bzl", "kt_jvm_library") 19load("//:build_defs.bzl", "DOCLINT_HTML_AND_SYNTAX") 20load("//:test_defs.bzl", "GenJavaTests") 21 22package(default_visibility = ["//:src"]) 23 24# These sources are purposely compiled without the Dagger compiler for certain tests. 25kt_jvm_library( 26 name = "kt_lib_no_dagger_compiler", 27 srcs = [ 28 "KotlinInjectedQualifier.kt", 29 "KotlinObjectWithMemberInjection.kt", 30 ], 31 deps = [ 32 "//java/dagger:core", 33 ], 34) 35 36# These sources are purposely compiled without the Dagger compiler for certain tests. 37java_library( 38 name = "java_lib_no_dagger_compiler", 39 srcs = [ 40 "ComponentProcessorTestClasses.java", 41 "InvalidInjectConstructor.java", 42 ], 43 deps = [ 44 "//third_party/java/jsr330_inject", 45 ], 46) 47 48# TODO(bcorso): Move this into a subpackage. 49java_library( 50 name = "compilers", 51 srcs = [ 52 "CompilerMode.java", 53 "Compilers.java", 54 "ComponentCreatorTestHelper.java", 55 "DaggerModuleMethodSubject.java", 56 "GeneratingProcessingStep.java", 57 "JavaFileBuilder.java", 58 "TestUtils.java", 59 ], 60 deps = [ 61 "//java/dagger:core", 62 "//java/dagger/internal/codegen:package_info", 63 "//java/dagger/internal/codegen:processor", 64 "//java/dagger/internal/codegen/base", 65 "//java/dagger/internal/codegen/binding", 66 "//java/dagger/internal/codegen/xprocessing", 67 "//java/dagger/internal/codegen/xprocessing:xprocessing-testing", 68 "//java/dagger/producers", 69 "//java/dagger/testing/compile", 70 "//third_party/java/compile_testing", 71 "//third_party/java/guava/base", 72 "//third_party/java/guava/collect", 73 "//third_party/java/javapoet", 74 "//third_party/java/truth", 75 "@com_google_auto_value_auto_value//jar", 76 ], 77) 78 79# These are tests with over 25 test cases. 80LARGE_TESTS = [ 81 "ComponentCreatorTest.java", 82 "ComponentProcessorTest.java", 83 "InjectConstructorFactoryGeneratorTest.java", 84 "MembersInjectionTest.java", 85 "MissingBindingValidationTest.java", 86 "ModuleFactoryGeneratorTest.java", 87 "ProducerModuleFactoryGeneratorTest.java", 88 "SubcomponentCreatorValidationTest.java", 89] 90 91# These are tests with over 10 test cases 92MEDIUM_TESTS = [ 93 "BindsMethodValidationTest.java", 94 "DaggerSuperficialValidationTest.java", 95 "DelegateRequestRepresentationTest.java", 96 "DuplicateBindingsValidationTest.java", 97 "IgnoreProvisionKeyWildcardsTest.java", 98 "MapMultibindingValidationTest.java", 99 "MultibindsValidationTest.java", 100 "ProductionComponentProcessorTest.java", 101 "ProductionGraphValidationTest.java", 102 "SubcomponentValidationTest.java", 103] 104 105DEPS = [ 106 ":compilers", 107 ":java_lib_no_dagger_compiler", 108 ":kt_lib_no_dagger_compiler", 109 "//third_party/java/guava/base", 110 "//third_party/java/guava/collect", 111 "//third_party/java/guava/util/concurrent", 112 "//third_party/java/auto:value", 113 "@com_google_auto_value_auto_value//jar", 114 "//third_party/java/auto:common", 115 "//third_party/java/compile_testing", 116 "//third_party/java/javapoet", 117 "//third_party/java/jsr250_annotations", # Include @Generated in generated files. 118 "//third_party/java/jsr330_inject", 119 "//third_party/java/junit", 120 "//third_party/java/mockito", 121 "//third_party/java/truth", 122 "//java/dagger:core", 123 "//java/dagger/internal/codegen:package_info", 124 "//java/dagger/internal/codegen:processor", 125 "//java/dagger/internal/codegen/base", 126 "//java/dagger/internal/codegen/binding", 127 "//java/dagger/internal/codegen/bindinggraphvalidation", 128 "//java/dagger/internal/codegen/compileroption", 129 "//java/dagger/internal/codegen/extension", 130 "//java/dagger/internal/codegen/javac", 131 "//java/dagger/internal/codegen/javapoet", 132 "//java/dagger/internal/codegen/kotlin", 133 "//java/dagger/internal/codegen/langmodel", 134 "//java/dagger/internal/codegen/model", 135 "//java/dagger/internal/codegen/validation", 136 "//java/dagger/internal/codegen/writing", 137 "//java/dagger/internal/codegen/xprocessing", 138 "//java/dagger/internal/codegen/xprocessing:xprocessing-testing", 139 "//java/dagger/model/testing", 140 "//java/dagger/producers", 141 "//java/dagger/spi", 142 "//java/dagger/spi/model/testing", 143 "//java/dagger/testing/compile", 144 "//java/dagger/testing/golden", 145] 146 147GenJavaTests( 148 name = "large_compiler_tests", 149 srcs = LARGE_TESTS, 150 functional = False, 151 javacopts = DOCLINT_HTML_AND_SYNTAX, 152 plugins = ["//java/dagger/internal/codegen/bootstrap"], 153 shard_count = 7, 154 deps = DEPS, 155) 156 157GenJavaTests( 158 name = "medium_compiler_tests", 159 srcs = MEDIUM_TESTS, 160 functional = False, 161 javacopts = DOCLINT_HTML_AND_SYNTAX, 162 plugins = ["//java/dagger/internal/codegen/bootstrap"], 163 shard_count = 3, 164 deps = DEPS, 165) 166 167GenJavaTests( 168 name = "compiler_tests", 169 srcs = glob( 170 ["*.java"], 171 exclude = [ 172 "CompilerMode.java", 173 "Compilers.java", 174 "ComponentCreatorTestHelper.java", 175 "ComponentProcessorTestClasses.java", 176 "DaggerModuleMethodSubject.java", 177 "GeneratingProcessingStep.java", 178 "InvalidInjectConstructor.java", 179 "JavaFileBuilder.java", 180 "TestUtils.java", 181 ] + LARGE_TESTS + MEDIUM_TESTS, 182 ), 183 functional = False, 184 javacopts = DOCLINT_HTML_AND_SYNTAX, 185 plugins = ["//java/dagger/internal/codegen/bootstrap"], 186 deps = DEPS, 187) 188