FIR IDE: add tests based on compiler spec tests for ide

This commit is contained in:
Ilya Kirillov
2021-05-27 17:47:02 +02:00
parent a8a31231f7
commit 335a2d7b71
6 changed files with 69 additions and 22 deletions
@@ -6,6 +6,7 @@
package org.jetbrains.kotlin.idea.fir.low.level.api.compiler.based
import org.jetbrains.kotlin.test.WrappedException
import org.jetbrains.kotlin.test.builders.TestConfigurationBuilder
import org.jetbrains.kotlin.test.model.AfterAnalysisChecker
import org.jetbrains.kotlin.test.directives.FirDiagnosticsDirectives
import org.jetbrains.kotlin.test.services.TestServices
@@ -58,4 +59,16 @@ class IdeTestIgnoreHandler(testServices: TestServices) : AfterAnalysisChecker(te
}
}
fun TestConfigurationBuilder.addIdeTestIgnoreHandler() {
/* IdeTestIgnoreHandler should be executed after FirFailingTestSuppressor,
otherwise IdeTestIgnoreHandler will suppress exceptions and FirFailingTestSuppressor will throw error
saying that file .fir.fail exists but test passes
*/
forTestsMatching("*") {
useAfterAnalysisCheckers(
::IdeTestIgnoreHandler
)
}
}
class TestWithFirIdeIgnoreAnnotationPassesException(override val message: String) : IllegalStateException()
@@ -0,0 +1,21 @@
/*
* Copyright 2010-2021 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.idea.fir.low.level.api.diagnostic.compiler.based
import org.jetbrains.kotlin.idea.fir.low.level.api.compiler.based.AbstractCompilerBasedTest
import org.jetbrains.kotlin.test.builders.TestConfigurationBuilder
import org.jetbrains.kotlin.test.runners.baseFirDiagnosticTestConfiguration
import org.jetbrains.kotlin.idea.fir.low.level.api.compiler.based.IdeTestIgnoreHandler
import org.jetbrains.kotlin.idea.fir.low.level.api.compiler.based.addIdeTestIgnoreHandler
import org.jetbrains.kotlin.test.runners.baseFirSpecDiagnosticTestConfiguration
abstract class AbstractDiagnosisCompilerTestDataSpecTest : AbstractCompilerBasedTest() {
override fun TestConfigurationBuilder.configureTest() {
baseFirDiagnosticTestConfiguration()
baseFirSpecDiagnosticTestConfiguration()
addIdeTestIgnoreHandler()
}
}
@@ -9,18 +9,11 @@ import org.jetbrains.kotlin.idea.fir.low.level.api.compiler.based.AbstractCompil
import org.jetbrains.kotlin.test.builders.TestConfigurationBuilder
import org.jetbrains.kotlin.test.runners.baseFirDiagnosticTestConfiguration
import org.jetbrains.kotlin.idea.fir.low.level.api.compiler.based.IdeTestIgnoreHandler
import org.jetbrains.kotlin.idea.fir.low.level.api.compiler.based.addIdeTestIgnoreHandler
abstract class AbstractDiagnosisCompilerTestDataTest : AbstractCompilerBasedTest() {
override fun TestConfigurationBuilder.configureTest() {
baseFirDiagnosticTestConfiguration()
/* IdeTestIgnoreHandler should be executed after FirFailingTestSuppressor,
otherwise IdeTestIgnoreHandler will suppress exceptions and FirFailingTestSuppressor will throw error
saying that file .fir.fail exists but test passes
*/
forTestsMatching("*") {
useAfterAnalysisCheckers(
::IdeTestIgnoreHandler
)
}
addIdeTestIgnoreHandler()
}
}