[KAPT] Migrate kapt tests to new test infrastructure
This commit is contained in:
committed by
teamcity
parent
fdf1b8b1c0
commit
9c41e75802
+2
-1
@@ -35,7 +35,8 @@ class SimpleDirective(
|
||||
class StringDirective(
|
||||
name: String,
|
||||
description: String,
|
||||
applicability: DirectiveApplicability
|
||||
applicability: DirectiveApplicability,
|
||||
val multiLine: Boolean
|
||||
) : Directive(name, description, applicability)
|
||||
|
||||
class ValueDirective<T : Any>(
|
||||
|
||||
+3
-2
@@ -29,9 +29,10 @@ abstract class SimpleDirectivesContainer : DirectivesContainer() {
|
||||
|
||||
protected fun stringDirective(
|
||||
description: String,
|
||||
applicability: DirectiveApplicability = DirectiveApplicability.Global
|
||||
applicability: DirectiveApplicability = DirectiveApplicability.Global,
|
||||
multiLine: Boolean = false
|
||||
): DirectiveDelegateProvider<StringDirective> {
|
||||
return DirectiveDelegateProvider { StringDirective(it, description, applicability) }
|
||||
return DirectiveDelegateProvider { StringDirective(it, description, applicability, multiLine) }
|
||||
}
|
||||
|
||||
protected inline fun <reified T : Enum<T>> enumDirective(
|
||||
|
||||
+8
@@ -17,6 +17,7 @@ import org.jetbrains.kotlin.idea.KotlinLanguage
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.sourceFiles.LightTreeFile
|
||||
import org.jetbrains.kotlin.test.model.TestFile
|
||||
import org.jetbrains.kotlin.test.model.TestModule
|
||||
import org.jetbrains.kotlin.test.util.KtTestUtil
|
||||
import org.jetbrains.kotlin.toSourceLinesMapping
|
||||
import java.io.File
|
||||
@@ -142,3 +143,10 @@ val TestFile.isJsFile: Boolean
|
||||
|
||||
val TestFile.isMjsFile: Boolean
|
||||
get() = name.endsWith(".mjs")
|
||||
|
||||
val TestModule.javaFiles: List<TestFile>
|
||||
get() = files.filter { it.isJavaFile }
|
||||
|
||||
fun SourceFileProvider.getRealJavaFiles(module: TestModule): List<File> {
|
||||
return module.javaFiles.map { getRealFileForSourceFile(it) }
|
||||
}
|
||||
|
||||
+1
@@ -10,6 +10,7 @@ import java.io.File
|
||||
abstract class TemporaryDirectoryManager(protected val testServices: TestServices) : TestService {
|
||||
abstract fun getOrCreateTempDirectory(name: String): File
|
||||
abstract fun cleanupTemporaryDirectories()
|
||||
abstract val rootDir: File
|
||||
}
|
||||
|
||||
val TestServices.temporaryDirectoryManager: TemporaryDirectoryManager by TestServices.testServiceAccessor()
|
||||
|
||||
+9
-5
@@ -18,12 +18,13 @@ class RegisteredDirectivesParser(private val container: DirectivesContainer, pri
|
||||
fun parseDirective(line: String): RawDirective? {
|
||||
val result = DIRECTIVE_PATTERN.matchEntire(line)?.groupValues ?: return null
|
||||
val name = result.getOrNull(NAME_GROUP) ?: return null
|
||||
val values = result.getOrNull(VALUES_GROUP)?.split(SPACES_PATTERN)?.filter { it.isNotBlank() }?.takeIf { it.isNotEmpty() }
|
||||
return RawDirective(name, values)
|
||||
val rawValue = result.getOrNull(VALUES_GROUP)
|
||||
val values = rawValue?.split(SPACES_PATTERN)?.filter { it.isNotBlank() }?.takeIf { it.isNotEmpty() }
|
||||
return RawDirective(name, values, rawValue)
|
||||
}
|
||||
}
|
||||
|
||||
data class RawDirective(val name: String, val values: List<String>?)
|
||||
data class RawDirective(val name: String, val values: List<String>?, val rawValue: String?)
|
||||
data class ParsedDirective(val directive: Directive, val values: List<*>)
|
||||
|
||||
private val simpleDirectives = mutableListOf<SimpleDirective>()
|
||||
@@ -58,7 +59,7 @@ class RegisteredDirectivesParser(private val container: DirectivesContainer, pri
|
||||
}
|
||||
|
||||
fun convertToRegisteredDirective(rawDirective: RawDirective): ParsedDirective? {
|
||||
val (name, rawValues) = rawDirective
|
||||
val (name, rawValues, rawValueString) = rawDirective
|
||||
val directive = container[name] ?: return null
|
||||
|
||||
val values: List<*> = when (directive) {
|
||||
@@ -72,7 +73,10 @@ class RegisteredDirectivesParser(private val container: DirectivesContainer, pri
|
||||
}
|
||||
|
||||
is StringDirective -> {
|
||||
rawValues ?: emptyList<Any?>()
|
||||
when (directive.multiLine) {
|
||||
true -> listOfNotNull(rawValueString)
|
||||
false -> rawValues ?: emptyList()
|
||||
}
|
||||
}
|
||||
|
||||
is ValueDirective<*> -> {
|
||||
|
||||
+2
-5
@@ -15,11 +15,8 @@ import org.jetbrains.kotlin.test.compileJavaFilesExternally
|
||||
import org.jetbrains.kotlin.test.directives.CodegenTestDirectives
|
||||
import org.jetbrains.kotlin.test.directives.CodegenTestDirectives.USE_JAVAC_BASED_ON_JVM_TARGET
|
||||
import org.jetbrains.kotlin.test.model.TestModule
|
||||
import org.jetbrains.kotlin.test.services.TestServices
|
||||
import org.jetbrains.kotlin.test.services.assertions
|
||||
import org.jetbrains.kotlin.test.services.javaFiles
|
||||
import org.jetbrains.kotlin.test.services.*
|
||||
import org.jetbrains.kotlin.test.services.jvm.compiledClassesManager
|
||||
import org.jetbrains.kotlin.test.services.sourceFileProvider
|
||||
import org.jetbrains.kotlin.test.util.KtTestUtil
|
||||
import java.io.File
|
||||
|
||||
@@ -43,7 +40,7 @@ class JavaCompilerFacade(private val testServices: TestServices) {
|
||||
javaClassesOutputDirectory
|
||||
)
|
||||
|
||||
val javaFiles = module.javaFiles.map { testServices.sourceFileProvider.getRealFileForSourceFile(it) }
|
||||
val javaFiles = testServices.sourceFileProvider.getRealJavaFiles(module)
|
||||
val ignoreErrors = CodegenTestDirectives.IGNORE_JAVA_ERRORS in module.directives
|
||||
compileJavaFiles(module, configuration[JVMConfigurationKeys.JVM_TARGET] ?: JvmTarget.DEFAULT, javaFiles, finalJavacOptions, ignoreErrors)
|
||||
}
|
||||
|
||||
+4
-2
@@ -22,6 +22,7 @@ import org.jetbrains.kotlin.types.AbstractTypeChecker
|
||||
import org.jetbrains.kotlin.types.FlexibleTypeImpl
|
||||
import org.junit.jupiter.api.BeforeEach
|
||||
import org.junit.jupiter.api.TestInfo
|
||||
import kotlin.jvm.optionals.getOrNull
|
||||
|
||||
abstract class AbstractKotlinCompilerTest {
|
||||
companion object {
|
||||
@@ -68,11 +69,12 @@ abstract class AbstractKotlinCompilerTest {
|
||||
}
|
||||
|
||||
@BeforeEach
|
||||
@OptIn(ExperimentalStdlibApi::class)
|
||||
fun initTestInfo(testInfo: TestInfo) {
|
||||
initTestInfo(
|
||||
KotlinTestInfo(
|
||||
className = testInfo.testClass.orElseGet(null)?.name ?: "_undefined_",
|
||||
methodName = testInfo.testMethod.orElseGet(null)?.name ?: "_testUndefined_",
|
||||
className = testInfo.testClass.getOrNull()?.name ?: "_undefined_",
|
||||
methodName = testInfo.testMethod.getOrNull()?.name ?: "_testUndefined_",
|
||||
tags = testInfo.tags
|
||||
)
|
||||
)
|
||||
|
||||
-3
@@ -151,6 +151,3 @@ fun createCompilerConfiguration(module: TestModule, configurators: List<Abstract
|
||||
private operator fun <T : Any> CompilerConfiguration.set(key: CompilerConfigurationKey<T>, value: T) {
|
||||
put(key, value)
|
||||
}
|
||||
|
||||
val TestModule.javaFiles: List<TestFile>
|
||||
get() = files.filter { it.isJavaFile }
|
||||
|
||||
+3
@@ -29,6 +29,9 @@ class TemporaryDirectoryManagerImpl(testServices: TestServices) : TemporaryDirec
|
||||
KtTestUtil.tmpDirForTest(packageName + simplifiedClassName, "test$simplifiedMethodName")
|
||||
}
|
||||
|
||||
override val rootDir: File
|
||||
get() = rootTempDir
|
||||
|
||||
override fun getOrCreateTempDirectory(name: String): File {
|
||||
return cache.getOrPut(name) { KtTestUtil.tmpDir(rootTempDir, name) }
|
||||
}
|
||||
|
||||
@@ -25,20 +25,20 @@ import org.jetbrains.kotlin.incremental.*
|
||||
import org.jetbrains.kotlin.jvm.abi.*
|
||||
import org.jetbrains.kotlin.kapt.cli.test.AbstractArgumentParsingTest
|
||||
import org.jetbrains.kotlin.kapt.cli.test.AbstractKaptToolIntegrationTest
|
||||
import org.jetbrains.kotlin.kapt3.test.AbstractClassFileToSourceStubConverterTest
|
||||
import org.jetbrains.kotlin.kapt3.test.AbstractIrClassFileToSourceStubConverterTest
|
||||
import org.jetbrains.kotlin.kapt3.test.AbstractIrKotlinKaptContextTest
|
||||
import org.jetbrains.kotlin.kapt3.test.AbstractKotlinKaptContextTest
|
||||
import org.jetbrains.kotlin.kapt3.test.runners.AbstractClassFileToSourceStubConverterTest
|
||||
import org.jetbrains.kotlin.kapt3.test.runners.AbstractIrClassFileToSourceStubConverterTest
|
||||
import org.jetbrains.kotlin.kapt3.test.runners.AbstractIrKotlinKaptContextTest
|
||||
import org.jetbrains.kotlin.kapt3.test.runners.AbstractKotlinKaptContextTest
|
||||
import org.jetbrains.kotlin.lombok.*
|
||||
import org.jetbrains.kotlin.noarg.*
|
||||
import org.jetbrains.kotlin.parcelize.test.runners.*
|
||||
import org.jetbrains.kotlin.samWithReceiver.*
|
||||
import org.jetbrains.kotlin.test.TargetBackend
|
||||
import org.jetbrains.kotlinx.atomicfu.AbstractAtomicfuJsIrTest
|
||||
import org.jetbrains.kotlinx.atomicfu.AbstractAtomicfuJvmIrTest
|
||||
import org.jetbrains.kotlinx.serialization.AbstractSerializationIrBytecodeListingTest
|
||||
import org.jetbrains.kotlinx.serialization.AbstractSerializationPluginBytecodeListingTest
|
||||
import org.jetbrains.kotlinx.serialization.AbstractSerializationPluginDiagnosticTest
|
||||
import org.jetbrains.kotlinx.atomicfu.AbstractAtomicfuJsIrTest
|
||||
import org.jetbrains.kotlinx.atomicfu.AbstractAtomicfuJvmIrTest
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
System.setProperty("java.awt.headless", "true")
|
||||
@@ -194,24 +194,6 @@ fun main(args: Array<String>) {
|
||||
}
|
||||
}
|
||||
|
||||
testGroup("plugins/kapt3/kapt3-compiler/test", "plugins/kapt3/kapt3-compiler/testData") {
|
||||
testClass<AbstractClassFileToSourceStubConverterTest> {
|
||||
model("converter")
|
||||
}
|
||||
|
||||
testClass<AbstractKotlinKaptContextTest> {
|
||||
model("kotlinRunner")
|
||||
}
|
||||
|
||||
testClass<AbstractIrClassFileToSourceStubConverterTest> {
|
||||
model("converter", targetBackend = TargetBackend.JVM_IR)
|
||||
}
|
||||
|
||||
testClass<AbstractIrKotlinKaptContextTest> {
|
||||
model("kotlinRunner", targetBackend = TargetBackend.JVM_IR)
|
||||
}
|
||||
}
|
||||
|
||||
testGroup("plugins/sam-with-receiver/tests-gen", "plugins/sam-with-receiver/testData") {
|
||||
testClass<AbstractSamWithReceiverScriptTest> {
|
||||
model("script", extension = "kts")
|
||||
@@ -238,80 +220,80 @@ fun main(args: Array<String>) {
|
||||
model("codegen")
|
||||
}
|
||||
}
|
||||
/*
|
||||
testGroup("plugins/android-extensions/android-extensions-idea/tests", "plugins/android-extensions/android-extensions-idea/testData") {
|
||||
testClass<AbstractAndroidCompletionTest> {
|
||||
model("android/completion", recursive = false, extension = null)
|
||||
}
|
||||
/*
|
||||
testGroup("plugins/android-extensions/android-extensions-idea/tests", "plugins/android-extensions/android-extensions-idea/testData") {
|
||||
testClass<AbstractAndroidCompletionTest> {
|
||||
model("android/completion", recursive = false, extension = null)
|
||||
}
|
||||
|
||||
testClass<AbstractAndroidGotoTest> {
|
||||
model("android/goto", recursive = false, extension = null)
|
||||
}
|
||||
testClass<AbstractAndroidGotoTest> {
|
||||
model("android/goto", recursive = false, extension = null)
|
||||
}
|
||||
|
||||
testClass<AbstractAndroidRenameTest> {
|
||||
model("android/rename", recursive = false, extension = null)
|
||||
}
|
||||
testClass<AbstractAndroidRenameTest> {
|
||||
model("android/rename", recursive = false, extension = null)
|
||||
}
|
||||
|
||||
testClass<AbstractAndroidLayoutRenameTest> {
|
||||
model("android/renameLayout", recursive = false, extension = null)
|
||||
}
|
||||
testClass<AbstractAndroidLayoutRenameTest> {
|
||||
model("android/renameLayout", recursive = false, extension = null)
|
||||
}
|
||||
|
||||
testClass<AbstractAndroidFindUsagesTest> {
|
||||
model("android/findUsages", recursive = false, extension = null)
|
||||
}
|
||||
testClass<AbstractAndroidFindUsagesTest> {
|
||||
model("android/findUsages", recursive = false, extension = null)
|
||||
}
|
||||
|
||||
testClass<AbstractAndroidUsageHighlightingTest> {
|
||||
model("android/usageHighlighting", recursive = false, extension = null)
|
||||
}
|
||||
testClass<AbstractAndroidUsageHighlightingTest> {
|
||||
model("android/usageHighlighting", recursive = false, extension = null)
|
||||
}
|
||||
|
||||
testClass<AbstractAndroidExtractionTest> {
|
||||
model("android/extraction", recursive = false, extension = null)
|
||||
}
|
||||
testClass<AbstractAndroidExtractionTest> {
|
||||
model("android/extraction", recursive = false, extension = null)
|
||||
}
|
||||
|
||||
testClass<AbstractParcelCheckerTest> {
|
||||
model("android/parcel/checker", excludeParentDirs = true)
|
||||
}
|
||||
testClass<AbstractParcelCheckerTest> {
|
||||
model("android/parcel/checker", excludeParentDirs = true)
|
||||
}
|
||||
|
||||
testClass<AbstractParcelQuickFixTest> {
|
||||
model("android/parcel/quickfix", pattern = """^(\w+)\.((before\.Main\.\w+)|(test))$""", testMethod = "doTestWithExtraFile")
|
||||
}
|
||||
}
|
||||
testClass<AbstractParcelQuickFixTest> {
|
||||
model("android/parcel/quickfix", pattern = """^(\w+)\.((before\.Main\.\w+)|(test))$""", testMethod = "doTestWithExtraFile")
|
||||
}
|
||||
}
|
||||
|
||||
testGroup("idea/idea-android/tests", "idea/testData") {
|
||||
testClass<AbstractConfigureProjectTest> {
|
||||
model("configuration/android-gradle", pattern = """(\w+)_before\.gradle$""", testMethod = "doTestAndroidGradle")
|
||||
model("configuration/android-gsk", pattern = """(\w+)_before\.gradle.kts$""", testMethod = "doTestAndroidGradle")
|
||||
}
|
||||
testGroup("idea/idea-android/tests", "idea/testData") {
|
||||
testClass<AbstractConfigureProjectTest> {
|
||||
model("configuration/android-gradle", pattern = """(\w+)_before\.gradle$""", testMethod = "doTestAndroidGradle")
|
||||
model("configuration/android-gsk", pattern = """(\w+)_before\.gradle.kts$""", testMethod = "doTestAndroidGradle")
|
||||
}
|
||||
|
||||
testClass<AbstractAndroidIntentionTest> {
|
||||
model("android/intention", pattern = "^([\\w\\-_]+)\\.kt$")
|
||||
}
|
||||
testClass<AbstractAndroidIntentionTest> {
|
||||
model("android/intention", pattern = "^([\\w\\-_]+)\\.kt$")
|
||||
}
|
||||
|
||||
testClass<AbstractAndroidResourceIntentionTest> {
|
||||
model("android/resourceIntention", extension = "test", singleClass = true)
|
||||
}
|
||||
testClass<AbstractAndroidResourceIntentionTest> {
|
||||
model("android/resourceIntention", extension = "test", singleClass = true)
|
||||
}
|
||||
|
||||
testClass<AbstractAndroidQuickFixMultiFileTest> {
|
||||
model("android/quickfix", pattern = """^(\w+)\.((before\.Main\.\w+)|(test))$""", testMethod = "doTestWithExtraFile")
|
||||
}
|
||||
testClass<AbstractAndroidQuickFixMultiFileTest> {
|
||||
model("android/quickfix", pattern = """^(\w+)\.((before\.Main\.\w+)|(test))$""", testMethod = "doTestWithExtraFile")
|
||||
}
|
||||
|
||||
testClass<AbstractKotlinLintTest> {
|
||||
model("android/lint", excludeParentDirs = true)
|
||||
}
|
||||
testClass<AbstractKotlinLintTest> {
|
||||
model("android/lint", excludeParentDirs = true)
|
||||
}
|
||||
|
||||
testClass<AbstractAndroidLintQuickfixTest> {
|
||||
model("android/lintQuickfix", pattern = "^([\\w\\-_]+)\\.kt$")
|
||||
}
|
||||
testClass<AbstractAndroidLintQuickfixTest> {
|
||||
model("android/lintQuickfix", pattern = "^([\\w\\-_]+)\\.kt$")
|
||||
}
|
||||
|
||||
testClass<AbstractAndroidResourceFoldingTest> {
|
||||
model("android/folding")
|
||||
}
|
||||
testClass<AbstractAndroidResourceFoldingTest> {
|
||||
model("android/folding")
|
||||
}
|
||||
|
||||
testClass<AbstractAndroidGutterIconTest> {
|
||||
model("android/gutterIcon")
|
||||
}
|
||||
}
|
||||
*/
|
||||
testClass<AbstractAndroidGutterIconTest> {
|
||||
model("android/gutterIcon")
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
testGroup("plugins/fir-plugin-prototype/fir-plugin-ic-test/tests-gen", "plugins/fir-plugin-prototype/fir-plugin-ic-test/testData") {
|
||||
testClass<AbstractIncrementalFirJvmWithPluginCompilerRunnerTest> {
|
||||
@@ -464,5 +446,24 @@ fun main(args: Array<String>) {
|
||||
model("integration", recursive = false, extension = null)
|
||||
}
|
||||
}
|
||||
|
||||
testGroup("plugins/kapt3/kapt3-compiler/tests-gen", "plugins/kapt3/kapt3-compiler/testData") {
|
||||
testClass<AbstractKotlinKaptContextTest> {
|
||||
model("kotlinRunner")
|
||||
}
|
||||
|
||||
testClass<AbstractIrKotlinKaptContextTest> {
|
||||
model("kotlinRunner")
|
||||
}
|
||||
|
||||
testClass<AbstractClassFileToSourceStubConverterTest> {
|
||||
model("converter")
|
||||
}
|
||||
|
||||
testClass<AbstractIrClassFileToSourceStubConverterTest> {
|
||||
model("converter")
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,10 +25,13 @@ dependencies {
|
||||
testImplementation(intellijCore())
|
||||
testRuntimeOnly(intellijResources()) { isTransitive = false }
|
||||
|
||||
testApi(projectTests(":compiler:tests-common"))
|
||||
testApiJUnit5()
|
||||
testApi(projectTests(":compiler:tests-common-new"))
|
||||
testApi(projectTests(":compiler:test-infrastructure"))
|
||||
testApi(projectTests(":compiler:test-infrastructure-utils"))
|
||||
|
||||
testApi(project(":kotlin-annotation-processing-base"))
|
||||
testApi(projectTests(":kotlin-annotation-processing-base"))
|
||||
testApi(commonDependency("junit:junit"))
|
||||
testApi(project(":kotlin-annotation-processing-runtime"))
|
||||
|
||||
testCompileOnly(toolsJarApi())
|
||||
@@ -43,12 +46,16 @@ optInToExperimentalCompilerApi()
|
||||
|
||||
sourceSets {
|
||||
"main" { projectDefault() }
|
||||
"test" { projectDefault() }
|
||||
"test" {
|
||||
projectDefault()
|
||||
generatedTestDir()
|
||||
}
|
||||
}
|
||||
|
||||
testsJar {}
|
||||
|
||||
projectTest(parallel = true) {
|
||||
useJUnitPlatform()
|
||||
workingDir = rootDir
|
||||
dependsOn(":dist")
|
||||
}
|
||||
|
||||
@@ -293,10 +293,7 @@ abstract class AbstractKapt3Extension(
|
||||
logger.info { "Stubs compilation took $classFilesCompilationTime ms" }
|
||||
logger.info { "Compiled classes: " + compiledClasses.joinToString { it.name } }
|
||||
|
||||
return KaptContextForStubGeneration(
|
||||
options, false, logger, project, bindingContext,
|
||||
compiledClasses, origins, generationState
|
||||
)
|
||||
return KaptContextForStubGeneration(options, false, logger, compiledClasses, origins, generationState)
|
||||
}
|
||||
|
||||
private fun generateKotlinSourceStubs(kaptContext: KaptContextForStubGeneration) {
|
||||
|
||||
+4
-3
@@ -32,14 +32,15 @@ class KaptContextForStubGeneration(
|
||||
options: KaptOptions,
|
||||
withJdk: Boolean,
|
||||
logger: KaptLogger,
|
||||
val project: Project,
|
||||
val bindingContext: BindingContext,
|
||||
val compiledClasses: List<ClassNode>,
|
||||
val origins: Map<Any, JvmDeclarationOrigin>,
|
||||
val generationState: GenerationState
|
||||
) : KaptContext(options, withJdk, logger) {
|
||||
private val treeMaker = TreeMaker.instance(context)
|
||||
|
||||
val project: Project get() = generationState.project
|
||||
val bindingContext: BindingContext get() = generationState.bindingContext
|
||||
|
||||
override fun preregisterTreeMaker(context: Context) {
|
||||
KaptTreeMaker.preRegister(context, this)
|
||||
}
|
||||
@@ -49,4 +50,4 @@ class KaptContextForStubGeneration(
|
||||
generationState.destroy()
|
||||
super.close()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
-12
@@ -1,12 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.kapt3.test
|
||||
|
||||
import org.jetbrains.kotlin.test.TargetBackend
|
||||
|
||||
abstract class AbstractIrKotlinKapt3IntegrationTest : AbstractKotlinKapt3IntegrationTest() {
|
||||
override val backend = TargetBackend.JVM_IR
|
||||
}
|
||||
-18
@@ -1,18 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.kapt3.test
|
||||
|
||||
import org.jetbrains.kotlin.config.CompilerConfiguration
|
||||
import org.jetbrains.kotlin.config.JVMConfigurationKeys
|
||||
import org.jetbrains.kotlin.test.TargetBackend
|
||||
|
||||
open class AbstractIrClassFileToSourceStubConverterTest : AbstractClassFileToSourceStubConverterTest() {
|
||||
override val backend = TargetBackend.JVM_IR
|
||||
}
|
||||
|
||||
abstract class AbstractIrKotlinKaptContextTest : AbstractKotlinKaptContextTest() {
|
||||
override val backend = TargetBackend.JVM_IR
|
||||
}
|
||||
-255
@@ -1,255 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2016 JetBrains s.r.o.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.kapt3.test
|
||||
|
||||
import com.intellij.openapi.util.text.StringUtil
|
||||
import com.intellij.openapi.vfs.StandardFileSystems
|
||||
import com.intellij.psi.PsiManager
|
||||
import org.jetbrains.kotlin.base.kapt3.DetectMemoryLeaksMode
|
||||
import org.jetbrains.kotlin.base.kapt3.KaptOptions
|
||||
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity
|
||||
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSourceLocation
|
||||
import org.jetbrains.kotlin.cli.common.messages.MessageCollector
|
||||
import org.jetbrains.kotlin.codegen.ClassBuilderMode
|
||||
import org.jetbrains.kotlin.codegen.CodegenTestFiles
|
||||
import org.jetbrains.kotlin.codegen.GenerationUtils
|
||||
import org.jetbrains.kotlin.codegen.OriginCollectingClassBuilderFactory
|
||||
import org.jetbrains.kotlin.kapt3.AbstractKapt3Extension
|
||||
import org.jetbrains.kotlin.kapt3.KaptContextForStubGeneration
|
||||
import org.jetbrains.kotlin.kapt3.base.KaptContext
|
||||
import org.jetbrains.kotlin.kapt3.base.LoadedProcessors
|
||||
import org.jetbrains.kotlin.kapt3.base.incremental.DeclaredProcType
|
||||
import org.jetbrains.kotlin.kapt3.base.incremental.IncrementalProcessor
|
||||
import org.jetbrains.kotlin.kapt3.javac.KaptJavaFileObject
|
||||
import org.jetbrains.kotlin.kapt3.prettyPrint
|
||||
import org.jetbrains.kotlin.kapt3.stubs.ClassFileToSourceStubConverter
|
||||
import org.jetbrains.kotlin.kapt3.stubs.ClassFileToSourceStubConverter.KaptStub
|
||||
import org.jetbrains.kotlin.kapt3.util.MessageCollectorBackedKaptLogger
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.resolve.jvm.extensions.AnalysisHandlerExtension
|
||||
import org.jetbrains.kotlin.test.ConfigurationKind
|
||||
import org.jetbrains.kotlin.test.KotlinTestUtils
|
||||
import org.jetbrains.kotlin.test.util.trimTrailingWhitespacesAndAddNewlineAtEOF
|
||||
import org.jetbrains.kotlin.utils.PathUtil
|
||||
import java.io.File
|
||||
import java.nio.file.Files
|
||||
import javax.annotation.processing.Completion
|
||||
import javax.annotation.processing.ProcessingEnvironment
|
||||
import javax.annotation.processing.Processor
|
||||
import javax.annotation.processing.RoundEnvironment
|
||||
import javax.lang.model.SourceVersion
|
||||
import javax.lang.model.element.AnnotationMirror
|
||||
import javax.lang.model.element.Element
|
||||
import javax.lang.model.element.ExecutableElement
|
||||
import javax.lang.model.element.TypeElement
|
||||
|
||||
abstract class AbstractKotlinKapt3IntegrationTest : KotlinKapt3TestBase() {
|
||||
private companion object {
|
||||
val TEST_DATA_DIR = File("plugins/kapt3/kapt3-compiler/testData/kotlinRunner")
|
||||
}
|
||||
|
||||
private var _processors: List<Processor>? = null
|
||||
private val processors get() = _processors!!
|
||||
|
||||
private var mutableOptions: Map<String, String>? = null
|
||||
|
||||
override fun tearDown() {
|
||||
_processors = null
|
||||
mutableOptions = null
|
||||
super.tearDown()
|
||||
}
|
||||
|
||||
protected open fun test(
|
||||
name: String,
|
||||
vararg supportedAnnotations: String,
|
||||
options: Map<String, String> = emptyMap(),
|
||||
process: (Set<TypeElement>, RoundEnvironment, ProcessingEnvironment) -> Unit
|
||||
) {
|
||||
this.mutableOptions = options
|
||||
|
||||
val ktFileName = File(TEST_DATA_DIR, "$name.kt")
|
||||
var started = false
|
||||
val processor = object : Processor {
|
||||
lateinit var processingEnv: ProcessingEnvironment
|
||||
|
||||
override fun getSupportedOptions() = options.keys
|
||||
|
||||
override fun process(annotations: Set<TypeElement>, roundEnv: RoundEnvironment): Boolean {
|
||||
if (!roundEnv.processingOver()) {
|
||||
started = true
|
||||
process(annotations, roundEnv, processingEnv)
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
override fun init(env: ProcessingEnvironment) {
|
||||
processingEnv = env
|
||||
}
|
||||
|
||||
override fun getCompletions(
|
||||
element: Element?,
|
||||
annotation: AnnotationMirror?,
|
||||
member: ExecutableElement?,
|
||||
userText: String?
|
||||
): Iterable<Completion> {
|
||||
return emptyList()
|
||||
}
|
||||
|
||||
override fun getSupportedSourceVersion() = SourceVersion.RELEASE_6
|
||||
override fun getSupportedAnnotationTypes() = supportedAnnotations.toSet()
|
||||
}
|
||||
|
||||
_processors = listOf(processor)
|
||||
doTest(ktFileName.canonicalPath)
|
||||
|
||||
if (!started) {
|
||||
fail("Annotation processor was not started")
|
||||
}
|
||||
}
|
||||
|
||||
override fun loadMultiFiles(files: List<TestFile>) {
|
||||
val project = myEnvironment.project
|
||||
val psiManager = PsiManager.getInstance(project)
|
||||
|
||||
val tmpDir = tmpDir("kaptTest")
|
||||
|
||||
val ktFiles = ArrayList<KtFile>(files.size)
|
||||
for (file in files.sorted()) {
|
||||
if (file.name.endsWith(".kt")) {
|
||||
val tmpKtFile = File(tmpDir, file.name).apply { writeText(file.content) }
|
||||
val virtualFile = StandardFileSystems.local().findFileByPath(tmpKtFile.path) ?: error("Can't find ${file.name}")
|
||||
ktFiles.add(psiManager.findFile(virtualFile) as? KtFile ?: error("Can't load ${file.name}"))
|
||||
}
|
||||
}
|
||||
|
||||
myFiles = CodegenTestFiles.create(ktFiles)
|
||||
}
|
||||
|
||||
override fun doMultiFileTest(wholeFile: File, files: List<TestFile>) {
|
||||
val txtFile = File(wholeFile.parentFile, wholeFile.nameWithoutExtension + ".it.txt")
|
||||
|
||||
val javaSources = listOfNotNull(writeJavaFiles(files))
|
||||
createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.ALL, *javaSources.toTypedArray())
|
||||
val project = myEnvironment.project
|
||||
|
||||
val options = KaptOptions.Builder().apply {
|
||||
projectBaseDir = project.basePath?.let(::File)
|
||||
compileClasspath.addAll(PathUtil.getJdkClassesRootsFromCurrentJre() + PathUtil.kotlinPathsForIdeaPlugin.stdlibPath)
|
||||
javaSourceRoots.addAll(javaSources)
|
||||
|
||||
sourcesOutputDir = Files.createTempDirectory("kaptRunner").toFile()
|
||||
classesOutputDir = sourcesOutputDir
|
||||
stubsOutputDir = Files.createTempDirectory("kaptStubs").toFile()
|
||||
incrementalDataOutputDir = Files.createTempDirectory("kaptIncrementalData").toFile()
|
||||
|
||||
mutableOptions?.let { processingOptions.putAll(it) }
|
||||
flags.addAll(kaptFlagsToAdd)
|
||||
flags.removeAll(kaptFlagsToRemove.toSet())
|
||||
detectMemoryLeaks = DetectMemoryLeaksMode.NONE
|
||||
}.build()
|
||||
|
||||
val kapt3Extension = Kapt3ExtensionForTests(options, processors)
|
||||
AnalysisHandlerExtension.registerExtension(project, kapt3Extension)
|
||||
|
||||
try {
|
||||
loadMultiFiles(files)
|
||||
|
||||
val classBuilderFactory = OriginCollectingClassBuilderFactory(ClassBuilderMode.KAPT3)
|
||||
GenerationUtils.compileFiles(myFiles.psiFiles, myEnvironment, classBuilderFactory).factory
|
||||
|
||||
val actualRaw = kapt3Extension.savedStubs ?: error("Stubs were not saved")
|
||||
val actual = StringUtil.convertLineSeparators(actualRaw.trim { it <= ' ' })
|
||||
.trimTrailingWhitespacesAndAddNewlineAtEOF()
|
||||
.let { AbstractClassFileToSourceStubConverterTest.removeMetadataAnnotationContents(it) }
|
||||
|
||||
checkTxtAccordingToBackend(txtFile, actual)
|
||||
} finally {
|
||||
options.sourcesOutputDir.deleteRecursively()
|
||||
options.incrementalDataOutputDir?.deleteRecursively()
|
||||
}
|
||||
}
|
||||
|
||||
protected inner class Kapt3ExtensionForTests(
|
||||
options: KaptOptions,
|
||||
private val processors: List<Processor>,
|
||||
val messageCollector: LoggingMessageCollector = LoggingMessageCollector()
|
||||
) : AbstractKapt3Extension(
|
||||
options, MessageCollectorBackedKaptLogger(
|
||||
flags = options,
|
||||
messageCollector = messageCollector
|
||||
), compilerConfiguration = myEnvironment.configuration
|
||||
) {
|
||||
internal var savedStubs: String? = null
|
||||
internal var savedBindings: Map<String, KaptJavaFileObject>? = null
|
||||
|
||||
override fun loadProcessors() = LoadedProcessors(
|
||||
processors.map { IncrementalProcessor(it, DeclaredProcType.NON_INCREMENTAL, logger) },
|
||||
Kapt3ExtensionForTests::class.java.classLoader
|
||||
)
|
||||
|
||||
override fun saveStubs(kaptContext: KaptContext, stubs: List<KaptStub>) {
|
||||
if (this.savedStubs != null) {
|
||||
error("Stubs are already saved")
|
||||
}
|
||||
|
||||
this.savedStubs = stubs
|
||||
.map { it.file.prettyPrint(kaptContext.context) }
|
||||
.sorted()
|
||||
.joinToString(AbstractKotlinKapt3Test.FILE_SEPARATOR)
|
||||
|
||||
super.saveStubs(kaptContext, stubs)
|
||||
}
|
||||
|
||||
override fun saveIncrementalData(
|
||||
kaptContext: KaptContextForStubGeneration,
|
||||
messageCollector: MessageCollector,
|
||||
converter: ClassFileToSourceStubConverter
|
||||
) {
|
||||
if (this.savedBindings != null) {
|
||||
error("Bindings are already saved")
|
||||
}
|
||||
|
||||
this.savedBindings = converter.bindings
|
||||
|
||||
super.saveIncrementalData(kaptContext, messageCollector, converter)
|
||||
}
|
||||
}
|
||||
|
||||
class LoggingMessageCollector : MessageCollector {
|
||||
private val _messages = mutableListOf<Message>()
|
||||
val messages: List<Message>
|
||||
get() = _messages
|
||||
|
||||
override fun clear() {
|
||||
_messages.clear()
|
||||
}
|
||||
|
||||
override fun report(severity: CompilerMessageSeverity, message: String, location: CompilerMessageSourceLocation?) {
|
||||
_messages.add(Message(severity, message, location))
|
||||
}
|
||||
|
||||
override fun hasErrors() = _messages.any {
|
||||
it.severity.isError
|
||||
}
|
||||
|
||||
data class Message(
|
||||
val severity: CompilerMessageSeverity,
|
||||
val message: String,
|
||||
val location: CompilerMessageSourceLocation?
|
||||
)
|
||||
}
|
||||
}
|
||||
-358
@@ -1,358 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2016 JetBrains s.r.o.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.kapt3.test
|
||||
|
||||
import com.intellij.openapi.util.io.FileUtil
|
||||
import com.intellij.openapi.util.text.StringUtil
|
||||
import com.intellij.openapi.vfs.StandardFileSystems
|
||||
import com.intellij.psi.PsiManager
|
||||
import com.sun.tools.javac.comp.CompileStates
|
||||
import com.sun.tools.javac.tree.JCTree.JCCompilationUnit
|
||||
import com.sun.tools.javac.util.JCDiagnostic
|
||||
import com.sun.tools.javac.util.Log
|
||||
import junit.framework.ComparisonFailure
|
||||
import org.jetbrains.kotlin.base.kapt3.DetectMemoryLeaksMode
|
||||
import org.jetbrains.kotlin.base.kapt3.KaptFlag
|
||||
import org.jetbrains.kotlin.base.kapt3.KaptOptions
|
||||
import org.jetbrains.kotlin.checkers.utils.CheckerTestUtil
|
||||
import org.jetbrains.kotlin.cli.common.messages.MessageRenderer
|
||||
import org.jetbrains.kotlin.cli.common.messages.PrintingMessageCollector
|
||||
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment
|
||||
import org.jetbrains.kotlin.cli.jvm.config.JvmClasspathRoot
|
||||
import org.jetbrains.kotlin.codegen.ClassBuilderMode
|
||||
import org.jetbrains.kotlin.codegen.CodegenTestFiles
|
||||
import org.jetbrains.kotlin.codegen.GenerationUtils
|
||||
import org.jetbrains.kotlin.codegen.OriginCollectingClassBuilderFactory
|
||||
import org.jetbrains.kotlin.extensions.StorageComponentContainerContributor
|
||||
import org.jetbrains.kotlin.kapt.base.test.JavaKaptContextTest
|
||||
import org.jetbrains.kotlin.kapt3.Kapt3ComponentRegistrar.KaptComponentContributor
|
||||
import org.jetbrains.kotlin.kapt3.KaptContextForStubGeneration
|
||||
import org.jetbrains.kotlin.kapt3.base.KaptContext
|
||||
import org.jetbrains.kotlin.kapt3.base.doAnnotationProcessing
|
||||
import org.jetbrains.kotlin.kapt3.base.javac.KaptJavaLogBase
|
||||
import org.jetbrains.kotlin.kapt3.base.parseJavaFiles
|
||||
import org.jetbrains.kotlin.kapt3.javac.KaptJavaFileObject
|
||||
import org.jetbrains.kotlin.kapt3.prettyPrint
|
||||
import org.jetbrains.kotlin.kapt3.stubs.ClassFileToSourceStubConverter
|
||||
import org.jetbrains.kotlin.kapt3.util.MessageCollectorBackedKaptLogger
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.resolve.jvm.extensions.AnalysisHandlerExtension
|
||||
import org.jetbrains.kotlin.resolve.jvm.extensions.PartialAnalysisHandlerExtension
|
||||
import org.jetbrains.kotlin.test.ConfigurationKind
|
||||
import org.jetbrains.kotlin.test.KotlinTestUtils
|
||||
import org.jetbrains.kotlin.test.TargetBackend
|
||||
import org.jetbrains.kotlin.test.TestJdkKind
|
||||
import org.jetbrains.kotlin.test.util.trimTrailingWhitespacesAndAddNewlineAtEOF
|
||||
import org.jetbrains.kotlin.utils.PathUtil
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstance
|
||||
import java.io.ByteArrayOutputStream
|
||||
import java.io.File
|
||||
import java.io.PrintStream
|
||||
import java.util.*
|
||||
import com.sun.tools.javac.util.List as JavacList
|
||||
|
||||
abstract class AbstractKotlinKapt3Test : KotlinKapt3TestBase() {
|
||||
companion object {
|
||||
const val FILE_SEPARATOR = "\n\n////////////////////\n\n"
|
||||
val ERR_BYTE_STREAM = ByteArrayOutputStream()
|
||||
private val ERR_PRINT_STREAM = PrintStream(ERR_BYTE_STREAM)
|
||||
|
||||
val messageCollector = PrintingMessageCollector(ERR_PRINT_STREAM, MessageRenderer.PLAIN_FULL_PATHS, false)
|
||||
}
|
||||
|
||||
override fun tearDown() {
|
||||
ERR_BYTE_STREAM.reset()
|
||||
super.tearDown()
|
||||
}
|
||||
|
||||
private fun createTempJavaFile(prefix: String, text: String): File =
|
||||
FileUtil.createTempFile(prefix, ".java", false).apply {
|
||||
writeText(text)
|
||||
}
|
||||
|
||||
override fun loadMultiFiles(files: List<TestFile>) {
|
||||
val project = myEnvironment.project
|
||||
val psiManager = PsiManager.getInstance(project)
|
||||
|
||||
val tmpDir = tmpDir("kaptTest")
|
||||
|
||||
val ktFiles = ArrayList<KtFile>(files.size)
|
||||
for (file in files.sorted()) {
|
||||
if (file.name.endsWith(".kt")) {
|
||||
// `rangesToDiagnosticNames` parameter is not-null only for diagnostic tests, it's using for lazy diagnostics
|
||||
val content = CheckerTestUtil.parseDiagnosedRanges(file.content, ArrayList(0), null)
|
||||
val tmpKtFile = File(tmpDir, file.name).apply { writeText(content) }
|
||||
val virtualFile = StandardFileSystems.local().findFileByPath(tmpKtFile.path) ?: error("Can't find ${file.name}")
|
||||
ktFiles.add(psiManager.findFile(virtualFile) as? KtFile ?: error("Can't load ${file.name}"))
|
||||
}
|
||||
}
|
||||
|
||||
myFiles = CodegenTestFiles.create(ktFiles)
|
||||
}
|
||||
|
||||
override fun doMultiFileTest(wholeFile: File, files: List<TestFile>) {
|
||||
val javaSourceRoots = listOfNotNull(writeJavaFiles(files))
|
||||
createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.ALL, files, TestJdkKind.MOCK_JDK, *javaSourceRoots.toTypedArray())
|
||||
|
||||
addAnnotationProcessingRuntimeLibrary(myEnvironment)
|
||||
|
||||
val project = myEnvironment.project
|
||||
|
||||
val javacOptions = wholeFile.getOptionValues("JAVAC_OPTION").associate { opt ->
|
||||
val (key, value) = opt.split('=').map { it.trim() }.also { assert(it.size == 2) }
|
||||
key to value
|
||||
}
|
||||
|
||||
val options = KaptOptions.Builder().apply {
|
||||
projectBaseDir = project.basePath?.let { File(it) }
|
||||
compileClasspath.addAll(PathUtil.getJdkClassesRootsFromCurrentJre() + PathUtil.kotlinPathsForIdeaPlugin.stdlibPath)
|
||||
|
||||
sourcesOutputDir = tmpDir("kaptRunner")
|
||||
classesOutputDir = sourcesOutputDir
|
||||
stubsOutputDir = sourcesOutputDir
|
||||
incrementalDataOutputDir = sourcesOutputDir
|
||||
|
||||
this.javacOptions.putAll(javacOptions)
|
||||
flags.addAll(kaptFlagsToAdd)
|
||||
flags.removeAll(kaptFlagsToRemove.toSet())
|
||||
|
||||
detectMemoryLeaks = DetectMemoryLeaksMode.NONE
|
||||
}.build()
|
||||
|
||||
val analysisExtension = object : PartialAnalysisHandlerExtension() {
|
||||
override val analyzeDefaultParameterValues: Boolean
|
||||
get() = options[KaptFlag.DUMP_DEFAULT_PARAMETER_VALUES]
|
||||
}
|
||||
|
||||
AnalysisHandlerExtension.registerExtension(project, analysisExtension)
|
||||
StorageComponentContainerContributor.registerExtension(project, KaptComponentContributor(analysisExtension))
|
||||
|
||||
loadMultiFiles(files)
|
||||
|
||||
val txtFile = File(wholeFile.parentFile, wholeFile.nameWithoutExtension + ".txt")
|
||||
val classBuilderFactory = OriginCollectingClassBuilderFactory(ClassBuilderMode.KAPT3)
|
||||
val generationState = GenerationUtils.compileFiles(myFiles.psiFiles, myEnvironment, classBuilderFactory)
|
||||
|
||||
val logger = MessageCollectorBackedKaptLogger(isVerbose = true, isInfoAsWarnings = false, messageCollector = messageCollector)
|
||||
|
||||
var kaptContext: KaptContext? = null
|
||||
|
||||
try {
|
||||
kaptContext = KaptContextForStubGeneration(
|
||||
options, true, logger,
|
||||
generationState.project, generationState.bindingContext, classBuilderFactory.compiledClasses,
|
||||
classBuilderFactory.origins, generationState
|
||||
)
|
||||
|
||||
val javaFiles = files
|
||||
.filter { it.name.lowercase().endsWith(".java") }
|
||||
.map { createTempJavaFile(it.name.substringBeforeLast('.'), it.content) }
|
||||
|
||||
check(kaptContext, javaFiles, txtFile, wholeFile)
|
||||
} finally {
|
||||
kaptContext?.close()
|
||||
}
|
||||
}
|
||||
|
||||
protected fun convert(
|
||||
kaptContext: KaptContextForStubGeneration,
|
||||
javaFiles: List<File>,
|
||||
generateNonExistentClass: Boolean
|
||||
): JavacList<JCCompilationUnit> {
|
||||
val converter = ClassFileToSourceStubConverter(kaptContext, generateNonExistentClass)
|
||||
|
||||
val kaptStubs = converter.convert()
|
||||
val convertedFiles = kaptStubs.map { stub ->
|
||||
val sourceFile = createTempJavaFile("stub", stub.file.prettyPrint(kaptContext.context))
|
||||
stub.writeMetadataIfNeeded(forSource = sourceFile)
|
||||
sourceFile
|
||||
}
|
||||
|
||||
val allJavaFiles = javaFiles + convertedFiles
|
||||
|
||||
// A workaround needed for Javac to parse files correctly even if errors were already reported
|
||||
// If nerrors > 0, "parseFiles()" returns the empty list
|
||||
val oldErrorCount = kaptContext.compiler.log.nerrors
|
||||
kaptContext.compiler.log.nerrors = 0
|
||||
|
||||
try {
|
||||
val parsedJavaFiles = kaptContext.parseJavaFiles(allJavaFiles)
|
||||
|
||||
for (tree in parsedJavaFiles) {
|
||||
val actualFile = File(tree.sourceFile.toUri())
|
||||
|
||||
// By default, JavaFileObject.getName() returns the absolute path to the file.
|
||||
// In our test, such a path will be temporary, so the comparison against it will lead to flaky tests.
|
||||
tree.sourcefile = KaptJavaFileObject(tree, tree.defs.firstIsInstance(), actualFile)
|
||||
}
|
||||
|
||||
return parsedJavaFiles
|
||||
} finally {
|
||||
kaptContext.compiler.log.nerrors = oldErrorCount
|
||||
}
|
||||
}
|
||||
|
||||
protected fun File.getRawOptionValues(name: String) = this.useLines { lines ->
|
||||
lines.filter { it.startsWith("// $name") }.toList()
|
||||
}
|
||||
|
||||
private fun File.getOptionValues(name: String) = getRawOptionValues(name).map { it.drop("// ".length + name.length).trim() }
|
||||
|
||||
protected abstract fun check(
|
||||
kaptContext: KaptContextForStubGeneration,
|
||||
javaFiles: List<File>,
|
||||
txtFile: File,
|
||||
wholeFile: File
|
||||
)
|
||||
}
|
||||
|
||||
open class AbstractClassFileToSourceStubConverterTest : AbstractKotlinKapt3Test(), CustomJdkTestLauncher {
|
||||
companion object {
|
||||
private const val KOTLIN_METADATA_GROUP = "[a-z0-9]+ = (\\{.+?\\}|[0-9]+)"
|
||||
private val KOTLIN_METADATA_REGEX = "@kotlin\\.Metadata\\(($KOTLIN_METADATA_GROUP)(, $KOTLIN_METADATA_GROUP)*\\)".toRegex()
|
||||
|
||||
private const val EXPECTED_ERROR = "EXPECTED_ERROR"
|
||||
|
||||
internal fun removeMetadataAnnotationContents(s: String): String {
|
||||
return s.replace(KOTLIN_METADATA_REGEX, "@kotlin.Metadata()")
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun main(args: Array<String>) {
|
||||
if (args.size != 2) error("2 argument expected, ${args.size} passed")
|
||||
|
||||
val test = when (args[0]) {
|
||||
TargetBackend.JVM.name -> AbstractClassFileToSourceStubConverterTest()
|
||||
TargetBackend.JVM_IR.name -> AbstractIrClassFileToSourceStubConverterTest()
|
||||
else -> throw UnsupportedOperationException(args[0])
|
||||
}
|
||||
|
||||
try {
|
||||
test.setUp()
|
||||
test.doTest(args[1])
|
||||
} finally {
|
||||
test.tearDown()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// This is to suppress "AssertionFailedError: No tests found"
|
||||
fun testSuppressWarning() {}
|
||||
|
||||
override fun doTest(filePath: String) {
|
||||
val testFile = File(filePath)
|
||||
|
||||
kaptFlagsToAdd.add(KaptFlag.MAP_DIAGNOSTIC_LOCATIONS)
|
||||
|
||||
addOrRemoveFlag(KaptFlag.CORRECT_ERROR_TYPES, testFile)
|
||||
if (isFlagEnabled("STRICT_MODE", testFile)) {
|
||||
kaptFlagsToAdd.add(KaptFlag.STRICT)
|
||||
}
|
||||
addOrRemoveFlag(KaptFlag.STRIP_METADATA, testFile)
|
||||
addOrRemoveFlag(KaptFlag.KEEP_KDOC_COMMENTS_IN_STUBS, testFile)
|
||||
|
||||
super.doTest(filePath)
|
||||
doTestWithJdk11(AbstractClassFileToSourceStubConverterTest::class.java, backend.name, filePath)
|
||||
}
|
||||
|
||||
override fun check(kaptContext: KaptContextForStubGeneration, javaFiles: List<File>, txtFile: File, wholeFile: File) {
|
||||
val generateNonExistentClass = isFlagEnabled("NON_EXISTENT_CLASS", wholeFile)
|
||||
val validate = !isFlagEnabled("NO_VALIDATION", wholeFile)
|
||||
val expectedErrors = wholeFile.getRawOptionValues(EXPECTED_ERROR).sorted()
|
||||
|
||||
val convertedFiles = convert(kaptContext, javaFiles, generateNonExistentClass)
|
||||
|
||||
kaptContext.javaLog.interceptorData.files = convertedFiles.associateBy { it.sourceFile }
|
||||
if (validate) kaptContext.compiler.enterTrees(convertedFiles)
|
||||
|
||||
val actualRaw = convertedFiles
|
||||
.sortedBy { it.sourceFile.name }
|
||||
.joinToString(FILE_SEPARATOR) { it.prettyPrint(kaptContext.context) }
|
||||
|
||||
val actual = StringUtil.convertLineSeparators(actualRaw.trim { it <= ' ' })
|
||||
.trimTrailingWhitespacesAndAddNewlineAtEOF()
|
||||
.let { removeMetadataAnnotationContents(it) }
|
||||
|
||||
if (kaptContext.compiler.shouldStop(CompileStates.CompileState.ENTER)) {
|
||||
val log = Log.instance(kaptContext.context) as KaptJavaLogBase
|
||||
|
||||
val actualErrors = log.reportedDiagnostics
|
||||
.filter { it.type == JCDiagnostic.DiagnosticType.ERROR }
|
||||
.map {
|
||||
// Unfortunately, we can't use the file name as it can contain temporary prefix
|
||||
val name = it.source?.name?.substringAfterLast("/") ?: ""
|
||||
val kind = when (name.substringAfterLast(".").lowercase()) {
|
||||
"kt" -> "kotlin"
|
||||
"java" -> "java"
|
||||
else -> "other"
|
||||
}
|
||||
|
||||
val javaLocation = "($kind:${it.lineNumber}:${it.columnNumber}) "
|
||||
javaLocation + it.getMessage(Locale.US).lines().first()
|
||||
}
|
||||
.map { "// $EXPECTED_ERROR$it" }
|
||||
.sorted()
|
||||
|
||||
log.flush()
|
||||
|
||||
val lineSeparator = System.getProperty("line.separator")
|
||||
val actualErrorsStr = actualErrors.joinToString(lineSeparator)
|
||||
|
||||
if (expectedErrors.isEmpty()) {
|
||||
error("There were errors during analysis:\n$actualErrorsStr\n\nStubs:\n\n$actual")
|
||||
} else {
|
||||
val expectedErrorsStr = expectedErrors.joinToString(lineSeparator)
|
||||
if (expectedErrorsStr != actualErrorsStr) {
|
||||
System.err.println(ERR_BYTE_STREAM.toString("UTF8"))
|
||||
throw ComparisonFailure("Expected error matching failed", expectedErrorsStr, actualErrorsStr)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
checkTxtAccordingToBackend(txtFile, actual)
|
||||
}
|
||||
}
|
||||
|
||||
abstract class AbstractKotlinKaptContextTest : AbstractKotlinKapt3Test() {
|
||||
override fun doTest(filePath: String) {
|
||||
kaptFlagsToAdd.add(KaptFlag.CORRECT_ERROR_TYPES)
|
||||
kaptFlagsToAdd.add(KaptFlag.STRICT)
|
||||
kaptFlagsToAdd.add(KaptFlag.MAP_DIAGNOSTIC_LOCATIONS)
|
||||
super.doTest(filePath)
|
||||
}
|
||||
|
||||
override fun check(kaptContext: KaptContextForStubGeneration, javaFiles: List<File>, txtFile: File, wholeFile: File) {
|
||||
val compilationUnits = convert(kaptContext, javaFiles, generateNonExistentClass = false)
|
||||
kaptContext.doAnnotationProcessing(
|
||||
emptyList(),
|
||||
listOf(JavaKaptContextTest.simpleProcessor()),
|
||||
additionalSources = compilationUnits
|
||||
)
|
||||
|
||||
val stubJavaFiles = kaptContext.options.sourcesOutputDir.walkTopDown().filter { it.isFile && it.extension == "java" }
|
||||
val actualRaw = stubJavaFiles.sortedBy { it.name }.joinToString(FILE_SEPARATOR) { it.name + ":\n\n" + it.readText() }
|
||||
val actual = StringUtil.convertLineSeparators(actualRaw.trim { it <= ' ' }).trimTrailingWhitespacesAndAddNewlineAtEOF()
|
||||
KotlinTestUtils.assertEqualsToFile(txtFile, actual)
|
||||
}
|
||||
}
|
||||
|
||||
private fun addAnnotationProcessingRuntimeLibrary(environment: KotlinCoreEnvironment) {
|
||||
environment.apply {
|
||||
val runtimeLibrary = File(PathUtil.kotlinPathsForCompiler.libPath, "kotlin-annotation-processing-runtime.jar")
|
||||
updateClasspath(listOf(JvmClasspathRoot(runtimeLibrary)))
|
||||
}
|
||||
}
|
||||
-36
@@ -1,36 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.kapt3.test
|
||||
|
||||
import org.junit.Test
|
||||
import javax.annotation.processing.ProcessingEnvironment
|
||||
import javax.annotation.processing.RoundEnvironment
|
||||
import javax.lang.model.element.TypeElement
|
||||
|
||||
class IrKotlinKapt3IntegrationTests : AbstractIrKotlinKapt3IntegrationTest(), CustomJdkTestLauncher {
|
||||
override fun test(
|
||||
name: String,
|
||||
vararg supportedAnnotations: String,
|
||||
options: Map<String, String>,
|
||||
process: (Set<TypeElement>, RoundEnvironment, ProcessingEnvironment) -> Unit
|
||||
) {
|
||||
super.test(name, *supportedAnnotations, options = options, process = process)
|
||||
|
||||
doTestWithJdk11(
|
||||
SingleJUnitTestRunner::class.java,
|
||||
IrKotlinKapt3IntegrationTests::class.java.name + "#test" + getTestName(false)
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testSimple() = test("Simple", "test.MyAnnotation") { set, roundEnv, _ ->
|
||||
assertEquals(1, set.size)
|
||||
val annotatedElements = roundEnv.getElementsAnnotatedWith(set.single())
|
||||
assertEquals(1, annotatedElements.size)
|
||||
assertEquals("myMethod", annotatedElements.single().simpleName.toString())
|
||||
}
|
||||
|
||||
}
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.kapt3.test
|
||||
|
||||
import org.jetbrains.kotlin.codegen.ClassBuilderMode
|
||||
import org.jetbrains.kotlin.codegen.GenerationUtils
|
||||
import org.jetbrains.kotlin.codegen.OriginCollectingClassBuilderFactory
|
||||
import org.jetbrains.kotlin.kapt3.KaptContextForStubGeneration
|
||||
import org.jetbrains.kotlin.kapt3.util.MessageCollectorBackedKaptLogger
|
||||
import org.jetbrains.kotlin.test.model.*
|
||||
import org.jetbrains.kotlin.test.services.*
|
||||
|
||||
class JvmCompilerWithKaptFacade(private val testServices: TestServices) :
|
||||
AbstractTestFacade<ResultingArtifact.Source, KaptContextBinaryArtifact>() {
|
||||
override val inputKind: TestArtifactKind<ResultingArtifact.Source>
|
||||
get() = SourcesKind
|
||||
override val outputKind: TestArtifactKind<KaptContextBinaryArtifact>
|
||||
get() = KaptContextBinaryArtifact.Kind
|
||||
|
||||
override val additionalServices: List<ServiceRegistrationData>
|
||||
get() = listOf(service(::KaptMessageCollectorProvider))
|
||||
|
||||
override fun transform(module: TestModule, inputArtifact: ResultingArtifact.Source): KaptContextBinaryArtifact {
|
||||
val configurationProvider = testServices.compilerConfigurationProvider
|
||||
val project = configurationProvider.getProject(module)
|
||||
val ktFiles = testServices.sourceFileProvider.getKtFilesForSourceFiles(module.files, project, findViaVfs = true).values.toList()
|
||||
val classBuilderFactory = OriginCollectingClassBuilderFactory(ClassBuilderMode.KAPT3)
|
||||
val generationState = GenerationUtils.compileFiles(
|
||||
ktFiles,
|
||||
configurationProvider.getCompilerConfiguration(module),
|
||||
classBuilderFactory,
|
||||
configurationProvider.getPackagePartProviderFactory(module)
|
||||
)
|
||||
val logger = MessageCollectorBackedKaptLogger(
|
||||
isVerbose = true,
|
||||
isInfoAsWarnings = false,
|
||||
messageCollector = testServices.messageCollectorProvider.getCollector(module)
|
||||
)
|
||||
val kaptContext = KaptContextForStubGeneration(
|
||||
testServices.kaptOptionsProvider[module],
|
||||
withJdk = true,
|
||||
logger,
|
||||
classBuilderFactory.compiledClasses,
|
||||
classBuilderFactory.origins,
|
||||
generationState
|
||||
)
|
||||
return KaptContextBinaryArtifact(kaptContext)
|
||||
}
|
||||
|
||||
override fun shouldRunAnalysis(module: TestModule): Boolean {
|
||||
return true // TODO
|
||||
}
|
||||
}
|
||||
|
||||
class KaptContextBinaryArtifact(val kaptContext: KaptContextForStubGeneration) : ResultingArtifact.Binary<KaptContextBinaryArtifact>() {
|
||||
object Kind : BinaryKind<KaptContextBinaryArtifact>("KaptArtifact")
|
||||
|
||||
override val kind: BinaryKind<KaptContextBinaryArtifact>
|
||||
get() = Kind
|
||||
}
|
||||
|
||||
+85
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.kapt3.test
|
||||
|
||||
import com.intellij.openapi.project.Project
|
||||
import org.jetbrains.kotlin.base.kapt3.DetectMemoryLeaksMode
|
||||
import org.jetbrains.kotlin.base.kapt3.KaptFlag
|
||||
import org.jetbrains.kotlin.cli.jvm.config.addJvmClasspathRoot
|
||||
import org.jetbrains.kotlin.config.CompilerConfiguration
|
||||
import org.jetbrains.kotlin.config.JVMConfigurationKeys
|
||||
import org.jetbrains.kotlin.extensions.StorageComponentContainerContributor
|
||||
import org.jetbrains.kotlin.kapt3.Kapt3ComponentRegistrar
|
||||
import org.jetbrains.kotlin.resolve.jvm.extensions.AnalysisHandlerExtension
|
||||
import org.jetbrains.kotlin.resolve.jvm.extensions.PartialAnalysisHandlerExtension
|
||||
import org.jetbrains.kotlin.test.directives.CodegenTestDirectives
|
||||
import org.jetbrains.kotlin.test.directives.model.DirectivesContainer
|
||||
import org.jetbrains.kotlin.test.model.TestModule
|
||||
import org.jetbrains.kotlin.test.services.*
|
||||
import org.jetbrains.kotlin.utils.PathUtil
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.runIf
|
||||
import java.io.File
|
||||
|
||||
class KaptEnvironmentConfigurator(
|
||||
testServices: TestServices,
|
||||
private val processorOptions: Map<String, String> = emptyMap()
|
||||
) : EnvironmentConfigurator(testServices) {
|
||||
companion object {
|
||||
const val KAPT_RUNNER_DIRECTORY_NAME = "kaptRunner"
|
||||
}
|
||||
|
||||
override val directiveContainers: List<DirectivesContainer> = listOf(
|
||||
CodegenTestDirectives,
|
||||
KaptTestDirectives
|
||||
)
|
||||
|
||||
override val additionalServices: List<ServiceRegistrationData> = listOf(service(::KaptOptionsProvider))
|
||||
|
||||
override fun configureCompilerConfiguration(configuration: CompilerConfiguration, module: TestModule) {
|
||||
testServices.kaptOptionsProvider.registerKaptOptions(module) {
|
||||
val temporaryDirectoryManager = testServices.temporaryDirectoryManager
|
||||
projectBaseDir = temporaryDirectoryManager.rootDir
|
||||
compileClasspath.addAll(PathUtil.getJdkClassesRootsFromCurrentJre() + PathUtil.kotlinPathsForIdeaPlugin.stdlibPath)
|
||||
|
||||
sourcesOutputDir = temporaryDirectoryManager.getOrCreateTempDirectory(KAPT_RUNNER_DIRECTORY_NAME)
|
||||
classesOutputDir = sourcesOutputDir
|
||||
stubsOutputDir = sourcesOutputDir
|
||||
incrementalDataOutputDir = sourcesOutputDir
|
||||
|
||||
val javacOptions = module.directives[CodegenTestDirectives.JAVAC_OPTIONS].associate { opt ->
|
||||
val (key, value) = opt.split('=').map { it.trim() }.also { assert(it.size == 2) }
|
||||
key to value
|
||||
}
|
||||
|
||||
this.javacOptions.putAll(javacOptions)
|
||||
val kaptFlagsToAdd = KaptTestDirectives.flagDirectives.mapNotNull {
|
||||
runIf(it in module.directives) {
|
||||
KaptFlag.valueOf(it.name)
|
||||
}
|
||||
}
|
||||
flags.addAll(kaptFlagsToAdd)
|
||||
flags.removeAll(module.directives[KaptTestDirectives.DISABLED_FLAGS])
|
||||
|
||||
processingOptions.putAll(processorOptions)
|
||||
detectMemoryLeaks = DetectMemoryLeaksMode.NONE
|
||||
}
|
||||
|
||||
val runtimeLibrary = File(PathUtil.kotlinPathsForCompiler.libPath, "kotlin-annotation-processing-runtime.jar")
|
||||
configuration.addJvmClasspathRoot(runtimeLibrary)
|
||||
configuration.put(JVMConfigurationKeys.DO_NOT_CLEAR_BINDING_CONTEXT, true)
|
||||
}
|
||||
}
|
||||
|
||||
class KaptRegularExtensionForTestConfigurator(testServices: TestServices) : EnvironmentConfigurator(testServices) {
|
||||
override fun legacyRegisterCompilerExtensions(project: Project, module: TestModule, configuration: CompilerConfiguration) {
|
||||
val analysisExtension = object : PartialAnalysisHandlerExtension() {
|
||||
override val analyzeDefaultParameterValues: Boolean
|
||||
get() = testServices.kaptOptionsProvider[module][KaptFlag.DUMP_DEFAULT_PARAMETER_VALUES]
|
||||
}
|
||||
AnalysisHandlerExtension.registerExtension(project, analysisExtension)
|
||||
StorageComponentContainerContributor.registerExtension(project, Kapt3ComponentRegistrar.KaptComponentContributor(analysisExtension))
|
||||
}
|
||||
}
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.kapt3.test
|
||||
|
||||
import org.jetbrains.kotlin.cli.common.messages.MessageRenderer
|
||||
import org.jetbrains.kotlin.cli.common.messages.PrintingMessageCollector
|
||||
import org.jetbrains.kotlin.test.model.TestModule
|
||||
import org.jetbrains.kotlin.test.services.TestService
|
||||
import org.jetbrains.kotlin.test.services.TestServices
|
||||
import java.io.ByteArrayOutputStream
|
||||
import java.io.PrintStream
|
||||
|
||||
class KaptMessageCollectorProvider(private val testServices: TestServices) : TestService {
|
||||
private class StreamAndCollector {
|
||||
val outputStream = ByteArrayOutputStream()
|
||||
val messageCollector = PrintingMessageCollector(PrintStream(outputStream), MessageRenderer.PLAIN_FULL_PATHS, false)
|
||||
}
|
||||
|
||||
private val cache: MutableMap<TestModule, StreamAndCollector> = mutableMapOf()
|
||||
|
||||
private fun getStreamAndCollector(module: TestModule): StreamAndCollector {
|
||||
return cache.getOrPut(module) { StreamAndCollector() }
|
||||
}
|
||||
|
||||
fun getCollector(module: TestModule): PrintingMessageCollector {
|
||||
return getStreamAndCollector(module).messageCollector
|
||||
}
|
||||
|
||||
fun getErrorStream(module: TestModule): ByteArrayOutputStream {
|
||||
return getStreamAndCollector(module).outputStream
|
||||
}
|
||||
}
|
||||
|
||||
val TestServices.messageCollectorProvider: KaptMessageCollectorProvider by TestServices.testServiceAccessor()
|
||||
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.kapt3.test
|
||||
|
||||
import org.jetbrains.kotlin.base.kapt3.KaptOptions
|
||||
import org.jetbrains.kotlin.test.model.TestModule
|
||||
import org.jetbrains.kotlin.test.services.TestService
|
||||
import org.jetbrains.kotlin.test.services.TestServices
|
||||
import org.jetbrains.kotlin.test.services.assertions
|
||||
|
||||
class KaptOptionsProvider(private val testServices: TestServices) : TestService {
|
||||
private val cache: MutableMap<TestModule, KaptOptions> = mutableMapOf()
|
||||
|
||||
fun registerKaptOptions(module: TestModule, builder: KaptOptions.Builder.() -> Unit) {
|
||||
if (module in cache) {
|
||||
testServices.assertions.fail { "KaptOptions for module $module already registered" }
|
||||
}
|
||||
val options = KaptOptions.Builder().apply(builder).build()
|
||||
cache[module] = options
|
||||
}
|
||||
|
||||
operator fun get(module: TestModule): KaptOptions {
|
||||
return cache.getValue(module)
|
||||
}
|
||||
}
|
||||
|
||||
val TestServices.kaptOptionsProvider: KaptOptionsProvider by TestServices.testServiceAccessor()
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.kapt3.test
|
||||
|
||||
import org.jetbrains.kotlin.base.kapt3.KaptFlag
|
||||
import org.jetbrains.kotlin.test.directives.model.SimpleDirectivesContainer
|
||||
|
||||
object KaptTestDirectives : SimpleDirectivesContainer() {
|
||||
val SHOW_PROCESSOR_STATS by directive("Enables SHOW_PROCESSOR_STATS flag")
|
||||
val VERBOSE by directive("Enables VERBOSE flag")
|
||||
val INFO_AS_WARNINGS by directive("Enables INFO_AS_WARNINGS flag")
|
||||
val USE_LIGHT_ANALYSIS by directive("Enables USE_LIGHT_ANALYSIS flag")
|
||||
val CORRECT_ERROR_TYPES by directive("Enables CORRECT_ERROR_TYPES flag")
|
||||
val DUMP_DEFAULT_PARAMETER_VALUES by directive("Enables DUMP_DEFAULT_PARAMETER_VALUES flag")
|
||||
val MAP_DIAGNOSTIC_LOCATIONS by directive("Enables MAP_DIAGNOSTIC_LOCATIONS flag")
|
||||
val STRICT by directive("Enables STRICT flag")
|
||||
val INCLUDE_COMPILE_CLASSPATH by directive("Enables INCLUDE_COMPILE_CLASSPATH flag")
|
||||
val INCREMENTAL_APT by directive("Enables INCREMENTAL_APT flag")
|
||||
val STRIP_METADATA by directive("Enables STRIP_METADATA flag")
|
||||
val KEEP_KDOC_COMMENTS_IN_STUBS by directive("Enables KEEP_KDOC_COMMENTS_IN_STUBS flag")
|
||||
val USE_JVM_IR by directive("Enables USE_JVM_IR flag")
|
||||
|
||||
val DISABLED_FLAGS by enumDirective<KaptFlag>("Disables listed flags")
|
||||
|
||||
val NON_EXISTENT_CLASS by directive("TODO")
|
||||
val NO_VALIDATION by directive("TODO")
|
||||
val EXPECTED_ERROR by stringDirective("TODO()", multiLine = true)
|
||||
|
||||
val flagDirectives = listOf(
|
||||
SHOW_PROCESSOR_STATS, VERBOSE, INFO_AS_WARNINGS, USE_LIGHT_ANALYSIS, CORRECT_ERROR_TYPES,
|
||||
DUMP_DEFAULT_PARAMETER_VALUES, MAP_DIAGNOSTIC_LOCATIONS, STRICT, INCLUDE_COMPILE_CLASSPATH,
|
||||
INCREMENTAL_APT, STRIP_METADATA, KEEP_KDOC_COMMENTS_IN_STUBS, USE_JVM_IR
|
||||
)
|
||||
}
|
||||
-90
@@ -1,90 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.kapt3.test
|
||||
|
||||
import org.jetbrains.kotlin.base.kapt3.KaptFlag
|
||||
import org.jetbrains.kotlin.codegen.CodegenTestCase
|
||||
import org.jetbrains.kotlin.config.CompilerConfiguration
|
||||
import org.jetbrains.kotlin.config.JVMConfigurationKeys
|
||||
import org.jetbrains.kotlin.test.KotlinTestUtils
|
||||
import org.jetbrains.kotlin.test.util.KtTestUtil
|
||||
import java.io.File
|
||||
|
||||
abstract class KotlinKapt3TestBase : CodegenTestCase() {
|
||||
val kaptFlagsToAdd = mutableListOf<KaptFlag>()
|
||||
val kaptFlagsToRemove = mutableListOf<KaptFlag>()
|
||||
private val directoriesToCleanup = mutableListOf<File>()
|
||||
|
||||
override fun setUp() {
|
||||
super.setUp()
|
||||
kaptFlagsToAdd.clear()
|
||||
kaptFlagsToRemove.clear()
|
||||
}
|
||||
|
||||
override fun tearDown() {
|
||||
directoriesToCleanup.forEach(File::deleteRecursively)
|
||||
super.tearDown()
|
||||
}
|
||||
|
||||
protected fun isFlagEnabled(flagName: String, testFile: File): Boolean {
|
||||
val stringToCheck = "// $flagName"
|
||||
return testFile.useLines { lines -> lines.any { it.trim() == stringToCheck } }
|
||||
}
|
||||
|
||||
private fun isFlagDisabled(flagName: String, testFile: File): Boolean {
|
||||
val stringToCheck = "// !$flagName"
|
||||
return testFile.useLines { lines -> lines.any { it.trim() == stringToCheck } }
|
||||
}
|
||||
|
||||
protected fun addOrRemoveFlag(flag: KaptFlag, testFile: File) {
|
||||
if (isFlagEnabled(flag.name, testFile)) {
|
||||
kaptFlagsToAdd.add(flag)
|
||||
} else if (isFlagDisabled(flag.name, testFile)) {
|
||||
kaptFlagsToRemove.add(flag)
|
||||
}
|
||||
}
|
||||
|
||||
protected fun tmpDir(name: String): File {
|
||||
return KtTestUtil.tmpDir(name).also(directoriesToCleanup::add)
|
||||
}
|
||||
|
||||
protected fun checkTxtAccordingToBackend(txtFile: File, actual: String) {
|
||||
val irTxtFile = File(txtFile.parentFile, txtFile.nameWithoutExtension + "_ir.txt")
|
||||
val expectedFile =
|
||||
if (backend.isIR && irTxtFile.exists()) irTxtFile
|
||||
else txtFile
|
||||
KotlinTestUtils.assertEqualsToFile(expectedFile, actual)
|
||||
|
||||
if (backend.isIR && txtFile.exists() && irTxtFile.exists() && txtFile.readText() == irTxtFile.readText()) {
|
||||
fail("JVM and JVM_IR golden files are identical. Remove $irTxtFile.")
|
||||
}
|
||||
}
|
||||
|
||||
override fun updateConfiguration(configuration: CompilerConfiguration) {
|
||||
super.updateConfiguration(configuration)
|
||||
|
||||
if (backend.isIR) {
|
||||
configuration.put(JVMConfigurationKeys.IR, true)
|
||||
configuration.put(JVMConfigurationKeys.DO_NOT_CLEAR_BINDING_CONTEXT, true)
|
||||
}
|
||||
}
|
||||
|
||||
override fun doTest(filePath: String) {
|
||||
val testFile = File(filePath)
|
||||
|
||||
kaptFlagsToAdd.add(KaptFlag.MAP_DIAGNOSTIC_LOCATIONS)
|
||||
|
||||
addOrRemoveFlag(KaptFlag.CORRECT_ERROR_TYPES, testFile)
|
||||
addOrRemoveFlag(KaptFlag.STRICT, testFile)
|
||||
addOrRemoveFlag(KaptFlag.DUMP_DEFAULT_PARAMETER_VALUES, testFile)
|
||||
|
||||
if (backend.isIR) {
|
||||
kaptFlagsToAdd.add(KaptFlag.USE_JVM_IR)
|
||||
}
|
||||
|
||||
super.doTest(filePath)
|
||||
}
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.kapt3.test.handlers
|
||||
|
||||
import org.jetbrains.kotlin.kapt3.test.KaptContextBinaryArtifact
|
||||
import org.jetbrains.kotlin.test.model.AnalysisHandler
|
||||
import org.jetbrains.kotlin.test.model.TestArtifactKind
|
||||
import org.jetbrains.kotlin.test.services.TestServices
|
||||
|
||||
abstract class AbstractKaptHandler(testServices: TestServices) : AnalysisHandler<KaptContextBinaryArtifact>(
|
||||
testServices,
|
||||
failureDisablesNextSteps = true,
|
||||
doNotRunIfThereWerePreviousFailures = true
|
||||
) {
|
||||
override val artifactKind: TestArtifactKind<KaptContextBinaryArtifact>
|
||||
get() = KaptContextBinaryArtifact.Kind
|
||||
}
|
||||
+70
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.kapt3.test.handlers
|
||||
|
||||
import com.sun.tools.javac.tree.JCTree
|
||||
import com.sun.tools.javac.util.List
|
||||
import org.jetbrains.kotlin.kapt3.KaptContextForStubGeneration
|
||||
import org.jetbrains.kotlin.kapt3.base.parseJavaFiles
|
||||
import org.jetbrains.kotlin.kapt3.javac.KaptJavaFileObject
|
||||
import org.jetbrains.kotlin.kapt3.prettyPrint
|
||||
import org.jetbrains.kotlin.kapt3.stubs.ClassFileToSourceStubConverter
|
||||
import org.jetbrains.kotlin.test.model.TestModule
|
||||
import org.jetbrains.kotlin.test.services.TestServices
|
||||
import org.jetbrains.kotlin.test.services.getRealJavaFiles
|
||||
import org.jetbrains.kotlin.test.services.sourceFileProvider
|
||||
import org.jetbrains.kotlin.test.utils.withExtension
|
||||
import org.jetbrains.kotlin.test.utils.withSuffixAndExtension
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstance
|
||||
import java.io.File
|
||||
|
||||
abstract class BaseKaptHandler(testServices: TestServices) : AbstractKaptHandler(testServices) {
|
||||
protected fun convert(
|
||||
module: TestModule,
|
||||
kaptContext: KaptContextForStubGeneration,
|
||||
generateNonExistentClass: Boolean
|
||||
): List<JCTree.JCCompilationUnit> {
|
||||
val javaFiles = testServices.sourceFileProvider.getRealJavaFiles(module)
|
||||
val converter = ClassFileToSourceStubConverter(kaptContext, generateNonExistentClass)
|
||||
|
||||
val kaptStubs = converter.convert()
|
||||
val convertedFiles = kaptStubs.mapIndexed { index, stub ->
|
||||
val sourceFile = createTempJavaFile("stub$index.java", stub.file.prettyPrint(kaptContext.context))
|
||||
stub.writeMetadataIfNeeded(forSource = sourceFile)
|
||||
sourceFile
|
||||
}
|
||||
|
||||
val allJavaFiles = javaFiles + convertedFiles
|
||||
|
||||
// A workaround needed for Javac to parse files correctly even if errors were already reported
|
||||
// If nerrors > 0, "parseFiles()" returns the empty list
|
||||
val oldErrorCount = kaptContext.compiler.log.nerrors
|
||||
kaptContext.compiler.log.nerrors = 0
|
||||
|
||||
try {
|
||||
val parsedJavaFiles = kaptContext.parseJavaFiles(allJavaFiles)
|
||||
|
||||
for (tree in parsedJavaFiles) {
|
||||
val actualFile = File(tree.sourceFile.toUri())
|
||||
|
||||
// By default, JavaFileObject.getName() returns the absolute path to the file.
|
||||
// In our test, such a path will be temporary, so the comparison against it will lead to flaky tests.
|
||||
tree.sourcefile = KaptJavaFileObject(tree, tree.defs.firstIsInstance(), actualFile)
|
||||
}
|
||||
|
||||
return parsedJavaFiles
|
||||
} finally {
|
||||
kaptContext.compiler.log.nerrors = oldErrorCount
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private fun createTempJavaFile(name: String, text: String): File {
|
||||
return testServices.sourceFileProvider.javaSourceDirectory.resolve(name).also {
|
||||
it.writeText(text)
|
||||
}
|
||||
}
|
||||
}
|
||||
+89
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.kapt3.test.handlers
|
||||
|
||||
import com.intellij.openapi.util.text.StringUtil
|
||||
import com.sun.tools.javac.comp.CompileStates
|
||||
import com.sun.tools.javac.util.JCDiagnostic
|
||||
import com.sun.tools.javac.util.Log
|
||||
import org.jetbrains.kotlin.kapt3.base.javac.KaptJavaLogBase
|
||||
import org.jetbrains.kotlin.kapt3.prettyPrint
|
||||
import org.jetbrains.kotlin.kapt3.test.KaptContextBinaryArtifact
|
||||
import org.jetbrains.kotlin.kapt3.test.old.AbstractClassFileToSourceStubConverterTest
|
||||
import org.jetbrains.kotlin.kapt3.test.old.AbstractKotlinKapt3Test
|
||||
import org.jetbrains.kotlin.kapt3.test.KaptTestDirectives.EXPECTED_ERROR
|
||||
import org.jetbrains.kotlin.kapt3.test.KaptTestDirectives.NON_EXISTENT_CLASS
|
||||
import org.jetbrains.kotlin.kapt3.test.KaptTestDirectives.NO_VALIDATION
|
||||
import org.jetbrains.kotlin.test.model.TestModule
|
||||
import org.jetbrains.kotlin.test.services.TestServices
|
||||
import org.jetbrains.kotlin.test.util.trimTrailingWhitespacesAndAddNewlineAtEOF
|
||||
import java.util.*
|
||||
|
||||
class ClassFileToSourceKaptStubHandler(testServices: TestServices) : BaseKaptHandler(testServices) {
|
||||
override fun processModule(module: TestModule, info: KaptContextBinaryArtifact) {
|
||||
val generateNonExistentClass = NON_EXISTENT_CLASS in module.directives
|
||||
val validate = NO_VALIDATION !in module.directives
|
||||
val expectedErrors = module.directives[EXPECTED_ERROR].sorted()
|
||||
|
||||
val kaptContext = info.kaptContext
|
||||
|
||||
val convertedFiles = convert(module, kaptContext, generateNonExistentClass)
|
||||
|
||||
kaptContext.javaLog.interceptorData.files = convertedFiles.associateBy { it.sourceFile }
|
||||
if (validate) kaptContext.compiler.enterTrees(convertedFiles)
|
||||
|
||||
val actualRaw = convertedFiles
|
||||
.sortedBy { it.sourceFile.name }
|
||||
.joinToString(AbstractKotlinKapt3Test.FILE_SEPARATOR) { it.prettyPrint(kaptContext.context) }
|
||||
|
||||
val actual = StringUtil.convertLineSeparators(actualRaw.trim { it <= ' ' })
|
||||
.trimTrailingWhitespacesAndAddNewlineAtEOF()
|
||||
.let { AbstractClassFileToSourceStubConverterTest.removeMetadataAnnotationContents(it) }
|
||||
|
||||
if (kaptContext.compiler.shouldStop(CompileStates.CompileState.ENTER)) {
|
||||
val log = Log.instance(kaptContext.context) as KaptJavaLogBase
|
||||
|
||||
val actualErrors = log.reportedDiagnostics
|
||||
.filter { it.type == JCDiagnostic.DiagnosticType.ERROR }
|
||||
.map {
|
||||
// Unfortunately, we can't use the file name as it can contain temporary prefix
|
||||
val name = it.source?.name?.substringAfterLast("/") ?: ""
|
||||
val kind = when (name.substringAfterLast(".").lowercase()) {
|
||||
"kt" -> "kotlin"
|
||||
"java" -> "java"
|
||||
else -> "other"
|
||||
}
|
||||
|
||||
val javaLocation = "($kind:${it.lineNumber}:${it.columnNumber}) "
|
||||
javaLocation + it.getMessage(Locale.US).lines().first()
|
||||
}
|
||||
.sorted()
|
||||
|
||||
log.flush()
|
||||
|
||||
val lineSeparator = System.getProperty("line.separator")
|
||||
val actualErrorsStr = actualErrors.joinToString(lineSeparator) { it.toDirectiveView() }
|
||||
|
||||
if (expectedErrors.isEmpty()) {
|
||||
assertions.fail { "There were errors during analysis:\n$actualErrorsStr\n\nStubs:\n\n$actual" }
|
||||
} else {
|
||||
val expectedErrorsStr = expectedErrors.joinToString(lineSeparator) { it.toDirectiveView() }
|
||||
if (expectedErrorsStr != actualErrorsStr) {
|
||||
assertions.assertEquals(expectedErrorsStr, actualErrorsStr) {
|
||||
System.err.println(AbstractKotlinKapt3Test.ERR_BYTE_STREAM.toString("UTF8"))
|
||||
"Expected error matching failed"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
assertions.checkTxtAccordingToBackend(module, actual)
|
||||
}
|
||||
|
||||
private fun String.toDirectiveView(): String = "// ${EXPECTED_ERROR.name}: $this"
|
||||
|
||||
override fun processAfterAllModules(someAssertionWasFailed: Boolean) {}
|
||||
}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.kapt3.test.handlers
|
||||
|
||||
import com.intellij.openapi.util.text.StringUtil
|
||||
import org.jetbrains.kotlin.kapt.base.test.JavaKaptContextTest
|
||||
import org.jetbrains.kotlin.kapt3.base.doAnnotationProcessing
|
||||
import org.jetbrains.kotlin.kapt3.test.KaptContextBinaryArtifact
|
||||
import org.jetbrains.kotlin.kapt3.test.handlers.ClassFileToSourceKaptStubHandler.Companion.FILE_SEPARATOR
|
||||
import org.jetbrains.kotlin.test.model.TestModule
|
||||
import org.jetbrains.kotlin.test.services.TestServices
|
||||
import org.jetbrains.kotlin.test.util.trimTrailingWhitespacesAndAddNewlineAtEOF
|
||||
import org.jetbrains.kotlin.test.utils.withExtension
|
||||
|
||||
class KaptContextHandler(testServices: TestServices) : BaseKaptHandler(testServices) {
|
||||
override fun processModule(module: TestModule, info: KaptContextBinaryArtifact) {
|
||||
val kaptContext = info.kaptContext
|
||||
val compilationUnits = convert(module, kaptContext, generateNonExistentClass = false)
|
||||
kaptContext.doAnnotationProcessing(
|
||||
emptyList(),
|
||||
listOf(JavaKaptContextTest.simpleProcessor()),
|
||||
additionalSources = compilationUnits
|
||||
)
|
||||
|
||||
val stubJavaFiles = kaptContext.options.sourcesOutputDir.walkTopDown().filter { it.isFile && it.extension == "java" }
|
||||
val actualRaw = stubJavaFiles.sortedBy { it.name }.joinToString(FILE_SEPARATOR) { it.name + ":\n\n" + it.readText() }
|
||||
val actual = StringUtil.convertLineSeparators(actualRaw.trim { it <= ' ' }).trimTrailingWhitespacesAndAddNewlineAtEOF()
|
||||
val expectedFile = module.files.first().originalFile.withExtension(".txt")
|
||||
assertions.assertEqualsToFile(expectedFile, actual)
|
||||
}
|
||||
|
||||
override fun processAfterAllModules(someAssertionWasFailed: Boolean) {}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.kapt3.test.handlers
|
||||
|
||||
import org.jetbrains.kotlin.test.Assertions
|
||||
import org.jetbrains.kotlin.test.model.TestModule
|
||||
import org.jetbrains.kotlin.test.utils.withExtension
|
||||
import org.jetbrains.kotlin.test.utils.withSuffixAndExtension
|
||||
|
||||
fun Assertions.checkTxtAccordingToBackend(module: TestModule, actual: String, fileSuffix: String = "") {
|
||||
val testDataFile = module.files.first().originalFile
|
||||
val txtFile = testDataFile.withExtension("$fileSuffix.txt")
|
||||
val irTxtFile = testDataFile.withSuffixAndExtension("${fileSuffix}_ir", ".txt")
|
||||
val isIr = module.targetBackend?.isIR == true
|
||||
val expectedFile = if (isIr && irTxtFile.exists()) {
|
||||
irTxtFile
|
||||
} else {
|
||||
txtFile
|
||||
}
|
||||
assertEqualsToFile(expectedFile, actual)
|
||||
|
||||
if (isIr && txtFile.exists() && irTxtFile.exists() && txtFile.readText() == irTxtFile.readText()) {
|
||||
fail { "JVM and JVM_IR golden files are identical. Remove $irTxtFile." }
|
||||
}
|
||||
}
|
||||
|
||||
private const val KOTLIN_METADATA_GROUP = "[a-z0-9]+ = (\\{.+?\\}|[0-9]+)"
|
||||
private val KOTLIN_METADATA_REGEX = "@kotlin\\.Metadata\\(($KOTLIN_METADATA_GROUP)(, $KOTLIN_METADATA_GROUP)*\\)".toRegex()
|
||||
|
||||
fun removeMetadataAnnotationContents(s: String): String {
|
||||
return s.replace(KOTLIN_METADATA_REGEX, "@kotlin.Metadata()")
|
||||
}
|
||||
+57
-73
@@ -1,27 +1,17 @@
|
||||
/*
|
||||
* Copyright 2010-2016 JetBrains s.r.o.
|
||||
*
|
||||
* 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.
|
||||
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.kapt3.test
|
||||
package org.jetbrains.kotlin.kapt3.test.integration
|
||||
|
||||
import org.jetbrains.kotlin.kapt3.javac.KaptJavaFileObject
|
||||
import org.jetbrains.kotlin.resolve.jvm.extensions.AnalysisHandlerExtension
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstance
|
||||
import org.junit.Test
|
||||
import org.junit.runner.JUnitCore
|
||||
import org.junit.runner.Request
|
||||
import org.jetbrains.kotlin.test.services.JUnit5Assertions.assertEquals
|
||||
import org.jetbrains.kotlin.test.services.JUnit5Assertions.assertTrue
|
||||
import org.jetbrains.kotlin.test.TargetBackend
|
||||
import org.jetbrains.kotlin.test.services.JUnit5Assertions.assertNotNull
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.junit.jupiter.api.TestInfo
|
||||
import java.io.File
|
||||
import javax.annotation.processing.ProcessingEnvironment
|
||||
import javax.annotation.processing.RoundEnvironment
|
||||
@@ -31,25 +21,34 @@ import javax.lang.model.element.TypeElement
|
||||
import javax.lang.model.element.VariableElement
|
||||
import javax.lang.model.util.ElementFilter
|
||||
import javax.tools.Diagnostic
|
||||
import kotlin.system.exitProcess
|
||||
|
||||
class KotlinKapt3IntegrationTests : AbstractKotlinKapt3IntegrationTest(), CustomJdkTestLauncher {
|
||||
override fun test(
|
||||
class KotlinKapt3IntegrationTest(testInfo: TestInfo) : AbstractKotlinKapt3IntegrationTestBase(testInfo, TargetBackend.JVM)
|
||||
|
||||
abstract class AbstractKotlinKapt3IntegrationTestBase(private val testInfo: TestInfo, private val targetBackend: TargetBackend) {
|
||||
private companion object {
|
||||
val TEST_DATA_DIR = File("plugins/kapt3/kapt3-compiler/testData/kotlinRunner")
|
||||
}
|
||||
|
||||
private fun test(
|
||||
name: String,
|
||||
vararg supportedAnnotations: String,
|
||||
options: Map<String, String>,
|
||||
process: (Set<TypeElement>, RoundEnvironment, ProcessingEnvironment) -> Unit
|
||||
options: Map<String, String> = emptyMap(),
|
||||
process: (Set<TypeElement>, RoundEnvironment, ProcessingEnvironment, Kapt3ExtensionForTests) -> Unit
|
||||
) {
|
||||
super.test(name, *supportedAnnotations, options = options, process = process)
|
||||
|
||||
doTestWithJdk11(
|
||||
SingleJUnitTestRunner::class.java,
|
||||
KotlinKapt3IntegrationTests::class.java.name + "#test" + getTestName(false)
|
||||
)
|
||||
val file = File(TEST_DATA_DIR, "$name.kt")
|
||||
AbstractKotlinKapt3IntegrationTestRunner(
|
||||
targetBackend,
|
||||
options,
|
||||
supportedAnnotations.toList(),
|
||||
process
|
||||
).apply {
|
||||
initTestInfo(testInfo)
|
||||
runTest(file.absolutePath)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testSimple() = test("Simple", "test.MyAnnotation") { set, roundEnv, _ ->
|
||||
fun testSimple() = test("Simple", "test.MyAnnotation") { set, roundEnv, _, _ ->
|
||||
assertEquals(1, set.size)
|
||||
val annotatedElements = roundEnv.getElementsAnnotatedWith(set.single())
|
||||
assertEquals(1, annotatedElements.size)
|
||||
@@ -57,17 +56,17 @@ class KotlinKapt3IntegrationTests : AbstractKotlinKapt3IntegrationTest(), Custom
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testComments() = test("Simple", "test.MyAnnotation") { _, _, env ->
|
||||
fun testComments() = test("Simple", "test.MyAnnotation") { _, _, env, _ ->
|
||||
fun commentOf(className: String) = env.elementUtils.getDocComment(env.elementUtils.getTypeElement(className))
|
||||
|
||||
assert(commentOf("test.Simple") == " KDoc comment.\n")
|
||||
assert(commentOf("test.EnumClass") == null) // simple comment - not saved
|
||||
assert(commentOf("test.MyAnnotation") == null) // multiline comment - not saved
|
||||
assertTrue(commentOf("test.Simple") == " KDoc comment.\n")
|
||||
assertTrue(commentOf("test.EnumClass") == null) // simple comment - not saved
|
||||
assertTrue(commentOf("test.MyAnnotation") == null) // multiline comment - not saved
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testParameterNames() {
|
||||
test("DefaultParameterValues", "test.Anno") { set, roundEnv, _ ->
|
||||
test("DefaultParameterValues", "test.Anno") { set, roundEnv, _, _ ->
|
||||
val user = roundEnv.getElementsAnnotatedWith(set.single()).single() as TypeElement
|
||||
val nameField = user.enclosedElements.filterIsInstance<VariableElement>().single()
|
||||
assertEquals("John", nameField.constantValue)
|
||||
@@ -76,32 +75,32 @@ class KotlinKapt3IntegrationTests : AbstractKotlinKapt3IntegrationTest(), Custom
|
||||
|
||||
@Test
|
||||
fun testSimpleStubsAndIncrementalData() = bindingsTest("Simple") { stubsOutputDir, incrementalDataOutputDir, bindings ->
|
||||
assert(File(stubsOutputDir, "error/NonExistentClass.java").exists())
|
||||
assert(File(stubsOutputDir, "test/Simple.java").exists())
|
||||
assert(File(stubsOutputDir, "test/EnumClass.java").exists())
|
||||
assertTrue(File(stubsOutputDir, "error/NonExistentClass.java").exists())
|
||||
assertTrue(File(stubsOutputDir, "test/Simple.java").exists())
|
||||
assertTrue(File(stubsOutputDir, "test/EnumClass.java").exists())
|
||||
|
||||
assert(File(incrementalDataOutputDir, "test/Simple.class").exists())
|
||||
assert(File(incrementalDataOutputDir, "test/EnumClass.class").exists())
|
||||
assertTrue(File(incrementalDataOutputDir, "test/Simple.class").exists())
|
||||
assertTrue(File(incrementalDataOutputDir, "test/EnumClass.class").exists())
|
||||
|
||||
assert(bindings.any { it.key == "test/Simple" && it.value.name == "test/Simple.java" })
|
||||
assert(bindings.any { it.key == "test/EnumClass" && it.value.name == "test/EnumClass.java" })
|
||||
assertTrue(bindings.any { it.key == "test/Simple" && it.value.name == "test/Simple.java" })
|
||||
assertTrue(bindings.any { it.key == "test/EnumClass" && it.value.name == "test/EnumClass.java" })
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testStubsAndIncrementalDataForNestedClasses() {
|
||||
bindingsTest("NestedClasses") { stubsOutputDir, incrementalDataOutputDir, bindings ->
|
||||
assert(File(stubsOutputDir, "test/Simple.java").exists())
|
||||
assert(!File(stubsOutputDir, "test/Simple/InnerClass.java").exists())
|
||||
assertTrue(File(stubsOutputDir, "test/Simple.java").exists())
|
||||
assertTrue(!File(stubsOutputDir, "test/Simple/InnerClass.java").exists())
|
||||
|
||||
assert(File(incrementalDataOutputDir, "test/Simple.class").exists())
|
||||
assert(File(incrementalDataOutputDir, "test/Simple\$Companion.class").exists())
|
||||
assert(File(incrementalDataOutputDir, "test/Simple\$InnerClass.class").exists())
|
||||
assert(File(incrementalDataOutputDir, "test/Simple\$NestedClass.class").exists())
|
||||
assert(File(incrementalDataOutputDir, "test/Simple\$NestedClass\$NestedNestedClass.class").exists())
|
||||
assertTrue(File(incrementalDataOutputDir, "test/Simple.class").exists())
|
||||
assertTrue(File(incrementalDataOutputDir, "test/Simple\$Companion.class").exists())
|
||||
assertTrue(File(incrementalDataOutputDir, "test/Simple\$InnerClass.class").exists())
|
||||
assertTrue(File(incrementalDataOutputDir, "test/Simple\$NestedClass.class").exists())
|
||||
assertTrue(File(incrementalDataOutputDir, "test/Simple\$NestedClass\$NestedNestedClass.class").exists())
|
||||
|
||||
assert(bindings.any { it.key == "test/Simple" && it.value.name == "test/Simple.java" })
|
||||
assert(bindings.none { it.key.contains("Companion") })
|
||||
assert(bindings.none { it.key.contains("InnerClass") })
|
||||
assertTrue(bindings.any { it.key == "test/Simple" && it.value.name == "test/Simple.java" })
|
||||
assertTrue(bindings.none { it.key.contains("Companion") })
|
||||
assertTrue(bindings.none { it.key.contains("InnerClass") })
|
||||
}
|
||||
}
|
||||
|
||||
@@ -134,7 +133,7 @@ class KotlinKapt3IntegrationTests : AbstractKotlinKapt3IntegrationTest(), Custom
|
||||
private fun List<LoggingMessageCollector.Message>.assertContainsDiagnostic(
|
||||
message: String
|
||||
) {
|
||||
assert(
|
||||
assertTrue(
|
||||
any {
|
||||
it.message.contains(message)
|
||||
}
|
||||
@@ -158,8 +157,7 @@ class KotlinKapt3IntegrationTests : AbstractKotlinKapt3IntegrationTest(), Custom
|
||||
test(
|
||||
name = name,
|
||||
supportedAnnotations = supportedAnnotations
|
||||
) { typeElements, roundEnv, processingEnv ->
|
||||
val kaptExtension = AnalysisHandlerExtension.getInstances(myEnvironment.project).firstIsInstance<Kapt3ExtensionForTests>()
|
||||
) { typeElements, roundEnv, processingEnv, kaptExtension ->
|
||||
messageCollector = kaptExtension.messageCollector
|
||||
process(typeElements, roundEnv, processingEnv)
|
||||
}
|
||||
@@ -168,9 +166,7 @@ class KotlinKapt3IntegrationTests : AbstractKotlinKapt3IntegrationTest(), Custom
|
||||
|
||||
|
||||
private fun bindingsTest(name: String, test: (File, File, Map<String, KaptJavaFileObject>) -> Unit) {
|
||||
test(name, "test.MyAnnotation") { _, _, _ ->
|
||||
val kaptExtension = AnalysisHandlerExtension.getInstances(myEnvironment.project).firstIsInstance<Kapt3ExtensionForTests>()
|
||||
|
||||
test(name, "test.MyAnnotation") { _, _, _, kaptExtension->
|
||||
val stubsOutputDir = kaptExtension.options.stubsOutputDir
|
||||
val incrementalDataOutputDir = kaptExtension.options.incrementalDataOutputDir
|
||||
|
||||
@@ -184,14 +180,14 @@ class KotlinKapt3IntegrationTests : AbstractKotlinKapt3IntegrationTest(), Custom
|
||||
fun testOptions() = test(
|
||||
"Simple", "test.MyAnnotation",
|
||||
options = mapOf("firstKey" to "firstValue", "secondKey" to "")
|
||||
) { _, _, env ->
|
||||
) { _, _, env, _ ->
|
||||
val options = env.options
|
||||
assertEquals("firstValue", options["firstKey"])
|
||||
assertTrue("secondKey" in options)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testOverloads() = test("Overloads", "test.MyAnnotation") { set, roundEnv, _ ->
|
||||
fun testOverloads() = test("Overloads", "test.MyAnnotation") { set, roundEnv, _, _ ->
|
||||
assertEquals(1, set.size)
|
||||
val annotatedElements = roundEnv.getElementsAnnotatedWith(set.single())
|
||||
assertEquals(1, annotatedElements.size)
|
||||
@@ -216,15 +212,3 @@ class KotlinKapt3IntegrationTests : AbstractKotlinKapt3IntegrationTest(), Custom
|
||||
assertEquals("someString", constructors[1].parameters[2].simpleName.toString())
|
||||
}
|
||||
}
|
||||
|
||||
internal class SingleJUnitTestRunner {
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun main(args: Array<String>) {
|
||||
val (className, methodName) = args.single().split('#')
|
||||
val request = Request.method(Class.forName(className), methodName)
|
||||
val result = JUnitCore().run(request)
|
||||
exitProcess(if (result.wasSuccessful()) 0 else 1)
|
||||
}
|
||||
}
|
||||
}
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.kapt3.test.integration
|
||||
|
||||
import org.jetbrains.kotlin.kapt3.test.JvmCompilerWithKaptFacade
|
||||
import org.jetbrains.kotlin.kapt3.test.KaptContextBinaryArtifact
|
||||
import org.jetbrains.kotlin.kapt3.test.KaptEnvironmentConfigurator
|
||||
import org.jetbrains.kotlin.kapt3.test.KaptTestDirectives
|
||||
import org.jetbrains.kotlin.platform.jvm.JvmPlatforms
|
||||
import org.jetbrains.kotlin.test.TargetBackend
|
||||
import org.jetbrains.kotlin.test.bind
|
||||
import org.jetbrains.kotlin.test.builders.TestConfigurationBuilder
|
||||
import org.jetbrains.kotlin.test.model.DependencyKind
|
||||
import org.jetbrains.kotlin.test.model.FrontendKinds
|
||||
import org.jetbrains.kotlin.test.runners.AbstractKotlinCompilerWithTargetBackendTest
|
||||
import org.jetbrains.kotlin.test.services.configuration.CommonEnvironmentConfigurator
|
||||
import org.jetbrains.kotlin.test.services.configuration.JvmEnvironmentConfigurator
|
||||
import javax.annotation.processing.ProcessingEnvironment
|
||||
import javax.annotation.processing.RoundEnvironment
|
||||
import javax.lang.model.element.TypeElement
|
||||
|
||||
class AbstractKotlinKapt3IntegrationTestRunner(
|
||||
targetBackend: TargetBackend,
|
||||
private val processorOptions: Map<String, String>,
|
||||
private val supportedAnnotations: List<String>,
|
||||
private val process: (Set<TypeElement>, RoundEnvironment, ProcessingEnvironment, Kapt3ExtensionForTests) -> Unit
|
||||
) : AbstractKotlinCompilerWithTargetBackendTest(targetBackend) {
|
||||
override fun TestConfigurationBuilder.configuration() {
|
||||
globalDefaults {
|
||||
frontend = FrontendKinds.ClassicFrontend
|
||||
targetPlatform = JvmPlatforms.defaultJvmPlatform
|
||||
dependencyKind = DependencyKind.Binary
|
||||
}
|
||||
|
||||
defaultDirectives {
|
||||
+KaptTestDirectives.MAP_DIAGNOSTIC_LOCATIONS
|
||||
if (targetBackend.isIR) {
|
||||
+KaptTestDirectives.USE_JVM_IR
|
||||
}
|
||||
}
|
||||
|
||||
useConfigurators(
|
||||
::CommonEnvironmentConfigurator,
|
||||
::JvmEnvironmentConfigurator,
|
||||
::KaptEnvironmentConfigurator.bind(processorOptions),
|
||||
{ KaptIntegrationEnvironmentConfigurator(it, processorOptions, supportedAnnotations, process) }
|
||||
)
|
||||
|
||||
facadeStep(::JvmCompilerWithKaptFacade)
|
||||
handlersStep(KaptContextBinaryArtifact.Kind) {
|
||||
useHandlers(::KaptIntegrationStubsDumpHandler, ::ProcessorWasCalledHandler)
|
||||
}
|
||||
|
||||
useAdditionalService(::Kapt3ExtensionProvider)
|
||||
}
|
||||
}
|
||||
+177
@@ -0,0 +1,177 @@
|
||||
/*
|
||||
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.kapt3.test.integration
|
||||
|
||||
import org.jetbrains.kotlin.base.kapt3.KaptOptions
|
||||
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity
|
||||
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSourceLocation
|
||||
import org.jetbrains.kotlin.cli.common.messages.MessageCollector
|
||||
import org.jetbrains.kotlin.config.CompilerConfiguration
|
||||
import org.jetbrains.kotlin.kapt3.AbstractKapt3Extension
|
||||
import org.jetbrains.kotlin.kapt3.KaptContextForStubGeneration
|
||||
import org.jetbrains.kotlin.kapt3.base.KaptContext
|
||||
import org.jetbrains.kotlin.kapt3.base.LoadedProcessors
|
||||
import org.jetbrains.kotlin.kapt3.base.incremental.DeclaredProcType
|
||||
import org.jetbrains.kotlin.kapt3.base.incremental.IncrementalProcessor
|
||||
import org.jetbrains.kotlin.kapt3.javac.KaptJavaFileObject
|
||||
import org.jetbrains.kotlin.kapt3.prettyPrint
|
||||
import org.jetbrains.kotlin.kapt3.stubs.ClassFileToSourceStubConverter
|
||||
import org.jetbrains.kotlin.kapt3.test.handlers.ClassFileToSourceKaptStubHandler.Companion.FILE_SEPARATOR
|
||||
import org.jetbrains.kotlin.kapt3.util.MessageCollectorBackedKaptLogger
|
||||
import org.jetbrains.kotlin.test.model.TestModule
|
||||
import org.jetbrains.kotlin.test.services.TestService
|
||||
import org.jetbrains.kotlin.test.services.TestServices
|
||||
import org.jetbrains.kotlin.test.services.assertions
|
||||
import javax.annotation.processing.Completion
|
||||
import javax.annotation.processing.ProcessingEnvironment
|
||||
import javax.annotation.processing.Processor
|
||||
import javax.annotation.processing.RoundEnvironment
|
||||
import javax.lang.model.SourceVersion
|
||||
import javax.lang.model.element.AnnotationMirror
|
||||
import javax.lang.model.element.Element
|
||||
import javax.lang.model.element.ExecutableElement
|
||||
import javax.lang.model.element.TypeElement
|
||||
|
||||
class Kapt3ExtensionProvider(private val testServices: TestServices) : TestService {
|
||||
private val cache: MutableMap<TestModule, Kapt3ExtensionForTests> = mutableMapOf()
|
||||
|
||||
fun createExtension(
|
||||
module: TestModule,
|
||||
kaptOptions: KaptOptions,
|
||||
processorOptions: Map<String, String>,
|
||||
process: (Set<TypeElement>, RoundEnvironment, ProcessingEnvironment, Kapt3ExtensionForTests) -> Unit,
|
||||
supportedAnnotations: List<String>,
|
||||
compilerConfiguration: CompilerConfiguration,
|
||||
): Kapt3ExtensionForTests {
|
||||
if (module in cache) {
|
||||
testServices.assertions.fail { "Kapt3ExtensionForTests for module $module already registered" }
|
||||
}
|
||||
|
||||
val extension = Kapt3ExtensionForTests(
|
||||
processorOptions,
|
||||
kaptOptions,
|
||||
process,
|
||||
supportedAnnotations,
|
||||
compilerConfiguration
|
||||
)
|
||||
cache[module] = extension
|
||||
return extension
|
||||
}
|
||||
|
||||
operator fun get(module: TestModule): Kapt3ExtensionForTests {
|
||||
return cache.getValue(module)
|
||||
}
|
||||
}
|
||||
|
||||
val TestServices.kapt3ExtensionProvider: Kapt3ExtensionProvider by TestServices.testServiceAccessor()
|
||||
|
||||
class Kapt3ExtensionForTests(
|
||||
private val processorOptions: Map<String, String>,
|
||||
options: KaptOptions,
|
||||
private val process: (Set<TypeElement>, RoundEnvironment, ProcessingEnvironment, Kapt3ExtensionForTests) -> Unit,
|
||||
val supportedAnnotations: List<String>,
|
||||
compilerConfiguration: CompilerConfiguration,
|
||||
val messageCollector: LoggingMessageCollector = LoggingMessageCollector()
|
||||
) : AbstractKapt3Extension(
|
||||
options, MessageCollectorBackedKaptLogger(
|
||||
flags = options,
|
||||
messageCollector = messageCollector
|
||||
), compilerConfiguration = compilerConfiguration
|
||||
) {
|
||||
private var _started = false
|
||||
val started: Boolean
|
||||
get() = _started
|
||||
var savedStubs: String? = null
|
||||
private set
|
||||
var savedBindings: Map<String, KaptJavaFileObject>? = null
|
||||
private set
|
||||
|
||||
private val processor = object : Processor {
|
||||
lateinit var processingEnv: ProcessingEnvironment
|
||||
|
||||
override fun getSupportedOptions() = processorOptions.keys
|
||||
|
||||
override fun process(annotations: Set<TypeElement>, roundEnv: RoundEnvironment): Boolean {
|
||||
if (!roundEnv.processingOver()) {
|
||||
_started = true
|
||||
process(annotations, roundEnv, processingEnv, this@Kapt3ExtensionForTests)
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
override fun init(env: ProcessingEnvironment) {
|
||||
processingEnv = env
|
||||
}
|
||||
|
||||
override fun getCompletions(
|
||||
element: Element?,
|
||||
annotation: AnnotationMirror?,
|
||||
member: ExecutableElement?,
|
||||
userText: String?
|
||||
): Iterable<Completion> {
|
||||
return emptyList()
|
||||
}
|
||||
|
||||
override fun getSupportedSourceVersion() = SourceVersion.RELEASE_6
|
||||
override fun getSupportedAnnotationTypes() = supportedAnnotations.toSet()
|
||||
}
|
||||
|
||||
override fun loadProcessors() = LoadedProcessors(
|
||||
listOf(IncrementalProcessor(processor, DeclaredProcType.NON_INCREMENTAL, logger)),
|
||||
Kapt3ExtensionForTests::class.java.classLoader
|
||||
)
|
||||
|
||||
override fun saveStubs(kaptContext: KaptContext, stubs: List<ClassFileToSourceStubConverter.KaptStub>) {
|
||||
if (this.savedStubs != null) {
|
||||
error("Stubs are already saved")
|
||||
}
|
||||
|
||||
this.savedStubs = stubs
|
||||
.map { it.file.prettyPrint(kaptContext.context) }
|
||||
.sorted()
|
||||
.joinToString(FILE_SEPARATOR)
|
||||
|
||||
super.saveStubs(kaptContext, stubs)
|
||||
}
|
||||
|
||||
override fun saveIncrementalData(
|
||||
kaptContext: KaptContextForStubGeneration,
|
||||
messageCollector: MessageCollector,
|
||||
converter: ClassFileToSourceStubConverter
|
||||
) {
|
||||
if (this.savedBindings != null) {
|
||||
error("Bindings are already saved")
|
||||
}
|
||||
|
||||
this.savedBindings = converter.bindings
|
||||
|
||||
super.saveIncrementalData(kaptContext, messageCollector, converter)
|
||||
}
|
||||
}
|
||||
|
||||
class LoggingMessageCollector : MessageCollector {
|
||||
private val _messages = mutableListOf<Message>()
|
||||
val messages: List<Message>
|
||||
get() = _messages
|
||||
|
||||
override fun clear() {
|
||||
_messages.clear()
|
||||
}
|
||||
|
||||
override fun report(severity: CompilerMessageSeverity, message: String, location: CompilerMessageSourceLocation?) {
|
||||
_messages.add(Message(severity, message, location))
|
||||
}
|
||||
|
||||
override fun hasErrors() = _messages.any {
|
||||
it.severity.isError
|
||||
}
|
||||
|
||||
data class Message(
|
||||
val severity: CompilerMessageSeverity,
|
||||
val message: String,
|
||||
val location: CompilerMessageSourceLocation?
|
||||
)
|
||||
}
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.kapt3.test.integration
|
||||
|
||||
import com.intellij.openapi.project.Project
|
||||
import org.jetbrains.kotlin.config.CompilerConfiguration
|
||||
import org.jetbrains.kotlin.kapt3.test.kaptOptionsProvider
|
||||
import org.jetbrains.kotlin.resolve.jvm.extensions.AnalysisHandlerExtension
|
||||
import org.jetbrains.kotlin.test.model.TestModule
|
||||
import org.jetbrains.kotlin.test.services.EnvironmentConfigurator
|
||||
import org.jetbrains.kotlin.test.services.TestServices
|
||||
import javax.annotation.processing.ProcessingEnvironment
|
||||
import javax.annotation.processing.RoundEnvironment
|
||||
import javax.lang.model.element.TypeElement
|
||||
|
||||
class KaptIntegrationEnvironmentConfigurator(
|
||||
testServices: TestServices,
|
||||
private val processorOptions: Map<String, String>,
|
||||
private val supportedAnnotations: List<String>,
|
||||
private val process: (Set<TypeElement>, RoundEnvironment, ProcessingEnvironment, Kapt3ExtensionForTests) -> Unit
|
||||
) : EnvironmentConfigurator(testServices) {
|
||||
override fun legacyRegisterCompilerExtensions(project: Project, module: TestModule, configuration: CompilerConfiguration) {
|
||||
val kaptOptions = testServices.kaptOptionsProvider[module]
|
||||
val kapt3Extension = testServices.kapt3ExtensionProvider.createExtension(
|
||||
module,
|
||||
kaptOptions,
|
||||
processorOptions,
|
||||
process,
|
||||
supportedAnnotations,
|
||||
configuration
|
||||
)
|
||||
AnalysisHandlerExtension.registerExtension(project, kapt3Extension)
|
||||
}
|
||||
}
|
||||
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.kapt3.test.integration
|
||||
|
||||
import com.intellij.openapi.util.text.StringUtil
|
||||
import org.jetbrains.kotlin.kapt3.test.KaptContextBinaryArtifact
|
||||
import org.jetbrains.kotlin.kapt3.test.handlers.AbstractKaptHandler
|
||||
import org.jetbrains.kotlin.kapt3.test.handlers.checkTxtAccordingToBackend
|
||||
import org.jetbrains.kotlin.kapt3.test.handlers.removeMetadataAnnotationContents
|
||||
import org.jetbrains.kotlin.test.model.TestModule
|
||||
import org.jetbrains.kotlin.test.services.TestServices
|
||||
import org.jetbrains.kotlin.test.util.trimTrailingWhitespacesAndAddNewlineAtEOF
|
||||
|
||||
class KaptIntegrationStubsDumpHandler(testServices: TestServices) : AbstractKaptHandler(testServices) {
|
||||
companion object {
|
||||
private const val FILE_SUFFIX = ".it"
|
||||
}
|
||||
|
||||
override fun processModule(module: TestModule, info: KaptContextBinaryArtifact) {
|
||||
val actualRaw = testServices.kapt3ExtensionProvider[module].savedStubs ?: assertions.fail { "Stubs were not saved" }
|
||||
val actual = StringUtil.convertLineSeparators(actualRaw.trim { it <= ' ' })
|
||||
.trimTrailingWhitespacesAndAddNewlineAtEOF()
|
||||
.let { removeMetadataAnnotationContents(it) }
|
||||
assertions.checkTxtAccordingToBackend(module, actual, FILE_SUFFIX)
|
||||
}
|
||||
|
||||
override fun processAfterAllModules(someAssertionWasFailed: Boolean) {}
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.kapt3.test.integration
|
||||
|
||||
import org.jetbrains.kotlin.kapt3.test.KaptContextBinaryArtifact
|
||||
import org.jetbrains.kotlin.kapt3.test.handlers.AbstractKaptHandler
|
||||
import org.jetbrains.kotlin.test.model.AnalysisHandler
|
||||
import org.jetbrains.kotlin.test.model.TestArtifactKind
|
||||
import org.jetbrains.kotlin.test.model.TestModule
|
||||
import org.jetbrains.kotlin.test.services.TestServices
|
||||
|
||||
class ProcessorWasCalledHandler(testServices: TestServices) : AbstractKaptHandler(testServices) {
|
||||
override val artifactKind: TestArtifactKind<KaptContextBinaryArtifact>
|
||||
get() = KaptContextBinaryArtifact.Kind
|
||||
|
||||
override fun processModule(module: TestModule, info: KaptContextBinaryArtifact) {
|
||||
assertions.assertTrue(testServices.kapt3ExtensionProvider[module].started) { "Annotation processor was not started" }
|
||||
}
|
||||
|
||||
override fun processAfterAllModules(someAssertionWasFailed: Boolean) {}
|
||||
}
|
||||
@@ -1,78 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2017 JetBrains s.r.o.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.kapt3.test
|
||||
|
||||
import com.intellij.openapi.application.PathManager
|
||||
import com.intellij.openapi.util.SystemInfoRt
|
||||
import org.jetbrains.kotlin.kapt3.base.util.isJava9OrLater
|
||||
import org.jetbrains.kotlin.test.util.KtTestUtil
|
||||
import java.io.File
|
||||
import java.net.URL
|
||||
import java.net.URLClassLoader
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
interface CustomJdkTestLauncher {
|
||||
fun doTestWithJdk11(mainClass: Class<*>, vararg args: String) {
|
||||
if (isJava9OrLater()) return
|
||||
doTestCustomJdk(mainClass, KtTestUtil.getJdk11Home(), *args)
|
||||
}
|
||||
|
||||
private fun doTestCustomJdk(mainClass: Class<*>, javaHome: File, vararg args: String) {
|
||||
//TODO unmute after investigation (tests are failing on TeamCity)
|
||||
if (SystemInfoRt.isWindows) return
|
||||
|
||||
val javaExe = File(javaHome, "bin/java.exe").takeIf { it.exists() } ?: File(javaHome, "bin/java")
|
||||
assert(javaExe.exists()) { "Can't find 'java' executable in $javaHome" }
|
||||
|
||||
val currentJavaHome = System.getProperty("java.home")
|
||||
|
||||
val classpath = collectClasspath(AbstractClassFileToSourceStubConverterTest::class.java.classLoader)
|
||||
.filter { it.protocol.lowercase() == "file" && it.path != null && !it.path.startsWith(currentJavaHome) }
|
||||
.map { it.path }
|
||||
|
||||
val command = arrayOf(
|
||||
javaExe.absolutePath,
|
||||
"--illegal-access=warn",
|
||||
"-ea",
|
||||
"-D${PathManager.PROPERTY_HOME_PATH}=${PathManager.getHomePath()}",
|
||||
"-classpath",
|
||||
classpath.joinToString(File.pathSeparator),
|
||||
mainClass.name,
|
||||
*args
|
||||
)
|
||||
|
||||
val process = ProcessBuilder(*command).start()
|
||||
val stdout = process.inputStream.bufferedReader().use { it.readText() }
|
||||
val stderr = process.errorStream.bufferedReader().use { it.readText() }
|
||||
process.waitFor(3, TimeUnit.MINUTES)
|
||||
|
||||
val exitCode = process.exitValue()
|
||||
if (exitCode != 0) {
|
||||
throw AssertionError(
|
||||
"Java $javaHome test process exited with exit code $exitCode\n\n" +
|
||||
"--- STDOUT ---\n$stdout\n\n" +
|
||||
"--- STDERR ---\n$stderr"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private fun collectClasspath(classLoader: ClassLoader?): List<URL> = when (classLoader) {
|
||||
is URLClassLoader -> classLoader.urLs.asList() + collectClasspath(classLoader.parent)
|
||||
is ClassLoader -> collectClasspath(classLoader.parent)
|
||||
else -> emptyList()
|
||||
}
|
||||
}
|
||||
+80
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.kapt3.test.runners
|
||||
|
||||
import org.jetbrains.kotlin.kapt3.test.JvmCompilerWithKaptFacade
|
||||
import org.jetbrains.kotlin.kapt3.test.KaptContextBinaryArtifact
|
||||
import org.jetbrains.kotlin.kapt3.test.KaptEnvironmentConfigurator
|
||||
import org.jetbrains.kotlin.kapt3.test.KaptRegularExtensionForTestConfigurator
|
||||
import org.jetbrains.kotlin.kapt3.test.KaptTestDirectives.MAP_DIAGNOSTIC_LOCATIONS
|
||||
import org.jetbrains.kotlin.kapt3.test.KaptTestDirectives.USE_JVM_IR
|
||||
import org.jetbrains.kotlin.kapt3.test.handlers.ClassFileToSourceKaptStubHandler
|
||||
import org.jetbrains.kotlin.platform.jvm.JvmPlatforms
|
||||
import org.jetbrains.kotlin.test.TargetBackend
|
||||
import org.jetbrains.kotlin.test.backend.BlackBoxCodegenSuppressor
|
||||
import org.jetbrains.kotlin.test.builders.TestConfigurationBuilder
|
||||
import org.jetbrains.kotlin.test.directives.ConfigurationDirectives.WITH_STDLIB
|
||||
import org.jetbrains.kotlin.test.model.DependencyKind
|
||||
import org.jetbrains.kotlin.test.model.FrontendKinds
|
||||
import org.jetbrains.kotlin.test.runners.AbstractKotlinCompilerWithTargetBackendTest
|
||||
import org.jetbrains.kotlin.test.services.configuration.CommonEnvironmentConfigurator
|
||||
import org.jetbrains.kotlin.test.services.configuration.JvmEnvironmentConfigurator
|
||||
|
||||
abstract class AbstractClassFileToSourceStubConverterTestBase(
|
||||
targetBackend: TargetBackend
|
||||
) : AbstractKotlinCompilerWithTargetBackendTest(targetBackend) {
|
||||
override fun TestConfigurationBuilder.configuration() {
|
||||
globalDefaults {
|
||||
frontend = FrontendKinds.ClassicFrontend
|
||||
targetPlatform = JvmPlatforms.defaultJvmPlatform
|
||||
dependencyKind = DependencyKind.Binary
|
||||
}
|
||||
|
||||
defaultDirectives {
|
||||
+MAP_DIAGNOSTIC_LOCATIONS
|
||||
+WITH_STDLIB
|
||||
}
|
||||
|
||||
useConfigurators(
|
||||
::CommonEnvironmentConfigurator,
|
||||
::JvmEnvironmentConfigurator,
|
||||
::KaptEnvironmentConfigurator,
|
||||
::KaptRegularExtensionForTestConfigurator,
|
||||
)
|
||||
|
||||
facadeStep(::JvmCompilerWithKaptFacade)
|
||||
handlersStep(KaptContextBinaryArtifact.Kind) {
|
||||
useHandlers(::ClassFileToSourceKaptStubHandler)
|
||||
}
|
||||
|
||||
useAfterAnalysisCheckers(::BlackBoxCodegenSuppressor)
|
||||
}
|
||||
}
|
||||
|
||||
open class AbstractClassFileToSourceStubConverterTest : AbstractClassFileToSourceStubConverterTestBase(TargetBackend.JVM) {
|
||||
override fun configure(builder: TestConfigurationBuilder) {
|
||||
super.configure(builder)
|
||||
builder.apply {
|
||||
globalDefaults {
|
||||
targetBackend = TargetBackend.JVM
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
open class AbstractIrClassFileToSourceStubConverterTest : AbstractClassFileToSourceStubConverterTestBase(TargetBackend.JVM_IR) {
|
||||
override fun configure(builder: TestConfigurationBuilder) {
|
||||
super.configure(builder)
|
||||
builder.apply {
|
||||
globalDefaults {
|
||||
targetBackend = TargetBackend.JVM_IR
|
||||
}
|
||||
defaultDirectives {
|
||||
+USE_JVM_IR
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+71
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.kapt3.test.runners
|
||||
|
||||
import org.jetbrains.kotlin.kapt3.test.*
|
||||
import org.jetbrains.kotlin.kapt3.test.KaptTestDirectives.MAP_DIAGNOSTIC_LOCATIONS
|
||||
import org.jetbrains.kotlin.kapt3.test.handlers.KaptContextHandler
|
||||
import org.jetbrains.kotlin.platform.jvm.JvmPlatforms
|
||||
import org.jetbrains.kotlin.test.TargetBackend
|
||||
import org.jetbrains.kotlin.test.builders.TestConfigurationBuilder
|
||||
import org.jetbrains.kotlin.test.model.DependencyKind
|
||||
import org.jetbrains.kotlin.test.model.FrontendKinds
|
||||
import org.jetbrains.kotlin.test.runners.AbstractKotlinCompilerWithTargetBackendTest
|
||||
import org.jetbrains.kotlin.test.services.configuration.CommonEnvironmentConfigurator
|
||||
import org.jetbrains.kotlin.test.services.configuration.JvmEnvironmentConfigurator
|
||||
|
||||
abstract class AbstractKotlinKaptContextTestBase(
|
||||
targetBackend: TargetBackend
|
||||
) : AbstractKotlinCompilerWithTargetBackendTest(targetBackend) {
|
||||
override fun TestConfigurationBuilder.configuration() {
|
||||
globalDefaults {
|
||||
frontend = FrontendKinds.ClassicFrontend
|
||||
targetPlatform = JvmPlatforms.defaultJvmPlatform
|
||||
dependencyKind = DependencyKind.Binary
|
||||
}
|
||||
|
||||
defaultDirectives {
|
||||
+MAP_DIAGNOSTIC_LOCATIONS
|
||||
}
|
||||
|
||||
useConfigurators(
|
||||
::CommonEnvironmentConfigurator,
|
||||
::JvmEnvironmentConfigurator,
|
||||
::KaptEnvironmentConfigurator,
|
||||
::KaptRegularExtensionForTestConfigurator,
|
||||
)
|
||||
|
||||
facadeStep(::JvmCompilerWithKaptFacade)
|
||||
handlersStep(KaptContextBinaryArtifact.Kind) {
|
||||
useHandlers(::KaptContextHandler)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
open class AbstractKotlinKaptContextTest : AbstractKotlinKaptContextTestBase(TargetBackend.JVM) {
|
||||
override fun configure(builder: TestConfigurationBuilder) {
|
||||
super.configure(builder)
|
||||
builder.apply {
|
||||
globalDefaults {
|
||||
targetBackend = TargetBackend.JVM
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
open class AbstractIrKotlinKaptContextTest : AbstractKotlinKaptContextTestBase(TargetBackend.JVM_IR) {
|
||||
override fun configure(builder: TestConfigurationBuilder) {
|
||||
super.configure(builder)
|
||||
builder.apply {
|
||||
globalDefaults {
|
||||
targetBackend = TargetBackend.JVM_IR
|
||||
}
|
||||
defaultDirectives {
|
||||
+KaptTestDirectives.USE_JVM_IR
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,14 +1,14 @@
|
||||
// CORRECT_ERROR_TYPES
|
||||
// NO_VALIDATION
|
||||
|
||||
//FILE: lib/Anno.java
|
||||
// FILE: lib/Anno.java
|
||||
package lib;
|
||||
|
||||
public @interface Anno {
|
||||
Class<?>[] impls() default {};
|
||||
}
|
||||
|
||||
//FILE: lib/impl/Impl.java
|
||||
// FILE: lib/impl/Impl.java
|
||||
package lib.impl;
|
||||
|
||||
public class Impl {}
|
||||
|
||||
+11
-11
@@ -1,4 +1,9 @@
|
||||
//FILE: lib/R.java
|
||||
// EXPECTED_ERROR: class B is public, should be declared in a file named B.java
|
||||
// EXPECTED_ERROR: class R is public, should be declared in a file named R.java
|
||||
// EXPECTED_ERROR: class R is public, should be declared in a file named R.java
|
||||
// EXPECTED_ERROR: class R2 is public, should be declared in a file named R2.java
|
||||
|
||||
// FILE: lib/R.java
|
||||
package lib;
|
||||
|
||||
public class R {
|
||||
@@ -7,7 +12,7 @@ public class R {
|
||||
}
|
||||
}
|
||||
|
||||
//FILE: app/R.java
|
||||
// FILE: app/R.java
|
||||
package app;
|
||||
|
||||
public class R {
|
||||
@@ -16,7 +21,7 @@ public class R {
|
||||
}
|
||||
}
|
||||
|
||||
//FILE: app/R2.java
|
||||
// FILE: app/R2.java
|
||||
package app;
|
||||
|
||||
public class R2 { // For ButterKnife library project support
|
||||
@@ -25,7 +30,7 @@ public class R2 { // For ButterKnife library project support
|
||||
}
|
||||
}
|
||||
|
||||
//FILE: app/B.java
|
||||
// FILE: app/B.java
|
||||
package app;
|
||||
|
||||
public class B {
|
||||
@@ -44,7 +49,7 @@ public class B {
|
||||
public final static String a9 = "A";
|
||||
}
|
||||
|
||||
//FILE: lib/OnClick.java
|
||||
// FILE: lib/OnClick.java
|
||||
package lib;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
@@ -58,7 +63,7 @@ public @interface OnClick {
|
||||
int[] value() default {};
|
||||
}
|
||||
|
||||
//FILE: test.kt
|
||||
// FILE: test.kt
|
||||
package app
|
||||
|
||||
import lib.R as LibR
|
||||
@@ -168,8 +173,3 @@ object JJ {
|
||||
val b = c()
|
||||
fun c() = "42"
|
||||
}
|
||||
|
||||
// EXPECTED_ERROR class B is public, should be declared in a file named B.java
|
||||
// EXPECTED_ERROR class R is public, should be declared in a file named R.java
|
||||
// EXPECTED_ERROR class R is public, should be declared in a file named R.java
|
||||
// EXPECTED_ERROR class R2 is public, should be declared in a file named R2.java
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// !KEEP_KDOC_COMMENTS_IN_STUBS
|
||||
// DISABLED_FLAGS: KEEP_KDOC_COMMENTS_IN_STUBS
|
||||
/** Test. */
|
||||
class Test {
|
||||
/** method(). */
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
// STRICT
|
||||
|
||||
//FILE: test/ClassRefAnnotation.java
|
||||
// EXPECTED_ERROR: (kotlin:42:1) cannot find symbol
|
||||
// EXPECTED_ERROR: (other:-1:-1) test.PackedClass: Can't reference type 'RootClass' from default package in Java stub.
|
||||
// EXPECTED_ERROR: (other:-1:-1) test.PackedClass: Can't reference type 'AnotherRootClass' from default package in Java stub.
|
||||
// EXPECTED_ERROR: (other:-1:-1) test.PackedWithAnnotation: Can't reference type 'RootClass' from default package in Java stub.
|
||||
|
||||
// FILE: test/ClassRefAnnotation.java
|
||||
|
||||
package test;
|
||||
|
||||
@@ -15,13 +20,13 @@ public @interface ClassRefAnnotation {
|
||||
Class<?>[] value();
|
||||
}
|
||||
|
||||
//FILE: a.kt
|
||||
// FILE: a.kt
|
||||
|
||||
class RootClass
|
||||
|
||||
class AnotherRootClass
|
||||
|
||||
//FILE: b.kt
|
||||
// FILE: b.kt
|
||||
package test
|
||||
|
||||
import java.lang.Number as JavaNumber
|
||||
@@ -36,8 +41,3 @@ interface PackedClass {
|
||||
|
||||
@ClassRefAnnotation(RootClass::class)
|
||||
class PackedWithAnnotation
|
||||
|
||||
// EXPECTED_ERROR(kotlin:14:1) cannot find symbol
|
||||
// EXPECTED_ERROR(other:-1:-1) test.PackedClass: Can't reference type 'RootClass' from default package in Java stub.
|
||||
// EXPECTED_ERROR(other:-1:-1) test.PackedClass: Can't reference type 'AnotherRootClass' from default package in Java stub.
|
||||
// EXPECTED_ERROR(other:-1:-1) test.PackedWithAnnotation: Can't reference type 'RootClass' from default package in Java stub.
|
||||
|
||||
+8
-8
@@ -1,7 +1,12 @@
|
||||
// CORRECT_ERROR_TYPES
|
||||
// STRICT
|
||||
|
||||
//FILE: test/ClassRefAnnotation.java
|
||||
// EXPECTED_ERROR: (kotlin:43:1) cannot find symbol
|
||||
// EXPECTED_ERROR: (other:-1:-1) test.PackedClass: Can't reference type 'RootClass' from default package in Java stub.
|
||||
// EXPECTED_ERROR: (other:-1:-1) test.PackedClass: Can't reference type 'AnotherRootClass' from default package in Java stub.
|
||||
// EXPECTED_ERROR: (other:-1:-1) test.PackedWithAnnotation: Can't reference type 'RootClass' from default package in Java stub.
|
||||
|
||||
// FILE: test/ClassRefAnnotation.java
|
||||
|
||||
package test;
|
||||
|
||||
@@ -16,13 +21,13 @@ public @interface ClassRefAnnotation {
|
||||
Class<?>[] value();
|
||||
}
|
||||
|
||||
//FILE: a.kt
|
||||
// FILE: a.kt
|
||||
|
||||
class RootClass
|
||||
|
||||
class AnotherRootClass
|
||||
|
||||
//FILE: b.kt
|
||||
// FILE: b.kt
|
||||
package test
|
||||
|
||||
import java.lang.Number as JavaNumber
|
||||
@@ -37,8 +42,3 @@ interface PackedClass {
|
||||
|
||||
@ClassRefAnnotation(RootClass::class)
|
||||
class PackedWithAnnotation
|
||||
|
||||
// EXPECTED_ERROR(kotlin:14:1) cannot find symbol
|
||||
// EXPECTED_ERROR(other:-1:-1) test.PackedClass: Can't reference type 'RootClass' from default package in Java stub.
|
||||
// EXPECTED_ERROR(other:-1:-1) test.PackedClass: Can't reference type 'AnotherRootClass' from default package in Java stub.
|
||||
// EXPECTED_ERROR(other:-1:-1) test.PackedWithAnnotation: Can't reference type 'RootClass' from default package in Java stub.
|
||||
|
||||
@@ -27,6 +27,6 @@ class ErrorInDeclarations {
|
||||
|
||||
annotation class Anno(val a: KClass<Any>)
|
||||
|
||||
// EXPECTED_ERROR(kotlin:11:1) cannot find symbol
|
||||
// EXPECTED_ERROR(kotlin:6:1) cannot find symbol
|
||||
// EXPECTED_ERROR(kotlin:12:1) cannot find symbol
|
||||
// EXPECTED_ERROR: (kotlin:11:1) cannot find symbol
|
||||
// EXPECTED_ERROR: (kotlin:6:1) cannot find symbol
|
||||
// EXPECTED_ERROR: (kotlin:12:1) cannot find symbol
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
// CORRECT_ERROR_TYPES
|
||||
|
||||
// EXPECTED_ERROR: (kotlin:16:5) cannot find symbol
|
||||
|
||||
// FILE: a.kt
|
||||
package test
|
||||
|
||||
@@ -51,5 +53,3 @@ interface TestC {
|
||||
|
||||
fun e(): LibFooBar
|
||||
}
|
||||
|
||||
// EXPECTED_ERROR(kotlin:16:5) cannot find symbol
|
||||
|
||||
@@ -5,5 +5,5 @@ enum class Color {
|
||||
@Anno(Color.`WHI-TE`)
|
||||
annotation class Anno(val color: Color)
|
||||
|
||||
// EXPECTED_ERROR(kotlin:5:1) an enum annotation value must be an enum constant
|
||||
// EXPECTED_ERROR(other:-1:-1) 'WHI-TE' is an invalid Java enum value name
|
||||
// EXPECTED_ERROR: (kotlin:5:1) an enum annotation value must be an enum constant
|
||||
// EXPECTED_ERROR: (other:-1:-1) 'WHI-TE' is an invalid Java enum value name
|
||||
|
||||
@@ -10,4 +10,4 @@ class Foo(private val string: String) {
|
||||
}
|
||||
}
|
||||
|
||||
// EXPECTED_ERROR(other:-1:-1) Can't generate a stub for 'Foo$Bar$Bar'.
|
||||
// EXPECTED_ERROR: (other:-1:-1) Can't generate a stub for 'Foo$Bar$Bar'.
|
||||
|
||||
@@ -15,6 +15,6 @@ class ErrorSomeMissingAnnotations
|
||||
|
||||
annotation class Anno(val klass: KClass<*>)
|
||||
|
||||
// EXPECTED_ERROR(kotlin:10:1) cannot find symbol
|
||||
// EXPECTED_ERROR(kotlin:13:1) cannot find symbol
|
||||
// EXPECTED_ERROR(kotlin:7:1) cannot find symbol
|
||||
// EXPECTED_ERROR: (kotlin:10:1) cannot find symbol
|
||||
// EXPECTED_ERROR: (kotlin:13:1) cannot find symbol
|
||||
// EXPECTED_ERROR: (kotlin:7:1) cannot find symbol
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// CORRECT_ERROR_TYPES
|
||||
|
||||
// FILE: te/st/a/JavaClass
|
||||
// FILE: te/st/a/JavaClass.java
|
||||
package te.st.a;
|
||||
|
||||
public class JavaClass {}
|
||||
|
||||
@@ -1,5 +1,16 @@
|
||||
package te.st.a;
|
||||
|
||||
public class JavaClass {
|
||||
|
||||
public JavaClass() {
|
||||
super();
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////
|
||||
|
||||
package te.st.a;
|
||||
|
||||
import te.st.a.$Test.Inner;
|
||||
import te.st.a.Test$.Inner$;
|
||||
|
||||
|
||||
@@ -11,4 +11,4 @@ class Test {
|
||||
// There are two errors (unresolved identifier ABC, BCD) actually.
|
||||
// But we specified the max error count, so the error output is limited.
|
||||
|
||||
// EXPECTED_ERROR(kotlin:7:5) cannot find symbol
|
||||
// EXPECTED_ERROR: (kotlin:7:5) cannot find symbol
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
// EXPECTED_ERROR: class J$B is public, should be declared in a file named J$B.java
|
||||
// EXPECTED_ERROR: class JavaClass is public, should be declared in a file named JavaClass.java
|
||||
|
||||
// FILE: JavaClass.java
|
||||
public class JavaClass {
|
||||
public class Foo {
|
||||
@@ -5,7 +8,7 @@ public class JavaClass {
|
||||
}
|
||||
}
|
||||
|
||||
//FILE: J$B.java
|
||||
// FILE: J$B.java
|
||||
public class J$B {
|
||||
public class C {}
|
||||
|
||||
@@ -76,6 +79,3 @@ class Test1(val zoo: Foo.Bar.Zoo) : Foo.Bar(), IFoo.IBar, IFoo.IBar.IZoo {
|
||||
fun a(): Thread.State = Thread.State.NEW
|
||||
fun b(foo: JavaClass.Foo, bar: JavaClass.Foo.Bar) {}
|
||||
}
|
||||
|
||||
// EXPECTED_ERROR class J$B is public, should be declared in a file named J$B.java
|
||||
// EXPECTED_ERROR class JavaClass is public, should be declared in a file named JavaClass.java
|
||||
|
||||
+3
-3
@@ -1,3 +1,5 @@
|
||||
// EXPECTED_ERROR: class J$B is public, should be declared in a file named J$B.java
|
||||
|
||||
// FILE: test/JavaClass.java
|
||||
package test;
|
||||
|
||||
@@ -7,7 +9,7 @@ class JavaClass {
|
||||
}
|
||||
}
|
||||
|
||||
//FILE: test/J$B.java
|
||||
// FILE: test/J$B.java
|
||||
package test;
|
||||
|
||||
public class J$B {
|
||||
@@ -82,5 +84,3 @@ class Test1(val zoo: Foo.Bar.Zoo) : Foo.Bar(), IFoo.IBar, IFoo.IBar.IZoo {
|
||||
fun a(): Thread.State = Thread.State.NEW
|
||||
fun b(foo: JavaClass.Foo, bar: JavaClass.Foo.Bar) {}
|
||||
}
|
||||
|
||||
// EXPECTED_ERROR class J$B is public, should be declared in a file named J$B.java
|
||||
|
||||
@@ -5,7 +5,7 @@ public @interface Anno {
|
||||
String value();
|
||||
}
|
||||
|
||||
//FILE: lib/R.java
|
||||
// FILE: lib/R.java
|
||||
package lib;
|
||||
|
||||
public class R {
|
||||
@@ -15,7 +15,6 @@ public class R {
|
||||
}
|
||||
|
||||
// FILE: test.kt
|
||||
// WITH_STDLIB
|
||||
import lib.Anno
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
|
||||
@@ -37,4 +37,4 @@ class `A B` {
|
||||
class C
|
||||
}
|
||||
|
||||
// EXPECTED_ERROR(other:-1:-1) '60x60' is an invalid Java enum value name
|
||||
// EXPECTED_ERROR: (other:-1:-1) '60x60' is an invalid Java enum value name
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// WITH_STDLIB
|
||||
|
||||
package test
|
||||
|
||||
internal annotation class MyAnnotation
|
||||
|
||||
@@ -36,12 +36,8 @@ package test;
|
||||
import java.lang.System;
|
||||
|
||||
@kotlin.Metadata()
|
||||
public enum EnumClass {
|
||||
/*public static final*/ BLACK /* = new BLACK() */,
|
||||
/*public static final*/ WHITE /* = new WHITE() */;
|
||||
|
||||
EnumClass() {
|
||||
}
|
||||
@java.lang.annotation.Retention(value = java.lang.annotation.RetentionPolicy.RUNTIME)
|
||||
public abstract @interface MyAnnotation {
|
||||
}
|
||||
|
||||
////////////////////
|
||||
@@ -51,8 +47,12 @@ package test;
|
||||
import java.lang.System;
|
||||
|
||||
@kotlin.Metadata()
|
||||
@java.lang.annotation.Retention(value = java.lang.annotation.RetentionPolicy.RUNTIME)
|
||||
public abstract @interface MyAnnotation {
|
||||
public enum EnumClass {
|
||||
/*public static final*/ BLACK /* = new BLACK() */,
|
||||
/*public static final*/ WHITE /* = new WHITE() */;
|
||||
|
||||
EnumClass() {
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////
|
||||
|
||||
+104
-11
@@ -3,512 +3,605 @@
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.kapt3.test;
|
||||
package org.jetbrains.kotlin.kapt3.test.runners;
|
||||
|
||||
import com.intellij.testFramework.TestDataPath;
|
||||
import org.jetbrains.kotlin.test.JUnit3RunnerWithInners;
|
||||
import org.jetbrains.kotlin.test.KotlinTestUtils;
|
||||
import org.jetbrains.kotlin.test.util.KtTestUtil;
|
||||
import org.jetbrains.kotlin.test.TargetBackend;
|
||||
import org.jetbrains.kotlin.test.TestMetadata;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Nested;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */
|
||||
/** This class is generated by {@link GenerateNewCompilerTests.kt}. DO NOT MODIFY MANUALLY */
|
||||
@SuppressWarnings("all")
|
||||
@TestMetadata("plugins/kapt3/kapt3-compiler/testData/converter")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public class ClassFileToSourceStubConverterTestGenerated extends AbstractClassFileToSourceStubConverterTest {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("abstractEnum.kt")
|
||||
public void testAbstractEnum() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/abstractEnum.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("abstractMethods.kt")
|
||||
public void testAbstractMethods() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/abstractMethods.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("aliasedImports.kt")
|
||||
public void testAliasedImports() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/aliasedImports.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAllFilesPresentInConverter() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("plugins/kapt3/kapt3-compiler/testData/converter"), Pattern.compile("^(.+)\\.kt$"), null, true);
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("plugins/kapt3/kapt3-compiler/testData/converter"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("annotationWithFqNames.kt")
|
||||
public void testAnnotationWithFqNames() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/annotationWithFqNames.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("annotations.kt")
|
||||
public void testAnnotations() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/annotations.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("annotations2.kt")
|
||||
public void testAnnotations2() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/annotations2.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("annotations3.kt")
|
||||
public void testAnnotations3() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/annotations3.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("annotationsWithConstants.kt")
|
||||
public void testAnnotationsWithConstants() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/annotationsWithConstants.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("annotationsWithTargets.kt")
|
||||
public void testAnnotationsWithTargets() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/annotationsWithTargets.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("anonymousDelegate.kt")
|
||||
public void testAnonymousDelegate() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/anonymousDelegate.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("anonymousInitializer.kt")
|
||||
public void testAnonymousInitializer() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/anonymousInitializer.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("comments.kt")
|
||||
public void testComments() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/comments.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("commentsRemoved.kt")
|
||||
public void testCommentsRemoved() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/commentsRemoved.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("cyrillicClassName.kt")
|
||||
public void testCyrillicClassName() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/cyrillicClassName.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("dataClass.kt")
|
||||
public void testDataClass() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/dataClass.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("defaultImpls.kt")
|
||||
public void testDefaultImpls() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/defaultImpls.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("defaultPackage.kt")
|
||||
public void testDefaultPackage() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/defaultPackage.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("defaultPackageCorrectErrorTypes.kt")
|
||||
public void testDefaultPackageCorrectErrorTypes() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/defaultPackageCorrectErrorTypes.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("defaultParameterValueOff.kt")
|
||||
public void testDefaultParameterValueOff() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/defaultParameterValueOff.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("defaultParameterValueOn.kt")
|
||||
public void testDefaultParameterValueOn() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/defaultParameterValueOn.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("delegateCorrectErrorTypes.kt")
|
||||
public void testDelegateCorrectErrorTypes() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/delegateCorrectErrorTypes.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("deprecated.kt")
|
||||
public void testDeprecated() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/deprecated.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("enumImports.kt")
|
||||
public void testEnumImports() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/enumImports.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("enumInCompanion.kt")
|
||||
public void testEnumInCompanion() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/enumInCompanion.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("enums.kt")
|
||||
public void testEnums() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/enums.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("errorLocationMapping.kt")
|
||||
public void testErrorLocationMapping() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/errorLocationMapping.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("errorSuperclass.kt")
|
||||
public void testErrorSuperclass() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/errorSuperclass.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("errorSuperclassCorrectErrorTypes.kt")
|
||||
public void testErrorSuperclassCorrectErrorTypes() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/errorSuperclassCorrectErrorTypes.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("fileFacadeJvmName.kt")
|
||||
public void testFileFacadeJvmName() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/fileFacadeJvmName.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("functions.kt")
|
||||
public void testFunctions() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/functions.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("genericParameters.kt")
|
||||
public void testGenericParameters() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/genericParameters.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("genericRawSignatures.kt")
|
||||
public void testGenericRawSignatures() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/genericRawSignatures.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("genericSimple.kt")
|
||||
public void testGenericSimple() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/genericSimple.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("ignoredMembers.kt")
|
||||
public void testIgnoredMembers() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/ignoredMembers.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("implicitReturnTypes.kt")
|
||||
public void testImplicitReturnTypes() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/implicitReturnTypes.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("importsForErrorTypes.kt")
|
||||
public void testImportsForErrorTypes() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/importsForErrorTypes.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("importsKt22083.kt")
|
||||
public void testImportsKt22083() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/importsKt22083.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("incorrectDelegate.kt")
|
||||
public void testIncorrectDelegate() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/incorrectDelegate.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("inheritanceSimple.kt")
|
||||
public void testInheritanceSimple() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/inheritanceSimple.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("inlineClasses.kt")
|
||||
public void testInlineClasses() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/inlineClasses.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("innerClassesWithTypeParameters.kt")
|
||||
public void testInnerClassesWithTypeParameters() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/innerClassesWithTypeParameters.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("interfaceImplementation.kt")
|
||||
public void testInterfaceImplementation() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/interfaceImplementation.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("invalidFieldName.kt")
|
||||
public void testInvalidFieldName() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/invalidFieldName.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("javaKeywords.kt")
|
||||
public void testJavaKeywords() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/javaKeywords.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("javaKeywordsInPackageNames.kt")
|
||||
public void testJavaKeywordsInPackageNames() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/javaKeywordsInPackageNames.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("javadoc.kt")
|
||||
public void testJavadoc() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/javadoc.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("jvmDefaultAll.kt")
|
||||
public void testJvmDefaultAll() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/jvmDefaultAll.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("jvmDefaultAllCompatibility.kt")
|
||||
public void testJvmDefaultAllCompatibility() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/jvmDefaultAllCompatibility.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("jvmDefaultDisable.kt")
|
||||
public void testJvmDefaultDisable() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/jvmDefaultDisable.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("jvmDefaultEnable.kt")
|
||||
public void testJvmDefaultEnable() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/jvmDefaultEnable.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("jvmOverloads.kt")
|
||||
public void testJvmOverloads() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/jvmOverloads.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("jvmStatic.kt")
|
||||
public void testJvmStatic() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/jvmStatic.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("jvmStaticFieldInParent.kt")
|
||||
public void testJvmStaticFieldInParent() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/jvmStaticFieldInParent.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt14996.kt")
|
||||
public void testKt14996() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/kt14996.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt14997.kt")
|
||||
public void testKt14997() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/kt14997.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt14998.kt")
|
||||
public void testKt14998() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/kt14998.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt15145.kt")
|
||||
public void testKt15145() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/kt15145.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt17567.kt")
|
||||
public void testKt17567() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/kt17567.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt18377.kt")
|
||||
public void testKt18377() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/kt18377.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt18682.kt")
|
||||
public void testKt18682() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/kt18682.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt19700.kt")
|
||||
public void testKt19700() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/kt19700.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt19750.kt")
|
||||
public void testKt19750() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/kt19750.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt24272.kt")
|
||||
public void testKt24272() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/kt24272.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt25071.kt")
|
||||
public void testKt25071() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/kt25071.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt27126.kt")
|
||||
public void testKt27126() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/kt27126.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt28306.kt")
|
||||
public void testKt28306() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/kt28306.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt32596.kt")
|
||||
public void testKt32596() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/kt32596.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt34569.kt")
|
||||
public void testKt34569() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/kt34569.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("lazyProperty.kt")
|
||||
public void testLazyProperty() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/lazyProperty.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("leadingDollars.kt")
|
||||
public void testLeadingDollars() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/leadingDollars.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("leadingDollars2.kt")
|
||||
public void testLeadingDollars2() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/leadingDollars2.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("mapEntry.kt")
|
||||
public void testMapEntry() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/mapEntry.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("maxErrorCount.kt")
|
||||
public void testMaxErrorCount() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/maxErrorCount.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("methodParameterNames.kt")
|
||||
public void testMethodParameterNames() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/methodParameterNames.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("methodPropertySignatureClash.kt")
|
||||
public void testMethodPropertySignatureClash() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/methodPropertySignatureClash.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("modifiers.kt")
|
||||
public void testModifiers() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/modifiers.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("multifileClass.kt")
|
||||
public void testMultifileClass() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/multifileClass.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("nestedClasses.kt")
|
||||
public void testNestedClasses() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/nestedClasses.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("nestedClasses2.kt")
|
||||
public void testNestedClasses2() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/nestedClasses2.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("nestedClassesNonRootPackage.kt")
|
||||
public void testNestedClassesNonRootPackage() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/nestedClassesNonRootPackage.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("nonExistentClass.kt")
|
||||
public void testNonExistentClass() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/nonExistentClass.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("nonExistentClassTypesConversion.kt")
|
||||
public void testNonExistentClassTypesConversion() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/nonExistentClassTypesConversion.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("nonExistentClassWIthoutCorrection.kt")
|
||||
public void testNonExistentClassWIthoutCorrection() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/nonExistentClassWIthoutCorrection.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("primitiveTypes.kt")
|
||||
public void testPrimitiveTypes() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/primitiveTypes.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("properties.kt")
|
||||
public void testProperties() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/properties.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("propertyAnnotations.kt")
|
||||
public void testPropertyAnnotations() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/propertyAnnotations.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("recentlyNullable.kt")
|
||||
public void testRecentlyNullable() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/recentlyNullable.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("repeatableAnnotations.kt")
|
||||
public void testRepeatableAnnotations() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/repeatableAnnotations.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("secondaryConstructor.kt")
|
||||
public void testSecondaryConstructor() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/secondaryConstructor.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("severalPackageParts.kt")
|
||||
public void testSeveralPackageParts() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/severalPackageParts.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("strangeIdentifiers.kt")
|
||||
public void testStrangeIdentifiers() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/strangeIdentifiers.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("strangeNames.kt")
|
||||
public void testStrangeNames() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/strangeNames.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("stripMetadata.kt")
|
||||
public void testStripMetadata() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/stripMetadata.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("suspendArgName.kt")
|
||||
public void testSuspendArgName() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/suspendArgName.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("suspendErrorTypes.kt")
|
||||
public void testSuspendErrorTypes() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/suspendErrorTypes.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("topLevel.kt")
|
||||
public void testTopLevel() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/topLevel.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("unsafePropertyInitializers.kt")
|
||||
public void testUnsafePropertyInitializers() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/unsafePropertyInitializers.kt");
|
||||
+102
-10
@@ -3,513 +3,605 @@
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.kapt3.test;
|
||||
package org.jetbrains.kotlin.kapt3.test.runners;
|
||||
|
||||
import com.intellij.testFramework.TestDataPath;
|
||||
import org.jetbrains.kotlin.test.JUnit3RunnerWithInners;
|
||||
import org.jetbrains.kotlin.test.KotlinTestUtils;
|
||||
import org.jetbrains.kotlin.test.util.KtTestUtil;
|
||||
import org.jetbrains.kotlin.test.TargetBackend;
|
||||
import org.jetbrains.kotlin.test.TestMetadata;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Nested;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */
|
||||
/** This class is generated by {@link GenerateNewCompilerTests.kt}. DO NOT MODIFY MANUALLY */
|
||||
@SuppressWarnings("all")
|
||||
@TestMetadata("plugins/kapt3/kapt3-compiler/testData/converter")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public class IrClassFileToSourceStubConverterTestGenerated extends AbstractIrClassFileToSourceStubConverterTest {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("abstractEnum.kt")
|
||||
public void testAbstractEnum() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/abstractEnum.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("abstractMethods.kt")
|
||||
public void testAbstractMethods() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/abstractMethods.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("aliasedImports.kt")
|
||||
public void testAliasedImports() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/aliasedImports.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAllFilesPresentInConverter() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("plugins/kapt3/kapt3-compiler/testData/converter"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("annotationWithFqNames.kt")
|
||||
public void testAnnotationWithFqNames() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/annotationWithFqNames.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("annotations.kt")
|
||||
public void testAnnotations() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/annotations.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("annotations2.kt")
|
||||
public void testAnnotations2() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/annotations2.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("annotations3.kt")
|
||||
public void testAnnotations3() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/annotations3.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("annotationsWithConstants.kt")
|
||||
public void testAnnotationsWithConstants() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/annotationsWithConstants.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("annotationsWithTargets.kt")
|
||||
public void testAnnotationsWithTargets() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/annotationsWithTargets.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("anonymousDelegate.kt")
|
||||
public void testAnonymousDelegate() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/anonymousDelegate.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("anonymousInitializer.kt")
|
||||
public void testAnonymousInitializer() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/anonymousInitializer.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("comments.kt")
|
||||
public void testComments() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/comments.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("commentsRemoved.kt")
|
||||
public void testCommentsRemoved() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/commentsRemoved.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("cyrillicClassName.kt")
|
||||
public void testCyrillicClassName() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/cyrillicClassName.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("dataClass.kt")
|
||||
public void testDataClass() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/dataClass.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("defaultImpls.kt")
|
||||
public void testDefaultImpls() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/defaultImpls.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("defaultPackage.kt")
|
||||
public void testDefaultPackage() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/defaultPackage.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("defaultPackageCorrectErrorTypes.kt")
|
||||
public void testDefaultPackageCorrectErrorTypes() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/defaultPackageCorrectErrorTypes.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("defaultParameterValueOff.kt")
|
||||
public void testDefaultParameterValueOff() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/defaultParameterValueOff.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("defaultParameterValueOn.kt")
|
||||
public void testDefaultParameterValueOn() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/defaultParameterValueOn.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("delegateCorrectErrorTypes.kt")
|
||||
public void testDelegateCorrectErrorTypes() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/delegateCorrectErrorTypes.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("deprecated.kt")
|
||||
public void testDeprecated() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/deprecated.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("enumImports.kt")
|
||||
public void testEnumImports() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/enumImports.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("enumInCompanion.kt")
|
||||
public void testEnumInCompanion() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/enumInCompanion.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("enums.kt")
|
||||
public void testEnums() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/enums.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("errorLocationMapping.kt")
|
||||
public void testErrorLocationMapping() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/errorLocationMapping.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("errorSuperclass.kt")
|
||||
public void testErrorSuperclass() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/errorSuperclass.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("errorSuperclassCorrectErrorTypes.kt")
|
||||
public void testErrorSuperclassCorrectErrorTypes() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/errorSuperclassCorrectErrorTypes.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("fileFacadeJvmName.kt")
|
||||
public void testFileFacadeJvmName() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/fileFacadeJvmName.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("functions.kt")
|
||||
public void testFunctions() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/functions.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("genericParameters.kt")
|
||||
public void testGenericParameters() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/genericParameters.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("genericRawSignatures.kt")
|
||||
public void testGenericRawSignatures() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/genericRawSignatures.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("genericSimple.kt")
|
||||
public void testGenericSimple() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/genericSimple.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("ignoredMembers.kt")
|
||||
public void testIgnoredMembers() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/ignoredMembers.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("implicitReturnTypes.kt")
|
||||
public void testImplicitReturnTypes() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/implicitReturnTypes.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("importsForErrorTypes.kt")
|
||||
public void testImportsForErrorTypes() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/importsForErrorTypes.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("importsKt22083.kt")
|
||||
public void testImportsKt22083() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/importsKt22083.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("incorrectDelegate.kt")
|
||||
public void testIncorrectDelegate() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/incorrectDelegate.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("inheritanceSimple.kt")
|
||||
public void testInheritanceSimple() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/inheritanceSimple.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("inlineClasses.kt")
|
||||
public void testInlineClasses() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/inlineClasses.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("innerClassesWithTypeParameters.kt")
|
||||
public void testInnerClassesWithTypeParameters() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/innerClassesWithTypeParameters.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("interfaceImplementation.kt")
|
||||
public void testInterfaceImplementation() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/interfaceImplementation.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("invalidFieldName.kt")
|
||||
public void testInvalidFieldName() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/invalidFieldName.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("javaKeywords.kt")
|
||||
public void testJavaKeywords() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/javaKeywords.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("javaKeywordsInPackageNames.kt")
|
||||
public void testJavaKeywordsInPackageNames() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/javaKeywordsInPackageNames.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("javadoc.kt")
|
||||
public void testJavadoc() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/javadoc.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("jvmDefaultAll.kt")
|
||||
public void testJvmDefaultAll() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/jvmDefaultAll.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("jvmDefaultAllCompatibility.kt")
|
||||
public void testJvmDefaultAllCompatibility() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/jvmDefaultAllCompatibility.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("jvmDefaultDisable.kt")
|
||||
public void testJvmDefaultDisable() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/jvmDefaultDisable.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("jvmDefaultEnable.kt")
|
||||
public void testJvmDefaultEnable() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/jvmDefaultEnable.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("jvmOverloads.kt")
|
||||
public void testJvmOverloads() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/jvmOverloads.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("jvmStatic.kt")
|
||||
public void testJvmStatic() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/jvmStatic.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("jvmStaticFieldInParent.kt")
|
||||
public void testJvmStaticFieldInParent() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/jvmStaticFieldInParent.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt14996.kt")
|
||||
public void testKt14996() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/kt14996.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt14997.kt")
|
||||
public void testKt14997() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/kt14997.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt14998.kt")
|
||||
public void testKt14998() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/kt14998.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt15145.kt")
|
||||
public void testKt15145() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/kt15145.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt17567.kt")
|
||||
public void testKt17567() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/kt17567.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt18377.kt")
|
||||
public void testKt18377() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/kt18377.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt18682.kt")
|
||||
public void testKt18682() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/kt18682.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt19700.kt")
|
||||
public void testKt19700() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/kt19700.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt19750.kt")
|
||||
public void testKt19750() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/kt19750.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt24272.kt")
|
||||
public void testKt24272() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/kt24272.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt25071.kt")
|
||||
public void testKt25071() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/kt25071.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt27126.kt")
|
||||
public void testKt27126() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/kt27126.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt28306.kt")
|
||||
public void testKt28306() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/kt28306.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt32596.kt")
|
||||
public void testKt32596() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/kt32596.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt34569.kt")
|
||||
public void testKt34569() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/kt34569.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("lazyProperty.kt")
|
||||
public void testLazyProperty() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/lazyProperty.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("leadingDollars.kt")
|
||||
public void testLeadingDollars() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/leadingDollars.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("leadingDollars2.kt")
|
||||
public void testLeadingDollars2() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/leadingDollars2.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("mapEntry.kt")
|
||||
public void testMapEntry() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/mapEntry.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("maxErrorCount.kt")
|
||||
public void testMaxErrorCount() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/maxErrorCount.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("methodParameterNames.kt")
|
||||
public void testMethodParameterNames() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/methodParameterNames.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("methodPropertySignatureClash.kt")
|
||||
public void testMethodPropertySignatureClash() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/methodPropertySignatureClash.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("modifiers.kt")
|
||||
public void testModifiers() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/modifiers.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("multifileClass.kt")
|
||||
public void testMultifileClass() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/multifileClass.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("nestedClasses.kt")
|
||||
public void testNestedClasses() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/nestedClasses.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("nestedClasses2.kt")
|
||||
public void testNestedClasses2() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/nestedClasses2.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("nestedClassesNonRootPackage.kt")
|
||||
public void testNestedClassesNonRootPackage() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/nestedClassesNonRootPackage.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("nonExistentClass.kt")
|
||||
public void testNonExistentClass() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/nonExistentClass.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("nonExistentClassTypesConversion.kt")
|
||||
public void testNonExistentClassTypesConversion() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/nonExistentClassTypesConversion.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("nonExistentClassWIthoutCorrection.kt")
|
||||
public void testNonExistentClassWIthoutCorrection() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/nonExistentClassWIthoutCorrection.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("primitiveTypes.kt")
|
||||
public void testPrimitiveTypes() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/primitiveTypes.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("properties.kt")
|
||||
public void testProperties() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/properties.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("propertyAnnotations.kt")
|
||||
public void testPropertyAnnotations() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/propertyAnnotations.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("recentlyNullable.kt")
|
||||
public void testRecentlyNullable() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/recentlyNullable.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("repeatableAnnotations.kt")
|
||||
public void testRepeatableAnnotations() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/repeatableAnnotations.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("secondaryConstructor.kt")
|
||||
public void testSecondaryConstructor() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/secondaryConstructor.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("severalPackageParts.kt")
|
||||
public void testSeveralPackageParts() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/severalPackageParts.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("strangeIdentifiers.kt")
|
||||
public void testStrangeIdentifiers() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/strangeIdentifiers.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("strangeNames.kt")
|
||||
public void testStrangeNames() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/strangeNames.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("stripMetadata.kt")
|
||||
public void testStripMetadata() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/stripMetadata.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("suspendArgName.kt")
|
||||
public void testSuspendArgName() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/suspendArgName.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("suspendErrorTypes.kt")
|
||||
public void testSuspendErrorTypes() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/suspendErrorTypes.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("topLevel.kt")
|
||||
public void testTopLevel() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/topLevel.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("unsafePropertyInitializers.kt")
|
||||
public void testUnsafePropertyInitializers() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/unsafePropertyInitializers.kt");
|
||||
+10
-10
@@ -3,53 +3,53 @@
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.kapt3.test;
|
||||
package org.jetbrains.kotlin.kapt3.test.runners;
|
||||
|
||||
import com.intellij.testFramework.TestDataPath;
|
||||
import org.jetbrains.kotlin.test.JUnit3RunnerWithInners;
|
||||
import org.jetbrains.kotlin.test.KotlinTestUtils;
|
||||
import org.jetbrains.kotlin.test.util.KtTestUtil;
|
||||
import org.jetbrains.kotlin.test.TargetBackend;
|
||||
import org.jetbrains.kotlin.test.TestMetadata;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Nested;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */
|
||||
/** This class is generated by {@link GenerateNewCompilerTests.kt}. DO NOT MODIFY MANUALLY */
|
||||
@SuppressWarnings("all")
|
||||
@TestMetadata("plugins/kapt3/kapt3-compiler/testData/kotlinRunner")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public class IrKotlinKaptContextTestGenerated extends AbstractIrKotlinKaptContextTest {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAllFilesPresentInKotlinRunner() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("plugins/kapt3/kapt3-compiler/testData/kotlinRunner"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("DefaultParameterValues.kt")
|
||||
public void testDefaultParameterValues() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/kotlinRunner/DefaultParameterValues.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("ErrorLocationMapping.kt")
|
||||
public void testErrorLocationMapping() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/kotlinRunner/ErrorLocationMapping.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("NestedClasses.kt")
|
||||
public void testNestedClasses() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/kotlinRunner/NestedClasses.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("Overloads.kt")
|
||||
public void testOverloads() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/kotlinRunner/Overloads.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("Simple.kt")
|
||||
public void testSimple() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/kotlinRunner/Simple.kt");
|
||||
+14
-11
@@ -3,52 +3,55 @@
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.kapt3.test;
|
||||
package org.jetbrains.kotlin.kapt3.test.runners;
|
||||
|
||||
import com.intellij.testFramework.TestDataPath;
|
||||
import org.jetbrains.kotlin.test.JUnit3RunnerWithInners;
|
||||
import org.jetbrains.kotlin.test.KotlinTestUtils;
|
||||
import org.jetbrains.kotlin.test.util.KtTestUtil;
|
||||
import org.junit.jupiter.api.Tag;
|
||||
import org.jetbrains.kotlin.test.TargetBackend;
|
||||
import org.jetbrains.kotlin.test.TestMetadata;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Nested;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */
|
||||
/** This class is generated by {@link GenerateNewCompilerTests.kt}. DO NOT MODIFY MANUALLY */
|
||||
@SuppressWarnings("all")
|
||||
@TestMetadata("plugins/kapt3/kapt3-compiler/testData/kotlinRunner")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
@Tag("IgnoreJDK11")
|
||||
public class KotlinKaptContextTestGenerated extends AbstractKotlinKaptContextTest {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAllFilesPresentInKotlinRunner() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("plugins/kapt3/kapt3-compiler/testData/kotlinRunner"), Pattern.compile("^(.+)\\.kt$"), null, true);
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("plugins/kapt3/kapt3-compiler/testData/kotlinRunner"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("DefaultParameterValues.kt")
|
||||
public void testDefaultParameterValues() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/kotlinRunner/DefaultParameterValues.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("ErrorLocationMapping.kt")
|
||||
public void testErrorLocationMapping() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/kotlinRunner/ErrorLocationMapping.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("NestedClasses.kt")
|
||||
public void testNestedClasses() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/kotlinRunner/NestedClasses.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("Overloads.kt")
|
||||
public void testOverloads() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/kotlinRunner/Overloads.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("Simple.kt")
|
||||
public void testSimple() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/kotlinRunner/Simple.kt");
|
||||
Reference in New Issue
Block a user