[Test] Migrate all jvm tests runners for boxInline tests

This commit is contained in:
Dmitriy Novozhilov
2021-01-27 12:07:06 +03:00
parent 8973e3f362
commit 3a0eee64b8
25 changed files with 7119 additions and 3499 deletions
@@ -42,3 +42,8 @@ abstract class TestConfiguration {
abstract fun getAllHandlers(): List<AnalysisHandler<*>>
}
// ---------------------------- Utils ----------------------------
fun <T, R> ((TestServices, T) -> R).bind(value: T): Constructor<R> {
return { this.invoke(it, value) }
}
@@ -35,11 +35,17 @@ class TestRunner(private val testConfiguration: TestConfiguration) {
configurator.transformTestDataPath(fileName)
}
val moduleStructure = testConfiguration.moduleStructureExtractor.splitTestDataByModules(
testDataFileName,
testConfiguration.directives,
).also {
services.register(TestModuleStructure::class, it)
val moduleStructure = try {
testConfiguration.moduleStructureExtractor.splitTestDataByModules(
testDataFileName,
testConfiguration.directives,
).also {
services.register(TestModuleStructure::class, it)
}
} catch (e: ExceptionFromModuleStructureTransformer) {
services.register(TestModuleStructure::class, e.alreadyParsedModuleStructure)
val exception = filterFailedExceptions(listOf(e.cause)).singleOrNull() ?: return
throw exception
}
testConfiguration.metaTestConfigurators.forEach {
@@ -84,15 +90,17 @@ class TestRunner(private val testConfiguration: TestConfiguration) {
}
}
val filteredFailedAssertions = testConfiguration.afterAnalysisCheckers
.fold<AfterAnalysisChecker, List<Throwable>>(failedAssertions) { assertions, checker ->
checker.suppressIfNeeded(assertions)
}
.map { if (it is ExceptionFromTestError) it.cause else it }
val filteredFailedAssertions = filterFailedExceptions(failedAssertions)
services.assertions.assertAll(filteredFailedAssertions)
}
private fun filterFailedExceptions(failedExceptions: List<Throwable>): List<Throwable> = testConfiguration.afterAnalysisCheckers
.fold(failedExceptions) { assertions, checker ->
checker.suppressIfNeeded(assertions)
}
.map { if (it is ExceptionFromTestError) it.cause else it }
private fun processModule(
services: TestServices,
module: TestModule,
@@ -11,3 +11,8 @@ import org.jetbrains.kotlin.test.TestInfrastructureInternals
abstract class ModuleStructureTransformer {
abstract fun transformModuleStructure(moduleStructure: TestModuleStructure): TestModuleStructure
}
class ExceptionFromModuleStructureTransformer(
override val cause: Throwable,
val alreadyParsedModuleStructure: TestModuleStructure
) : Exception(cause)