diff --git a/plugins/kapt3/kapt3-compiler/test/org/jetbrains/kotlin/kapt3/test/AbstractIrKotlinKapt3IntegrationTest.kt b/plugins/kapt3/kapt3-compiler/test/org/jetbrains/kotlin/kapt3/test/AbstractIrKotlinKapt3IntegrationTest.kt new file mode 100644 index 00000000000..e69050af03b --- /dev/null +++ b/plugins/kapt3/kapt3-compiler/test/org/jetbrains/kotlin/kapt3/test/AbstractIrKotlinKapt3IntegrationTest.kt @@ -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 +} \ No newline at end of file diff --git a/plugins/kapt3/kapt3-compiler/test/org/jetbrains/kotlin/kapt3/test/AbstractKotlinKapt3IntegrationTest.kt b/plugins/kapt3/kapt3-compiler/test/org/jetbrains/kotlin/kapt3/test/AbstractKotlinKapt3IntegrationTest.kt index cff7662c3e3..4419edb3d10 100644 --- a/plugins/kapt3/kapt3-compiler/test/org/jetbrains/kotlin/kapt3/test/AbstractKotlinKapt3IntegrationTest.kt +++ b/plugins/kapt3/kapt3-compiler/test/org/jetbrains/kotlin/kapt3/test/AbstractKotlinKapt3IntegrationTest.kt @@ -168,8 +168,8 @@ abstract class AbstractKotlinKapt3IntegrationTest : CodegenTestCase() { } } - protected class Kapt3ExtensionForTests(options: KaptOptions, private val processors: List) : AbstractKapt3Extension( - options, MessageCollectorBackedKaptLogger(options), compilerConfiguration = CompilerConfiguration.EMPTY + protected inner class Kapt3ExtensionForTests(options: KaptOptions, private val processors: List) : AbstractKapt3Extension( + options, MessageCollectorBackedKaptLogger(options), compilerConfiguration = myEnvironment.configuration ) { internal var savedStubs: String? = null internal var savedBindings: Map? = null diff --git a/plugins/kapt3/kapt3-compiler/test/org/jetbrains/kotlin/kapt3/test/IrKotlinKapt3IntegrationTests.kt b/plugins/kapt3/kapt3-compiler/test/org/jetbrains/kotlin/kapt3/test/IrKotlinKapt3IntegrationTests.kt new file mode 100644 index 00000000000..b03d287f405 --- /dev/null +++ b/plugins/kapt3/kapt3-compiler/test/org/jetbrains/kotlin/kapt3/test/IrKotlinKapt3IntegrationTests.kt @@ -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, + process: (Set, 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()) + } + +} \ No newline at end of file