[KAPT] Migrate kapt tests to new test infrastructure

This commit is contained in:
Dmitriy Novozhilov
2022-07-06 17:53:11 +03:00
committed by teamcity
parent fdf1b8b1c0
commit 9c41e75802
61 changed files with 1474 additions and 1133 deletions
@@ -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)
}
@@ -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
)
)
@@ -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 }
@@ -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) }
}