[Test] Introduce directive for ignoring codegen tests for FIR with LT
^KT-56757
This commit is contained in:
committed by
Space Team
parent
9ee60e4648
commit
f47040696e
+22
-10
@@ -9,7 +9,7 @@ import org.jetbrains.kotlin.test.TargetBackend
|
|||||||
import org.jetbrains.kotlin.test.WrappedException
|
import org.jetbrains.kotlin.test.WrappedException
|
||||||
import org.jetbrains.kotlin.test.bind
|
import org.jetbrains.kotlin.test.bind
|
||||||
import org.jetbrains.kotlin.test.directives.CodegenTestDirectives
|
import org.jetbrains.kotlin.test.directives.CodegenTestDirectives
|
||||||
import org.jetbrains.kotlin.test.directives.extractIgnoredDirectiveForTargetBackend
|
import org.jetbrains.kotlin.test.directives.extractIgnoredDirectivesForTargetBackend
|
||||||
import org.jetbrains.kotlin.test.directives.model.DirectivesContainer
|
import org.jetbrains.kotlin.test.directives.model.DirectivesContainer
|
||||||
import org.jetbrains.kotlin.test.directives.model.ValueDirective
|
import org.jetbrains.kotlin.test.directives.model.ValueDirective
|
||||||
import org.jetbrains.kotlin.test.model.AfterAnalysisChecker
|
import org.jetbrains.kotlin.test.model.AfterAnalysisChecker
|
||||||
@@ -26,15 +26,19 @@ class BlackBoxCodegenSuppressor(
|
|||||||
override val additionalServices: List<ServiceRegistrationData>
|
override val additionalServices: List<ServiceRegistrationData>
|
||||||
get() = listOf(service(::SuppressionChecker.bind(customIgnoreDirective)))
|
get() = listOf(service(::SuppressionChecker.bind(customIgnoreDirective)))
|
||||||
|
|
||||||
@OptIn(ExperimentalStdlibApi::class)
|
|
||||||
override fun suppressIfNeeded(failedAssertions: List<WrappedException>): List<WrappedException> {
|
override fun suppressIfNeeded(failedAssertions: List<WrappedException>): List<WrappedException> {
|
||||||
val suppressionChecker = testServices.codegenSuppressionChecker
|
val suppressionChecker = testServices.codegenSuppressionChecker
|
||||||
val moduleStructure = testServices.moduleStructure
|
val moduleStructure = testServices.moduleStructure
|
||||||
val ignoreDirective = suppressionChecker.extractIgnoreDirective(moduleStructure.modules.first()) ?: return failedAssertions
|
val ignoreDirectives = suppressionChecker.extractIgnoreDirectives(moduleStructure.modules.first()) ?: return failedAssertions
|
||||||
val suppressionResult = moduleStructure.modules.map { suppressionChecker.failuresInModuleAreIgnored(it, ignoreDirective) }
|
for (ignoreDirective in ignoreDirectives) {
|
||||||
.firstOrNull { it.testMuted } ?: return failedAssertions
|
val suppressionResult = moduleStructure.modules
|
||||||
val additionalMessage = suppressionResult.matchedBackend?.let { "for $it" } ?: ""
|
.map { suppressionChecker.failuresInModuleAreIgnored(it, ignoreDirective) }
|
||||||
return processAssertions(failedAssertions, ignoreDirective, additionalMessage)
|
.firstOrNull { it.testMuted }
|
||||||
|
?: continue
|
||||||
|
val additionalMessage = suppressionResult.matchedBackend?.let { "for $it" } ?: ""
|
||||||
|
return processAssertions(failedAssertions, ignoreDirective, additionalMessage)
|
||||||
|
}
|
||||||
|
return failedAssertions
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun processAssertions(
|
private fun processAssertions(
|
||||||
@@ -58,16 +62,24 @@ class BlackBoxCodegenSuppressor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
class SuppressionChecker(val testServices: TestServices, val customIgnoreDirective: ValueDirective<TargetBackend>?) : TestService {
|
class SuppressionChecker(val testServices: TestServices, val customIgnoreDirective: ValueDirective<TargetBackend>?) : TestService {
|
||||||
fun extractIgnoreDirective(module: TestModule): ValueDirective<TargetBackend>? {
|
fun extractIgnoreDirectives(module: TestModule): List<ValueDirective<TargetBackend>>? {
|
||||||
val targetBackend = testServices.defaultsProvider.defaultTargetBackend ?: module.targetBackend ?: return null
|
val targetBackend = testServices.defaultsProvider.defaultTargetBackend ?: module.targetBackend ?: return null
|
||||||
return extractIgnoredDirectiveForTargetBackend(module, targetBackend, customIgnoreDirective)
|
return extractIgnoredDirectivesForTargetBackend(module, targetBackend, customIgnoreDirective)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun failuresInModuleAreIgnored(module: TestModule): Boolean {
|
fun failuresInModuleAreIgnored(module: TestModule): Boolean {
|
||||||
val ignoreDirective = extractIgnoreDirective(module) ?: return false
|
val ignoreDirective = extractIgnoreDirectives(module) ?: return false
|
||||||
return failuresInModuleAreIgnored(module, ignoreDirective).testMuted
|
return failuresInModuleAreIgnored(module, ignoreDirective).testMuted
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun failuresInModuleAreIgnored(module: TestModule, ignoreDirectives: List<ValueDirective<TargetBackend>>): SuppressionResult {
|
||||||
|
for (ignoreDirective in ignoreDirectives) {
|
||||||
|
val result = failuresInModuleAreIgnored(module, ignoreDirective)
|
||||||
|
if (result.testMuted) return result
|
||||||
|
}
|
||||||
|
return SuppressionResult.NO_MUTE
|
||||||
|
}
|
||||||
|
|
||||||
fun failuresInModuleAreIgnored(module: TestModule, ignoreDirective: ValueDirective<TargetBackend>): SuppressionResult {
|
fun failuresInModuleAreIgnored(module: TestModule, ignoreDirective: ValueDirective<TargetBackend>): SuppressionResult {
|
||||||
val ignoredBackends = module.directives[ignoreDirective]
|
val ignoredBackends = module.directives[ignoreDirective]
|
||||||
|
|
||||||
|
|||||||
+37
-18
@@ -32,6 +32,11 @@ object CodegenTestDirectives : SimpleDirectivesContainer() {
|
|||||||
applicability = Global
|
applicability = Global
|
||||||
)
|
)
|
||||||
|
|
||||||
|
val IGNORE_BACKEND_K2_LIGHT_TREE by enumDirective<TargetBackend>(
|
||||||
|
description = "Ignore specific backend if test uses K2 frontend in Light tree mode",
|
||||||
|
applicability = Global
|
||||||
|
)
|
||||||
|
|
||||||
val IGNORE_BACKEND_MULTI_MODULE by enumDirective<TargetBackend>(
|
val IGNORE_BACKEND_MULTI_MODULE by enumDirective<TargetBackend>(
|
||||||
description = "Ignore failures of multimodule test on target backend",
|
description = "Ignore failures of multimodule test on target backend",
|
||||||
applicability = Global
|
applicability = Global
|
||||||
@@ -191,27 +196,41 @@ object CodegenTestDirectives : SimpleDirectivesContainer() {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun extractIgnoredDirectiveForTargetBackend(
|
fun extractIgnoredDirectivesForTargetBackend(
|
||||||
module: TestModule,
|
module: TestModule,
|
||||||
targetBackend: TargetBackend,
|
targetBackend: TargetBackend,
|
||||||
customIgnoreDirective: ValueDirective<TargetBackend>? = null
|
customIgnoreDirective: ValueDirective<TargetBackend>? = null
|
||||||
): ValueDirective<TargetBackend>? =
|
): List<ValueDirective<TargetBackend>> {
|
||||||
when (module.frontendKind) {
|
val specificIgnoreDirectives = when (module.frontendKind) {
|
||||||
FrontendKinds.ClassicFrontend -> CodegenTestDirectives.IGNORE_BACKEND_K1
|
FrontendKinds.ClassicFrontend -> listOf(CodegenTestDirectives.IGNORE_BACKEND_K1)
|
||||||
FrontendKinds.FIR -> CodegenTestDirectives.IGNORE_BACKEND_K2
|
FrontendKinds.FIR -> listOfNotNull(
|
||||||
else -> null
|
CodegenTestDirectives.IGNORE_BACKEND_K2,
|
||||||
}?.let { specificIgnoreDirective ->
|
CodegenTestDirectives.IGNORE_BACKEND_K2_LIGHT_TREE.takeIf { module.directives.contains(FirDiagnosticsDirectives.USE_LIGHT_TREE) }
|
||||||
when {
|
)
|
||||||
customIgnoreDirective != null -> customIgnoreDirective
|
else -> return emptyList()
|
||||||
!module.directives.contains(specificIgnoreDirective) -> CodegenTestDirectives.IGNORE_BACKEND
|
}
|
||||||
else -> {
|
val result = specificIgnoreDirectives.mapNotNull {
|
||||||
val inCommonIgnored = module.directives[CodegenTestDirectives.IGNORE_BACKEND].let { targetBackend in it || TargetBackend.ANY in it }
|
extractIgnoredDirectiveForTargetBackendForSpecificIgnoreDirective(module, targetBackend, it, customIgnoreDirective)
|
||||||
val inSpecificIgnored = module.directives[specificIgnoreDirective].let { targetBackend in it || TargetBackend.ANY in it }
|
}
|
||||||
if (inCommonIgnored && inSpecificIgnored) {
|
return result.takeIf { it.isNotEmpty() } ?: listOf(CodegenTestDirectives.IGNORE_BACKEND)
|
||||||
throw AssertionError("Both, IGNORE_BACKEND and ${specificIgnoreDirective.name} contain target backend ${targetBackend.name}. Please remove one of them.")
|
}
|
||||||
}
|
|
||||||
if (inCommonIgnored) CodegenTestDirectives.IGNORE_BACKEND else specificIgnoreDirective
|
private fun extractIgnoredDirectiveForTargetBackendForSpecificIgnoreDirective(
|
||||||
|
module: TestModule,
|
||||||
|
targetBackend: TargetBackend,
|
||||||
|
specificIgnoreDirective: ValueDirective<TargetBackend>,
|
||||||
|
customIgnoreDirective: ValueDirective<TargetBackend>?
|
||||||
|
): ValueDirective<TargetBackend>? {
|
||||||
|
return when {
|
||||||
|
customIgnoreDirective != null -> customIgnoreDirective
|
||||||
|
!module.directives.contains(specificIgnoreDirective) -> null//CodegenTestDirectives.IGNORE_BACKEND
|
||||||
|
else -> {
|
||||||
|
val inCommonIgnored = module.directives[CodegenTestDirectives.IGNORE_BACKEND].let { targetBackend in it || TargetBackend.ANY in it }
|
||||||
|
val inSpecificIgnored = module.directives[specificIgnoreDirective].let { targetBackend in it || TargetBackend.ANY in it }
|
||||||
|
if (inCommonIgnored && inSpecificIgnored) {
|
||||||
|
throw AssertionError("Both, IGNORE_BACKEND and ${specificIgnoreDirective.name} contain target backend ${targetBackend.name}. Please remove one of them.")
|
||||||
}
|
}
|
||||||
|
if (inCommonIgnored) null else specificIgnoreDirective
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user