Add integration test for Kapt3+IR
This commit is contained in:
+19
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
* 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
|
||||
|
||||
abstract class AbstractIrKotlinKapt3IntegrationTest : AbstractKotlinKapt3IntegrationTest() {
|
||||
override fun updateConfiguration(configuration: CompilerConfiguration) {
|
||||
super.updateConfiguration(configuration)
|
||||
configuration.put(JVMConfigurationKeys.IR, true)
|
||||
}
|
||||
|
||||
override fun getBackend() = TargetBackend.JVM_IR
|
||||
}
|
||||
+2
-2
@@ -168,8 +168,8 @@ abstract class AbstractKotlinKapt3IntegrationTest : CodegenTestCase() {
|
||||
}
|
||||
}
|
||||
|
||||
protected class Kapt3ExtensionForTests(options: KaptOptions, private val processors: List<Processor>) : AbstractKapt3Extension(
|
||||
options, MessageCollectorBackedKaptLogger(options), compilerConfiguration = CompilerConfiguration.EMPTY
|
||||
protected inner class Kapt3ExtensionForTests(options: KaptOptions, private val processors: List<Processor>) : AbstractKapt3Extension(
|
||||
options, MessageCollectorBackedKaptLogger(options), compilerConfiguration = myEnvironment.configuration
|
||||
) {
|
||||
internal var savedStubs: String? = null
|
||||
internal var savedBindings: Map<String, KaptJavaFileObject>? = null
|
||||
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* 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
|
||||
|
||||
// For now, just run one simple test to make sure Kapt launches at all with IR switched on.
|
||||
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)
|
||||
|
||||
doTestWithJdk9(
|
||||
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())
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user