diff --git a/compiler/testData/diagnostics/testsWithStdLib/builderInference/typeVariableShouldNotBeFixed.fail b/compiler/testData/diagnostics/testsWithStdLib/builderInference/typeVariableShouldNotBeFixed.fail new file mode 100644 index 00000000000..4bb26c11caf --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/builderInference/typeVariableShouldNotBeFixed.fail @@ -0,0 +1 @@ +java.lang.AssertionError: Lower bound CapturedType(in (Model..Model?)) of a flexible type must be a subtype of the upper bound CapturedType(in (Model..Model?))? \ No newline at end of file diff --git a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/frontend/AbstractFailingTestSuppressor.kt b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/frontend/AbstractFailingTestSuppressor.kt new file mode 100644 index 00000000000..1e95bdc4e00 --- /dev/null +++ b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/frontend/AbstractFailingTestSuppressor.kt @@ -0,0 +1,30 @@ +/* + * Copyright 2010-2022 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.test.frontend + +import org.jetbrains.kotlin.test.WrappedException +import org.jetbrains.kotlin.test.model.AfterAnalysisChecker +import org.jetbrains.kotlin.test.services.TestServices +import java.io.File + +abstract class AbstractFailingTestSuppressor(testServices: TestServices) : AfterAnalysisChecker(testServices) { + + protected abstract fun testFile(): File + + protected abstract fun hasFail(failedAssertions: List): Boolean + + override fun suppressIfNeeded(failedAssertions: List): List { + val failFile = testFile().parentFile.resolve("${testFile().nameWithoutExtension}.fail").takeIf { it.exists() } + ?: return failedAssertions + val failReason = failFile.readText().trim() + if (hasFail(failedAssertions) || failReason == INCONSISTENT_DIAGNOSTICS) return emptyList() + return failedAssertions + AssertionError("Fail file exists but no exception was thrown. Please remove ${failFile.name}").wrap() + } + + companion object { + const val INCONSISTENT_DIAGNOSTICS = "INCONSISTENT_DIAGNOSTICS" + } +} diff --git a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/frontend/classic/ClassicFrontendFailingTestSuppressor.kt b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/frontend/classic/ClassicFrontendFailingTestSuppressor.kt new file mode 100644 index 00000000000..e11b41dab94 --- /dev/null +++ b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/frontend/classic/ClassicFrontendFailingTestSuppressor.kt @@ -0,0 +1,30 @@ +/* + * Copyright 2010-2022 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.test.frontend.classic + +import org.jetbrains.kotlin.test.WrappedException +import org.jetbrains.kotlin.test.frontend.AbstractFailingTestSuppressor +import org.jetbrains.kotlin.test.model.FrontendKinds +import org.jetbrains.kotlin.test.services.TestServices +import org.jetbrains.kotlin.test.services.moduleStructure +import java.io.File + +class ClassicFrontendFailingTestSuppressor(testServices: TestServices) : AbstractFailingTestSuppressor(testServices) { + + override fun testFile(): File { + return testServices.moduleStructure.originalTestDataFiles.first() + } + + override fun hasFail(failedAssertions: List): Boolean { + return failedAssertions.any { + when (it) { + is WrappedException.FromFacade -> it.facade is ClassicFrontendFacade + is WrappedException.FromHandler -> it.handler.artifactKind == FrontendKinds.ClassicFrontend + else -> false + } + } + } +} diff --git a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/frontend/fir/FirFailingTestSuppressor.kt b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/frontend/fir/FirFailingTestSuppressor.kt index f69a60700c7..82d94b44932 100644 --- a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/frontend/fir/FirFailingTestSuppressor.kt +++ b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/frontend/fir/FirFailingTestSuppressor.kt @@ -6,30 +6,26 @@ package org.jetbrains.kotlin.test.frontend.fir import org.jetbrains.kotlin.test.WrappedException -import org.jetbrains.kotlin.test.model.AfterAnalysisChecker +import org.jetbrains.kotlin.test.frontend.AbstractFailingTestSuppressor import org.jetbrains.kotlin.test.model.FrontendKinds import org.jetbrains.kotlin.test.services.TestServices import org.jetbrains.kotlin.test.services.moduleStructure import org.jetbrains.kotlin.test.utils.firTestDataFile +import java.io.File -class FirFailingTestSuppressor(testServices: TestServices) : AfterAnalysisChecker(testServices) { - override fun suppressIfNeeded(failedAssertions: List): List { - val testFile = testServices.moduleStructure.originalTestDataFiles.first().firTestDataFile - val failFile = testFile.parentFile.resolve("${testFile.nameWithoutExtension}.fail").takeIf { it.exists() } - ?: return failedAssertions - val failReason = failFile.readText().trim() - val hasFail = failedAssertions.any { +class FirFailingTestSuppressor(testServices: TestServices) : AbstractFailingTestSuppressor(testServices) { + + override fun testFile(): File { + return testServices.moduleStructure.originalTestDataFiles.first().firTestDataFile + } + + override fun hasFail(failedAssertions: List): Boolean { + return failedAssertions.any { when (it) { is WrappedException.FromFacade -> it.facade is FirFrontendFacade is WrappedException.FromHandler -> it.handler.artifactKind == FrontendKinds.FIR else -> false } } - if (hasFail || failReason == INCONSISTENT_DIAGNOSTICS) return emptyList() - return failedAssertions + AssertionError("Fail file exists but no exception was thrown. Please remove ${failFile.name}").wrap() - } - - companion object { - const val INCONSISTENT_DIAGNOSTICS = "INCONSISTENT_DIAGNOSTICS" } } diff --git a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/runners/AbstractDiagnosticTest.kt b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/runners/AbstractDiagnosticTest.kt index 4113f047f19..453391501cf 100644 --- a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/runners/AbstractDiagnosticTest.kt +++ b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/runners/AbstractDiagnosticTest.kt @@ -21,6 +21,7 @@ import org.jetbrains.kotlin.test.directives.JvmEnvironmentConfigurationDirective import org.jetbrains.kotlin.test.directives.LanguageSettingsDirectives.EXPLICIT_API_MODE import org.jetbrains.kotlin.test.directives.LanguageSettingsDirectives.LANGUAGE import org.jetbrains.kotlin.test.directives.LanguageSettingsDirectives.OPT_IN +import org.jetbrains.kotlin.test.frontend.classic.ClassicFrontendFailingTestSuppressor import org.jetbrains.kotlin.test.frontend.classic.handlers.* import org.jetbrains.kotlin.test.model.DependencyKind import org.jetbrains.kotlin.test.model.FrontendKinds @@ -82,7 +83,10 @@ abstract class AbstractDiagnosticTest : AbstractKotlinCompilerTest() { ) } - useAfterAnalysisCheckers(::FirTestDataConsistencyHandler) + useAfterAnalysisCheckers( + ::FirTestDataConsistencyHandler, + ::ClassicFrontendFailingTestSuppressor + ) forTestsMatching("compiler/testData/diagnostics/testsWithStdLib/*") { defaultDirectives {