[LL FIR] separate non-reversed/reversed test suppressors
Each compiler-based LL FIR test can: - fail in both non-reversed and reversed configurations, muted with `// MUTE_LL_FIR` - fail in non-reversed test only, muted with `// IGNORE_NON_REVERSED_RESOLVE` - fail in reversed test only, muted with `// IGNORE_REVERSED_RESOLVE`
This commit is contained in:
committed by
Space Team
parent
f26300a43e
commit
a4564351d7
+81
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
* Copyright 2010-2023 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.analysis.low.level.api.fir
|
||||
|
||||
import org.jetbrains.kotlin.test.WrappedException
|
||||
import org.jetbrains.kotlin.test.directives.model.DirectivesContainer
|
||||
import org.jetbrains.kotlin.test.directives.model.SimpleDirectivesContainer
|
||||
import org.jetbrains.kotlin.test.directives.model.StringDirective
|
||||
import org.jetbrains.kotlin.test.model.AfterAnalysisChecker
|
||||
import org.jetbrains.kotlin.test.services.TestServices
|
||||
import org.jetbrains.kotlin.test.services.moduleStructure
|
||||
|
||||
abstract class TestByDirectiveSuppressor(
|
||||
val suppressDirective: StringDirective,
|
||||
directivesContainer: DirectivesContainer,
|
||||
testServices: TestServices,
|
||||
) : AfterAnalysisChecker(testServices) {
|
||||
init {
|
||||
require(suppressDirective in directivesContainer)
|
||||
}
|
||||
|
||||
override val directiveContainers: List<DirectivesContainer> = listOf(directivesContainer)
|
||||
|
||||
override fun suppressIfNeeded(failedAssertions: List<WrappedException>): List<WrappedException> {
|
||||
if (!isDisabled()) {
|
||||
return failedAssertions
|
||||
}
|
||||
|
||||
return if (failedAssertions.isEmpty()) {
|
||||
listOf(
|
||||
AssertionError(
|
||||
"Test contains $suppressDirective directive but no errors was reported. Please remove directive",
|
||||
).wrap()
|
||||
)
|
||||
} else {
|
||||
emptyList()
|
||||
}
|
||||
}
|
||||
|
||||
private fun isDisabled(): Boolean = suppressDirective in testServices.moduleStructure.allDirectives
|
||||
}
|
||||
|
||||
class LLFirTestSuppressor(
|
||||
testServices: TestServices,
|
||||
) : TestByDirectiveSuppressor(
|
||||
suppressDirective = Directives.MUTE_LL_FIR,
|
||||
directivesContainer = Directives,
|
||||
testServices
|
||||
) {
|
||||
|
||||
private object Directives : SimpleDirectivesContainer() {
|
||||
val MUTE_LL_FIR by stringDirective("Temporary mute Low Level FIR implementation due to some error. YT ticket must be provided")
|
||||
}
|
||||
}
|
||||
|
||||
class LLFirOnlyReversedTestSuppressor(
|
||||
testServices: TestServices,
|
||||
) : TestByDirectiveSuppressor(
|
||||
suppressDirective = Directives.IGNORE_REVERSED_RESOLVE,
|
||||
directivesContainer = Directives,
|
||||
testServices
|
||||
) {
|
||||
private object Directives : SimpleDirectivesContainer() {
|
||||
val IGNORE_REVERSED_RESOLVE by stringDirective("Temporary disables reversed resolve checks until the issue is fixed. YT ticket must be provided")
|
||||
}
|
||||
}
|
||||
|
||||
class LLFirOnlyNonReversedTestSuppressor(
|
||||
testServices: TestServices,
|
||||
) : TestByDirectiveSuppressor(
|
||||
suppressDirective = Directives.IGNORE_NON_REVERSED_RESOLVE,
|
||||
directivesContainer = Directives,
|
||||
testServices
|
||||
) {
|
||||
private object Directives : SimpleDirectivesContainer() {
|
||||
val IGNORE_NON_REVERSED_RESOLVE by stringDirective("Temporary disables non-reversed resolve checks until the issue is fixed. YT ticket must be provided")
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -7,9 +7,9 @@ package org.jetbrains.kotlin.analysis.low.level.api.fir.compiler.based
|
||||
|
||||
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.LLFirResolveSessionService
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.LLFirTestSuppressor
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.api.DiagnosticCheckerFilter
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.api.getOrBuildFirFile
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.diagnostic.compiler.based.LLFirCompiledBasedTestSuppressor
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.diagnostic.compiler.based.facades.LLFirAnalyzerFacadeFactory
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.test.base.FirLowLevelCompilerBasedTestConfigurator
|
||||
import org.jetbrains.kotlin.analysis.project.structure.KtModule
|
||||
@@ -60,7 +60,7 @@ abstract class AbstractCompilerBasedTestForFir : AbstractCompilerBasedTest() {
|
||||
useMetaTestConfigurators(::LLFirMetaTestConfigurator)
|
||||
useAfterAnalysisCheckers(::LLFirIdenticalChecker)
|
||||
useAfterAnalysisCheckers(::LLFirDivergenceCommentChecker)
|
||||
useAfterAnalysisCheckers(::LLFirCompiledBasedTestSuppressor)
|
||||
useAfterAnalysisCheckers(::LLFirTestSuppressor)
|
||||
}
|
||||
|
||||
open fun TestConfigurationBuilder.configureTest() {}
|
||||
|
||||
+4
@@ -5,6 +5,9 @@
|
||||
|
||||
package org.jetbrains.kotlin.analysis.low.level.api.fir.diagnostic.compiler.based
|
||||
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.LLFirOnlyNonReversedTestSuppressor
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.LLFirOnlyReversedTestSuppressor
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.LLFirTestSuppressor
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.diagnostic.compiler.based.facades.LLFirAnalyzerFacadeFactoryWithoutPreresolve
|
||||
import org.jetbrains.kotlin.test.bind
|
||||
import org.jetbrains.kotlin.test.builders.TestConfigurationBuilder
|
||||
@@ -13,5 +16,6 @@ abstract class AbstractLLFirBlackBoxCodegenBasedTest : AbstractLLFirBlackBoxCode
|
||||
override fun TestConfigurationBuilder.configureTest() {
|
||||
facadeStep(::LowLevelFirFrontendFacade.bind(LLFirAnalyzerFacadeFactoryWithoutPreresolve))
|
||||
baseConfiguration()
|
||||
useAfterAnalysisCheckers(::LLFirOnlyNonReversedTestSuppressor)
|
||||
}
|
||||
}
|
||||
|
||||
+2
-1
@@ -5,6 +5,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.analysis.low.level.api.fir.diagnostic.compiler.based
|
||||
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.LLFirOnlyReversedTestSuppressor
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.compiler.based.AbstractCompilerBasedTestForFir
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.diagnostic.compiler.based.facades.LLFirAnalyzerFacadeFactoryWithPreresolveInReversedOrder
|
||||
import org.jetbrains.kotlin.test.bind
|
||||
@@ -17,7 +18,7 @@ abstract class AbstractLLFirPreresolvedReversedDiagnosticCompilerTestDataSpecTes
|
||||
frontendFacade = ::LowLevelFirFrontendFacade.bind(LLFirAnalyzerFacadeFactoryWithPreresolveInReversedOrder)
|
||||
)
|
||||
baseFirSpecDiagnosticTestConfigurationForIde()
|
||||
useAfterAnalysisCheckers(::FirReversedSuppressor)
|
||||
useAfterAnalysisCheckers(::LLFirOnlyReversedTestSuppressor)
|
||||
useMetaTestConfigurators(::ReversedDiagnosticsConfigurator)
|
||||
useAfterAnalysisCheckers(::ReversedFirIdenticalChecker)
|
||||
}
|
||||
|
||||
+2
-26
@@ -5,6 +5,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.analysis.low.level.api.fir.diagnostic.compiler.based
|
||||
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.LLFirOnlyReversedTestSuppressor
|
||||
import java.io.File
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.compiler.based.AbstractCompilerBasedTestForFir
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.diagnostic.compiler.based.facades.LLFirAnalyzerFacadeFactoryWithPreresolveInReversedOrder
|
||||
@@ -30,7 +31,7 @@ abstract class AbstractLLFirPreresolvedReversedDiagnosticCompilerTestDataTest :
|
||||
testDataConsistencyHandler = ::ReversedFirIdenticalChecker,
|
||||
)
|
||||
|
||||
useAfterAnalysisCheckers(::FirReversedSuppressor)
|
||||
useAfterAnalysisCheckers(::LLFirOnlyReversedTestSuppressor)
|
||||
useMetaTestConfigurators(::ReversedDiagnosticsConfigurator)
|
||||
}
|
||||
}
|
||||
@@ -42,31 +43,6 @@ internal class ReversedDiagnosticsConfigurator(testServices: TestServices) : Met
|
||||
}
|
||||
}
|
||||
|
||||
internal class FirReversedSuppressor(testServices: TestServices) : AfterAnalysisChecker(testServices) {
|
||||
override val directiveContainers: List<DirectivesContainer> get() = listOf(Companion)
|
||||
|
||||
override fun suppressIfNeeded(failedAssertions: List<WrappedException>): List<WrappedException> {
|
||||
if (!isDisabled()) {
|
||||
return failedAssertions
|
||||
}
|
||||
|
||||
return if (failedAssertions.isEmpty()) {
|
||||
listOf(
|
||||
AssertionError(
|
||||
"Test contains $IGNORE_REVERSED_RESOLVE directive but no errors was reported. Please remove directive",
|
||||
).wrap()
|
||||
)
|
||||
} else {
|
||||
emptyList()
|
||||
}
|
||||
}
|
||||
|
||||
private fun isDisabled(): Boolean = IGNORE_REVERSED_RESOLVE in testServices.moduleStructure.allDirectives
|
||||
|
||||
companion object : SimpleDirectivesContainer() {
|
||||
val IGNORE_REVERSED_RESOLVE by directive("Temporary disables reversed resolve checks until the issue is fixed")
|
||||
}
|
||||
}
|
||||
|
||||
class ReversedFirIdenticalChecker(testServices: TestServices) : AbstractFirIdenticalChecker(testServices) {
|
||||
override fun checkTestDataFile(testDataFile: File) {
|
||||
|
||||
+2
-1
@@ -5,6 +5,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.analysis.low.level.api.fir.diagnostic.compiler.based
|
||||
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.LLFirOnlyReversedTestSuppressor
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.diagnostic.compiler.based.facades.LLFirAnalyzerFacadeFactoryWithPreresolveInReversedOrder
|
||||
import org.jetbrains.kotlin.test.bind
|
||||
import org.jetbrains.kotlin.test.builders.TestConfigurationBuilder
|
||||
@@ -13,6 +14,6 @@ abstract class AbstractLLFirReversedBlackBoxCodegenBasedTest : AbstractLLFirBlac
|
||||
override fun TestConfigurationBuilder.configureTest() {
|
||||
facadeStep(::LowLevelFirFrontendFacade.bind(LLFirAnalyzerFacadeFactoryWithPreresolveInReversedOrder))
|
||||
baseConfiguration()
|
||||
useAfterAnalysisCheckers(::FirReversedSuppressor)
|
||||
useAfterAnalysisCheckers(::LLFirOnlyReversedTestSuppressor)
|
||||
}
|
||||
}
|
||||
|
||||
-37
@@ -1,37 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2023 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.analysis.low.level.api.fir.diagnostic.compiler.based
|
||||
|
||||
import org.jetbrains.kotlin.test.WrappedException
|
||||
import org.jetbrains.kotlin.test.directives.model.DirectivesContainer
|
||||
import org.jetbrains.kotlin.test.directives.model.SimpleDirectivesContainer
|
||||
import org.jetbrains.kotlin.test.model.AfterAnalysisChecker
|
||||
import org.jetbrains.kotlin.test.services.TestServices
|
||||
import org.jetbrains.kotlin.test.services.moduleStructure
|
||||
|
||||
class LLFirCompiledBasedTestSuppressor(testServices: TestServices) : AfterAnalysisChecker(testServices) {
|
||||
override val directiveContainers: List<DirectivesContainer> get() = listOf(Companion)
|
||||
|
||||
override fun suppressIfNeeded(failedAssertions: List<WrappedException>): List<WrappedException> {
|
||||
if (MUTE_LL_FIR !in testServices.moduleStructure.allDirectives) return failedAssertions
|
||||
|
||||
return if (failedAssertions.isEmpty()) {
|
||||
listOf(
|
||||
AssertionError(
|
||||
"Test contains $MUTE_LL_FIR directive but no errors was reported. Please remove directive",
|
||||
).wrap()
|
||||
)
|
||||
} else {
|
||||
emptyList()
|
||||
}
|
||||
}
|
||||
|
||||
private companion object : SimpleDirectivesContainer() {
|
||||
val MUTE_LL_FIR by stringDirective(
|
||||
"Temporary mute Low Level FIR implementation due to some error. YT ticket must be provided"
|
||||
)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user