FIR IDE: ignore non-passing tests in compiler based tests

This commit is contained in:
Ilya Kirillov
2021-04-28 17:05:10 +02:00
parent 3503a54437
commit 09a94f3200
63 changed files with 348 additions and 11 deletions
@@ -1,3 +1,4 @@
// FIR_IDE_IGNORE
// FILE: foo/Some.java // FILE: foo/Some.java
package foo; package foo;
@@ -1,3 +1,4 @@
// FIR_IDE_IGNORE
// FILE: K1.kt // FILE: K1.kt
class KSub : J1() class KSub : J1()
@@ -1,3 +1,4 @@
// FIR_IDE_IGNORE
// FILE: K1.kt // FILE: K1.kt
class K2: J1() { class K2: J1() {
class Q : <!UNRESOLVED_REFERENCE!>Nested<!>() class Q : <!UNRESOLVED_REFERENCE!>Nested<!>()
@@ -1,3 +1,4 @@
// FIR_IDE_IGNORE
// FIR_IDENTICAL // FIR_IDENTICAL
// Error: name should present // Error: name should present
enum class<!SYNTAX!><!>(val rgb : Int) { enum class<!SYNTAX!><!>(val rgb : Int) {
@@ -1,3 +1,4 @@
// FIR_IDE_IGNORE
// !LANGUAGE: +InlineClasses, -JvmInlineValueClasses // !LANGUAGE: +InlineClasses, -JvmInlineValueClasses
// SKIP_JAVAC // SKIP_JAVAC
@@ -1,3 +1,4 @@
// FIR_IDE_IGNORE
// !LANGUAGE: +InlineClasses, -JvmInlineValueClasses // !LANGUAGE: +InlineClasses, -JvmInlineValueClasses
// SKIP_JAVAC // SKIP_JAVAC
@@ -1,3 +1,4 @@
// FIR_IDE_IGNORE
// SKIP_JAVAC // SKIP_JAVAC
// FILE: JavaClass.java // FILE: JavaClass.java
public class JavaClass { public class JavaClass {
@@ -1,3 +1,4 @@
// FIR_IDE_IGNORE
// SKIP_JAVAC // SKIP_JAVAC
// FILE: JavaClass.java // FILE: JavaClass.java
public class JavaClass { public class JavaClass {
@@ -1,3 +1,4 @@
// FIR_IDE_IGNORE
// !WITH_NEW_INFERENCE // !WITH_NEW_INFERENCE
// See KT-6271 // See KT-6271
fun foo() { fun foo() {
@@ -1,3 +1,4 @@
// FIR_IDE_IGNORE
// !WITH_NEW_INFERENCE // !WITH_NEW_INFERENCE
// See KT-6271 // See KT-6271
fun foo() { fun foo() {
@@ -1,3 +1,4 @@
// FIR_IDE_IGNORE
// !WITH_NEW_INFERENCE // !WITH_NEW_INFERENCE
fun foo() { fun foo() {
fun bar() = (fun() = bar()) fun bar() = (fun() = bar())
@@ -1,3 +1,4 @@
// FIR_IDE_IGNORE
// !WITH_NEW_INFERENCE // !WITH_NEW_INFERENCE
fun foo() { fun foo() {
fun bar() = (fun() = <!TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM!><!DEBUG_INFO_MISSING_UNRESOLVED!>bar<!>()<!>) fun bar() = (fun() = <!TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM!><!DEBUG_INFO_MISSING_UNRESOLVED!>bar<!>()<!>)
@@ -1,3 +1,4 @@
// FIR_IDE_IGNORE
// !WITH_NEW_INFERENCE // !WITH_NEW_INFERENCE
fun foo() { fun foo() {
fun bar() = { fun bar() = {
@@ -1,3 +1,4 @@
// FIR_IDE_IGNORE
// !WITH_NEW_INFERENCE // !WITH_NEW_INFERENCE
fun foo() { fun foo() {
fun bar() = { fun bar() = {
@@ -1,3 +1,4 @@
// FIR_IDE_IGNORE
// !WITH_NEW_INFERENCE // !WITH_NEW_INFERENCE
fun foo() { fun foo() {
fun bar1() = bar1() fun bar1() = bar1()
@@ -1,3 +1,4 @@
// FIR_IDE_IGNORE
// !WITH_NEW_INFERENCE // !WITH_NEW_INFERENCE
fun foo() { fun foo() {
fun bar1() = <!TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM!><!DEBUG_INFO_MISSING_UNRESOLVED!>bar1<!>()<!> fun bar1() = <!TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM!><!DEBUG_INFO_MISSING_UNRESOLVED!>bar1<!>()<!>
@@ -1,3 +1,4 @@
// FIR_IDE_IGNORE
// SKIP_JAVAC // SKIP_JAVAC
// FILE: A.java // FILE: A.java
public class A { public class A {
@@ -1,3 +1,4 @@
// FIR_IDE_IGNORE
// SKIP_JAVAC // SKIP_JAVAC
// FILE: A.java // FILE: A.java
public class A { public class A {
@@ -1,3 +1,4 @@
// FIR_IDE_IGNORE
// FIR_IDENTICAL // FIR_IDENTICAL
// FILE: a/b.java // FILE: a/b.java
package a; package a;
@@ -1,3 +1,4 @@
// FIR_IDE_IGNORE
// FIR_IDENTICAL // FIR_IDENTICAL
// FILE: foo/a/b.java // FILE: foo/a/b.java
package foo.a; package foo.a;
@@ -1,3 +1,4 @@
// FIR_IDE_IGNORE
// FIR_IDENTICAL // FIR_IDENTICAL
// FILE: a/b/c.java // FILE: a/b/c.java
package a.b; package a.b;
@@ -1,3 +1,4 @@
// FIR_IDE_IGNORE
// FIR_IDENTICAL // FIR_IDENTICAL
// FILE: a/b.java // FILE: a/b.java
package a; package a;
@@ -1,3 +1,4 @@
// FIR_IDE_IGNORE
// WITH_RUNTIME // WITH_RUNTIME
// FULL_JDK // FULL_JDK
@@ -1,3 +1,4 @@
// FIR_IDE_IGNORE
// WITH_RUNTIME // WITH_RUNTIME
// FULL_JDK // FULL_JDK
@@ -1,3 +1,4 @@
// FIR_IDE_IGNORE
// WITH_RUNTIME // WITH_RUNTIME
// FULL_JDK // FULL_JDK
@@ -1,3 +1,4 @@
// FIR_IDE_IGNORE
// WITH_RUNTIME // WITH_RUNTIME
// FULL_JDK // FULL_JDK
@@ -1,3 +1,4 @@
// FIR_IDE_IGNORE
// WITH_RUNTIME // WITH_RUNTIME
// FULL_JDK // FULL_JDK
@@ -1,3 +1,4 @@
// FIR_IDE_IGNORE
// WITH_RUNTIME // WITH_RUNTIME
// FULL_JDK // FULL_JDK
@@ -1,3 +1,4 @@
// FIR_IDE_IGNORE
// WITH_RUNTIME // WITH_RUNTIME
// FULL_JDK // FULL_JDK
@@ -1,3 +1,4 @@
// FIR_IDE_IGNORE
// WITH_RUNTIME // WITH_RUNTIME
// FULL_JDK // FULL_JDK
@@ -1,3 +1,4 @@
// FIR_IDE_IGNORE
// WITH_RUNTIME // WITH_RUNTIME
// FULL_JDK // FULL_JDK
@@ -1,3 +1,4 @@
// FIR_IDE_IGNORE
// WITH_RUNTIME // WITH_RUNTIME
// FULL_JDK // FULL_JDK
@@ -1,3 +1,4 @@
// FIR_IDE_IGNORE
// WITH_RUNTIME // WITH_RUNTIME
// FULL_JDK // FULL_JDK
@@ -1,3 +1,4 @@
// FIR_IDE_IGNORE
// WITH_RUNTIME // WITH_RUNTIME
// FULL_JDK // FULL_JDK
@@ -1,3 +1,4 @@
// FIR_IDE_IGNORE
// FILE: f1.kt // FILE: f1.kt
package test package test
@@ -1,3 +1,4 @@
// FIR_IDE_IGNORE
// FILE: f1.kt // FILE: f1.kt
package test package test
@@ -1,3 +1,4 @@
// FIR_IDE_IGNORE
// !DIAGNOSTICS: -UNUSED_PARAMETER // !DIAGNOSTICS: -UNUSED_PARAMETER
fun main(args: Array<String>) { fun main(args: Array<String>) {
fun f() = run { fun f() = run {
@@ -1,3 +1,4 @@
// FIR_IDE_IGNORE
// !DIAGNOSTICS: -UNUSED_PARAMETER // !DIAGNOSTICS: -UNUSED_PARAMETER
fun main(args: Array<String>) { fun main(args: Array<String>) {
fun f() = run { fun f() = run {
@@ -1,3 +1,4 @@
// FIR_IDE_IGNORE
// JAVAC_EXPECTED_FILE // JAVAC_EXPECTED_FILE
// FILE: KotlinFile.kt // FILE: KotlinFile.kt
fun foo(javaClass: JavaClass<String>): String { fun foo(javaClass: JavaClass<String>): String {
@@ -1,3 +1,4 @@
// FIR_IDE_IGNORE
// JAVAC_EXPECTED_FILE // JAVAC_EXPECTED_FILE
// FILE: KotlinFile.kt // FILE: KotlinFile.kt
fun foo(javaClass: JavaClass<String>): String { fun foo(javaClass: JavaClass<String>): String {
@@ -1,3 +1,4 @@
// FIR_IDE_IGNORE
// JAVAC_EXPECTED_FILE // JAVAC_EXPECTED_FILE
// FILE: KotlinFile.kt // FILE: KotlinFile.kt
fun foo(javaClass: JavaClass): String { fun foo(javaClass: JavaClass): String {
@@ -1,3 +1,4 @@
// FIR_IDE_IGNORE
// JAVAC_EXPECTED_FILE // JAVAC_EXPECTED_FILE
// FILE: KotlinFile.kt // FILE: KotlinFile.kt
fun foo(javaClass: JavaClass): String { fun foo(javaClass: JavaClass): String {
@@ -1,3 +1,4 @@
// FIR_IDE_IGNORE
// JAVAC_EXPECTED_FILE // JAVAC_EXPECTED_FILE
// FILE: KotlinFile.kt // FILE: KotlinFile.kt
fun foo(javaClass: JavaClass<Int>) { fun foo(javaClass: JavaClass<Int>) {
@@ -1,3 +1,4 @@
// FIR_IDE_IGNORE
// JAVAC_EXPECTED_FILE // JAVAC_EXPECTED_FILE
// FILE: KotlinFile.kt // FILE: KotlinFile.kt
fun foo(javaClass: JavaClass<Int>) { fun foo(javaClass: JavaClass<Int>) {
@@ -1,3 +1,4 @@
// FIR_IDE_IGNORE
// !JDK_KIND: MODIFIED_MOCK_JDK // !JDK_KIND: MODIFIED_MOCK_JDK
abstract class A : Throwable(1.0) {} abstract class A : Throwable(1.0) {}
@@ -1,3 +1,4 @@
// FIR_IDE_IGNORE
// !JDK_KIND: MODIFIED_MOCK_JDK // !JDK_KIND: MODIFIED_MOCK_JDK
abstract class A : <!DEPRECATION!>Throwable<!>(1.0) {} abstract class A : <!DEPRECATION!>Throwable<!>(1.0) {}
@@ -1,3 +1,4 @@
// FIR_IDE_IGNORE
// !API_VERSION: 1.5 // !API_VERSION: 1.5
// !LANGUAGE: -JvmRecordSupport // !LANGUAGE: -JvmRecordSupport
// SKIP_TXT // SKIP_TXT
@@ -1,3 +1,4 @@
// FIR_IDE_IGNORE
// !API_VERSION: 1.5 // !API_VERSION: 1.5
// !LANGUAGE: -JvmRecordSupport // !LANGUAGE: -JvmRecordSupport
// SKIP_TXT // SKIP_TXT
@@ -1,3 +1,4 @@
// FIR_IDE_IGNORE
// !API_VERSION: 1.5 // !API_VERSION: 1.5
// !LANGUAGE: +JvmRecordSupport // !LANGUAGE: +JvmRecordSupport
// FILE: MyRecord.java // FILE: MyRecord.java
@@ -1,3 +1,4 @@
// FIR_IDE_IGNORE
// !API_VERSION: 1.5 // !API_VERSION: 1.5
// !LANGUAGE: +JvmRecordSupport // !LANGUAGE: +JvmRecordSupport
// FILE: MyRecord.java // FILE: MyRecord.java
@@ -1,3 +1,4 @@
// FIR_IDE_IGNORE
// FILE: file1.kt // FILE: file1.kt
private class C { private class C {
companion object companion object
@@ -1,3 +1,4 @@
// FIR_IDE_IGNORE
// FILE: file1.kt // FILE: file1.kt
private class <!PACKAGE_OR_CLASSIFIER_REDECLARATION!>C<!> { private class <!PACKAGE_OR_CLASSIFIER_REDECLARATION!>C<!> {
companion object companion object
@@ -1,3 +1,4 @@
// FIR_IDE_IGNORE
// !LANGUAGE: +AllowContractsForCustomFunctions +UseReturnsEffect // !LANGUAGE: +AllowContractsForCustomFunctions +UseReturnsEffect
// !DIAGNOSTICS: -INVISIBLE_REFERENCE -INVISIBLE_MEMBER // !DIAGNOSTICS: -INVISIBLE_REFERENCE -INVISIBLE_MEMBER
// !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts // !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts
@@ -1,3 +1,4 @@
// FIR_IDE_IGNORE
// !LANGUAGE: +AllowContractsForCustomFunctions +UseReturnsEffect // !LANGUAGE: +AllowContractsForCustomFunctions +UseReturnsEffect
// !DIAGNOSTICS: -INVISIBLE_REFERENCE -INVISIBLE_MEMBER // !DIAGNOSTICS: -INVISIBLE_REFERENCE -INVISIBLE_MEMBER
// !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts // !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts
@@ -20,7 +20,6 @@ import org.jetbrains.kotlin.test.MockLibraryUtil
import org.jetbrains.kotlin.test.MockLibraryUtil.compileJavaFilesLibraryToJar import org.jetbrains.kotlin.test.MockLibraryUtil.compileJavaFilesLibraryToJar
import org.jetbrains.kotlin.test.TestJavacVersion import org.jetbrains.kotlin.test.TestJavacVersion
import org.jetbrains.kotlin.test.TestJdkKind import org.jetbrains.kotlin.test.TestJdkKind
import org.jetbrains.kotlin.test.directives.ForeignAnnotationsDirectives
import org.jetbrains.kotlin.test.directives.JvmEnvironmentConfigurationDirectives import org.jetbrains.kotlin.test.directives.JvmEnvironmentConfigurationDirectives
import org.jetbrains.kotlin.test.directives.JvmEnvironmentConfigurationDirectives.ALL_JAVA_AS_BINARY import org.jetbrains.kotlin.test.directives.JvmEnvironmentConfigurationDirectives.ALL_JAVA_AS_BINARY
import org.jetbrains.kotlin.test.directives.JvmEnvironmentConfigurationDirectives.ASSERTIONS_MODE import org.jetbrains.kotlin.test.directives.JvmEnvironmentConfigurationDirectives.ASSERTIONS_MODE
@@ -46,8 +45,6 @@ import org.jetbrains.kotlin.test.model.DependencyKind
import org.jetbrains.kotlin.test.model.TestFile import org.jetbrains.kotlin.test.model.TestFile
import org.jetbrains.kotlin.test.model.TestModule import org.jetbrains.kotlin.test.model.TestModule
import org.jetbrains.kotlin.test.services.* import org.jetbrains.kotlin.test.services.*
import org.jetbrains.kotlin.test.services.JUnit5Assertions.assertTrue
import org.jetbrains.kotlin.test.services.configuration.JvmForeignAnnotationsConfigurator.Companion.JSR_305_TEST_ANNOTATIONS_PATH
import org.jetbrains.kotlin.test.services.jvm.CompiledClassesManager import org.jetbrains.kotlin.test.services.jvm.CompiledClassesManager
import org.jetbrains.kotlin.test.services.jvm.compiledClassesManager import org.jetbrains.kotlin.test.services.jvm.compiledClassesManager
import org.jetbrains.kotlin.test.util.KtTestUtil import org.jetbrains.kotlin.test.util.KtTestUtil
@@ -56,7 +53,6 @@ import org.jetbrains.kotlin.utils.PathUtil
import org.jetbrains.kotlin.utils.addIfNotNull import org.jetbrains.kotlin.utils.addIfNotNull
import java.io.File import java.io.File
import kotlin.io.path.ExperimentalPathApi import kotlin.io.path.ExperimentalPathApi
import kotlin.io.path.createTempDirectory
class JvmEnvironmentConfigurator(testServices: TestServices) : EnvironmentConfigurator(testServices) { class JvmEnvironmentConfigurator(testServices: TestServices) : EnvironmentConfigurator(testServices) {
companion object { companion object {
@@ -100,11 +96,9 @@ class JvmEnvironmentConfigurator(testServices: TestServices) : EnvironmentConfig
} }
} }
fun getLibraryFiles(configurationKind: ConfigurationKind, directives: RegisteredDirectives): List<File> { fun getLibraryFilesExceptRealRuntime(configurationKind: ConfigurationKind, directives: RegisteredDirectives): List<File> {
val files = mutableListOf<File>() val files = mutableListOf<File>()
if (configurationKind.withRuntime) { if (configurationKind.withRuntime) {
files.add(ForTestCompileRuntime.runtimeJarForTests())
files.add(ForTestCompileRuntime.scriptRuntimeJarForTests())
files.add(ForTestCompileRuntime.kotlinTestJarForTests()) files.add(ForTestCompileRuntime.kotlinTestJarForTests())
} else if (configurationKind.withMockRuntime) { } else if (configurationKind.withMockRuntime) {
files.add(ForTestCompileRuntime.minimalRuntimeJarForTests()) files.add(ForTestCompileRuntime.minimalRuntimeJarForTests())
@@ -118,6 +112,7 @@ class JvmEnvironmentConfigurator(testServices: TestServices) : EnvironmentConfig
if (JvmEnvironmentConfigurationDirectives.STDLIB_JDK8 in directives) { if (JvmEnvironmentConfigurationDirectives.STDLIB_JDK8 in directives) {
files.add(ForTestCompileRuntime.runtimeJarForTestsWithJdk8()) files.add(ForTestCompileRuntime.runtimeJarForTestsWithJdk8())
} }
files.add(KtTestUtil.getAnnotationsJar())
return files return files
} }
} }
@@ -185,10 +180,17 @@ class JvmEnvironmentConfigurator(testServices: TestServices) : EnvironmentConfig
configuration.put(TEST_CONFIGURATION_KIND_KEY, it) configuration.put(TEST_CONFIGURATION_KIND_KEY, it)
} }
configuration.addJvmClasspathRoots(getLibraryFiles(configurationKind, module.directives)) val javaVersionToCompile = registeredDirectives[COMPILE_JAVA_USING].singleOrNull()
val javaBinaryFiles = if (ALL_JAVA_AS_BINARY !in registeredDirectives) {
module.javaFiles.filter { INCLUDE_JAVA_AS_BINARY in it.directives }
} else module.javaFiles
val useJava9ToCompileIncludedJavaFiles = javaVersionToCompile == TestJavacVersion.JAVAC_9
configuration.addJvmClasspathRoot(KtTestUtil.getAnnotationsJar()) if (configurationKind.withRuntime) {
configuration.configureStandardLibs(PathUtil.kotlinPathsForDistDirectory, K2JVMCompilerArguments().also { it.noReflect = true })
}
configuration.addJvmClasspathRoots(getLibraryFilesExceptRealRuntime(configurationKind, module.directives))
val isIr = module.targetBackend?.isIR == true val isIr = module.targetBackend?.isIR == true
configuration.put(JVMConfigurationKeys.IR, isIr) configuration.put(JVMConfigurationKeys.IR, isIr)
@@ -14,7 +14,7 @@ import java.io.File
class FirOldFrontendMetaConfigurator(testServices: TestServices) : MetaTestConfigurator(testServices) { class FirOldFrontendMetaConfigurator(testServices: TestServices) : MetaTestConfigurator(testServices) {
override fun transformTestDataPath(testDataFileName: String): String { override fun transformTestDataPath(testDataFileName: String): String {
val originalFile = File(testDataFileName) val originalFile = File(testDataFileName)
val isFirIdentical = originalFile.useLines { it.first() == "// ${FirDiagnosticsDirectives.FIR_IDENTICAL.name}" } val isFirIdentical = originalFile.useLines { lines -> lines.any { it == "// ${FirDiagnosticsDirectives.FIR_IDENTICAL.name}" } }
return if (isFirIdentical) { return if (isFirIdentical) {
testDataFileName testDataFileName
} else { } else {
@@ -5,6 +5,7 @@
package org.jetbrains.kotlin.test.utils package org.jetbrains.kotlin.test.utils
import org.jetbrains.kotlin.test.directives.model.Directive
import java.io.File import java.io.File
private const val FIR_KT = ".fir.kt" private const val FIR_KT = ".fir.kt"
@@ -44,3 +45,13 @@ fun File.withSuffixAndExtension(suffix: String, extension: String): File {
fun File.isDirectiveDefined(directive: String): Boolean = this.useLines { line -> fun File.isDirectiveDefined(directive: String): Boolean = this.useLines { line ->
line.any { it == directive } line.any { it == directive }
} }
fun File.removeDirectiveFromFile(directive: Directive) {
val directiveName = directive.name
val directiveRegexp = "^// $directiveName(:.*)?$(\n)?".toRegex(RegexOption.MULTILINE)
val text = readText()
val directiveRange = directiveRegexp.find(text)?.range
?: error("Directive $directiveName was not found in $this")
val textWithoutDirective = text.removeRange(directiveRange)
writeText(textWithoutDirective)
}
@@ -13,6 +13,7 @@ import com.intellij.openapi.roots.LanguageLevelProjectExtension
import com.intellij.serviceContainer.ComponentManagerImpl import com.intellij.serviceContainer.ComponentManagerImpl
import com.intellij.testFramework.LightProjectDescriptor import com.intellij.testFramework.LightProjectDescriptor
import org.jetbrains.kotlin.cli.jvm.compiler.MockExternalAnnotationsManager import org.jetbrains.kotlin.cli.jvm.compiler.MockExternalAnnotationsManager
import org.jetbrains.kotlin.codegen.forTestCompile.ForTestCompileRuntime
import org.jetbrains.kotlin.config.LanguageVersionSettings import org.jetbrains.kotlin.config.LanguageVersionSettings
import org.jetbrains.kotlin.idea.caches.project.IdeaModuleInfo import org.jetbrains.kotlin.idea.caches.project.IdeaModuleInfo
import org.jetbrains.kotlin.idea.caches.project.ModuleSourceInfo import org.jetbrains.kotlin.idea.caches.project.ModuleSourceInfo
@@ -181,7 +182,14 @@ abstract class AbstractCompilerBasedTest : KotlinLightCodeInsightFixtureTestCase
val configurationKind = JvmEnvironmentConfigurator.extractConfigurationKind(allDirectives) val configurationKind = JvmEnvironmentConfigurator.extractConfigurationKind(allDirectives)
val jdkKind = JvmEnvironmentConfigurator.extractJdkKind(allDirectives) val jdkKind = JvmEnvironmentConfigurator.extractJdkKind(allDirectives)
val libraryFiles = JvmEnvironmentConfigurator.getLibraryFiles(configurationKind, allDirectives) @OptIn(ExperimentalStdlibApi::class)
val libraryFiles = buildList {
if (configurationKind.withRuntime) {
add(ForTestCompileRuntime.runtimeJarForTests())
add(ForTestCompileRuntime.scriptRuntimeJarForTests())
}
addAll(JvmEnvironmentConfigurator.getLibraryFilesExceptRealRuntime(configurationKind, allDirectives))
}
return object : KotlinJdkAndLibraryProjectDescriptor(libraryFiles) { return object : KotlinJdkAndLibraryProjectDescriptor(libraryFiles) {
override fun getSdk(): Sdk = PluginTestCaseBase.jdk(jdkKind) override fun getSdk(): Sdk = PluginTestCaseBase.jdk(jdkKind)
@@ -0,0 +1,16 @@
/*
* 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.compiler.based
import org.jetbrains.kotlin.test.directives.model.SimpleDirectivesContainer
import org.jetbrains.kotlin.test.directives.model.DirectiveApplicability.Global
object FirIdeDirectives : SimpleDirectivesContainer() {
val FIR_IDE_IGNORE by directive(
description = "Test is ignored in FIR IDE",
applicability = Global
)
}
@@ -0,0 +1,60 @@
/*
* 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.compiler.based
import org.jetbrains.kotlin.test.model.AfterAnalysisChecker
import org.jetbrains.kotlin.test.directives.FirDiagnosticsDirectives
import org.jetbrains.kotlin.test.services.TestServices
import org.jetbrains.kotlin.test.directives.model.DirectivesContainer
import org.jetbrains.kotlin.test.services.moduleStructure
import org.jetbrains.kotlin.test.utils.removeDirectiveFromFile
class IdeTestIgnoreHandler(testServices: TestServices) : AfterAnalysisChecker(testServices) {
companion object {
private val isTeamCityBuild: Boolean = System.getenv("TEAMCITY_VERSION") != null
}
override val directives: List<DirectivesContainer>
get() = listOf(FirIdeDirectives)
override fun check(failedAssertions: List<Throwable>) {
if (!isFirIdeIgnoreDirectivePresent()) return
if (failedAssertions.isNotEmpty()) return
val moduleStructure = testServices.moduleStructure
val testDataFile = testServices.moduleStructure.originalTestDataFiles.first()
if (!isTeamCityBuild) {
testDataFile.removeDirectiveFromFile(FirIdeDirectives.FIR_IDE_IGNORE)
}
val message = if (isTeamCityBuild) {
"Please remove // ${FirIdeDirectives.FIR_IDE_IGNORE} from the test source"
} else {
"Removed // ${FirIdeDirectives.FIR_IDE_IGNORE} from the test source"
}
throw TestWithFirIdeIgnoreAnnotationPassesException(
"""
Test pass in FIR IDE
$message
Please re-run the test now
""".trimIndent()
)
}
override fun suppressIfNeeded(failedAssertions: List<Throwable>): List<Throwable> {
return if (isFirIdeIgnoreDirectivePresent())
failedAssertions.filterIsInstance<TestWithFirIdeIgnoreAnnotationPassesException>()
else failedAssertions
}
private fun isFirIdeIgnoreDirectivePresent(): Boolean {
val moduleStructure = testServices.moduleStructure
return FirIdeDirectives.FIR_IDE_IGNORE in moduleStructure.allDirectives
}
}
class TestWithFirIdeIgnoreAnnotationPassesException(override val message: String) : IllegalStateException()
@@ -8,9 +8,13 @@ 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.idea.fir.low.level.api.compiler.based.AbstractCompilerBasedTest
import org.jetbrains.kotlin.test.builders.TestConfigurationBuilder import org.jetbrains.kotlin.test.builders.TestConfigurationBuilder
import org.jetbrains.kotlin.test.runners.baseFirDiagnosticTestConfiguration import org.jetbrains.kotlin.test.runners.baseFirDiagnosticTestConfiguration
import org.jetbrains.kotlin.idea.fir.low.level.api.compiler.based.IdeTestIgnoreHandler
abstract class AbstractDiagnosisCompilerTestDataTest : AbstractCompilerBasedTest() { abstract class AbstractDiagnosisCompilerTestDataTest : AbstractCompilerBasedTest() {
override fun TestConfigurationBuilder.configureTest() { override fun TestConfigurationBuilder.configureTest() {
baseFirDiagnosticTestConfiguration() baseFirDiagnosticTestConfiguration()
useAfterAnalysisCheckers(
::IdeTestIgnoreHandler
)
} }
} }
@@ -2791,6 +2791,11 @@ public class DiagnosisCompilerFirTestdataTestGenerated extends AbstractDiagnosis
runTest("compiler/fir/analysis-tests/testData/resolve/problems/secondaryConstructorCfg.kt"); runTest("compiler/fir/analysis-tests/testData/resolve/problems/secondaryConstructorCfg.kt");
} }
@TestMetadata("symbolsAndDescriptors.kt")
public void testSymbolsAndDescriptors() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/problems/symbolsAndDescriptors.kt");
}
@TestMetadata("transform.kt") @TestMetadata("transform.kt")
public void testTransform() throws Exception { public void testTransform() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/problems/transform.kt"); runTest("compiler/fir/analysis-tests/testData/resolve/problems/transform.kt");
@@ -4887,6 +4887,133 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag
runTest("compiler/testData/diagnostics/tests/coroutines/callableReference/outsideSuspend.kt"); runTest("compiler/testData/diagnostics/tests/coroutines/callableReference/outsideSuspend.kt");
} }
} }
@TestMetadata("compiler/testData/diagnostics/tests/coroutines/suspendFunctionAsSupertype")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class SuspendFunctionAsSupertype extends AbstractDiagnosisCompilerTestDataTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
}
public void testAllFilesPresentInSuspendFunctionAsSupertype() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/coroutines/suspendFunctionAsSupertype"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
}
@TestMetadata("compiler/testData/diagnostics/tests/coroutines/suspendFunctionAsSupertype/kSuspendFunctionN")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class KSuspendFunctionN extends AbstractDiagnosisCompilerTestDataTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
}
public void testAllFilesPresentInKSuspendFunctionN() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/coroutines/suspendFunctionAsSupertype/kSuspendFunctionN"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
}
@TestMetadata("mixingSuspendAndNonSuspendSupertypes.kt")
public void testMixingSuspendAndNonSuspendSupertypes() throws Exception {
runTest("compiler/testData/diagnostics/tests/coroutines/suspendFunctionAsSupertype/kSuspendFunctionN/mixingSuspendAndNonSuspendSupertypes.kt");
}
@TestMetadata("mixingSuspendAndNonSuspendSupertypesThruSuperClass.kt")
public void testMixingSuspendAndNonSuspendSupertypesThruSuperClass() throws Exception {
runTest("compiler/testData/diagnostics/tests/coroutines/suspendFunctionAsSupertype/kSuspendFunctionN/mixingSuspendAndNonSuspendSupertypesThruSuperClass.kt");
}
@TestMetadata("mixingSuspendAndNonSuspendSupertypesThruSuperFunInterface.kt")
public void testMixingSuspendAndNonSuspendSupertypesThruSuperFunInterface() throws Exception {
runTest("compiler/testData/diagnostics/tests/coroutines/suspendFunctionAsSupertype/kSuspendFunctionN/mixingSuspendAndNonSuspendSupertypesThruSuperFunInterface.kt");
}
@TestMetadata("mixingSuspendAndNonSuspendSupertypesThruSuperinterface.kt")
public void testMixingSuspendAndNonSuspendSupertypesThruSuperinterface() throws Exception {
runTest("compiler/testData/diagnostics/tests/coroutines/suspendFunctionAsSupertype/kSuspendFunctionN/mixingSuspendAndNonSuspendSupertypesThruSuperinterface.kt");
}
@TestMetadata("simple.kt")
public void testSimple() throws Exception {
runTest("compiler/testData/diagnostics/tests/coroutines/suspendFunctionAsSupertype/kSuspendFunctionN/simple.kt");
}
}
@TestMetadata("compiler/testData/diagnostics/tests/coroutines/suspendFunctionAsSupertype/simple")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Simple extends AbstractDiagnosisCompilerTestDataTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
}
public void testAllFilesPresentInSimple() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/coroutines/suspendFunctionAsSupertype/simple"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
}
@TestMetadata("mixingSuspendAndNonSuspendSupertypes.kt")
public void testMixingSuspendAndNonSuspendSupertypes() throws Exception {
runTest("compiler/testData/diagnostics/tests/coroutines/suspendFunctionAsSupertype/simple/mixingSuspendAndNonSuspendSupertypes.kt");
}
@TestMetadata("mixingSuspendAndNonSuspendSupertypesThruSuperClass.kt")
public void testMixingSuspendAndNonSuspendSupertypesThruSuperClass() throws Exception {
runTest("compiler/testData/diagnostics/tests/coroutines/suspendFunctionAsSupertype/simple/mixingSuspendAndNonSuspendSupertypesThruSuperClass.kt");
}
@TestMetadata("mixingSuspendAndNonSuspendSupertypesThruSuperFunInterface.kt")
public void testMixingSuspendAndNonSuspendSupertypesThruSuperFunInterface() throws Exception {
runTest("compiler/testData/diagnostics/tests/coroutines/suspendFunctionAsSupertype/simple/mixingSuspendAndNonSuspendSupertypesThruSuperFunInterface.kt");
}
@TestMetadata("mixingSuspendAndNonSuspendSupertypesThruSuperinterface.kt")
public void testMixingSuspendAndNonSuspendSupertypesThruSuperinterface() throws Exception {
runTest("compiler/testData/diagnostics/tests/coroutines/suspendFunctionAsSupertype/simple/mixingSuspendAndNonSuspendSupertypesThruSuperinterface.kt");
}
@TestMetadata("simple.kt")
public void testSimple() throws Exception {
runTest("compiler/testData/diagnostics/tests/coroutines/suspendFunctionAsSupertype/simple/simple.kt");
}
}
@TestMetadata("compiler/testData/diagnostics/tests/coroutines/suspendFunctionAsSupertype/suspendFunctionN")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class SuspendFunctionN extends AbstractDiagnosisCompilerTestDataTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
}
public void testAllFilesPresentInSuspendFunctionN() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/coroutines/suspendFunctionAsSupertype/suspendFunctionN"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
}
@TestMetadata("mixingSuspendAndNonSuspendSupertypes.kt")
public void testMixingSuspendAndNonSuspendSupertypes() throws Exception {
runTest("compiler/testData/diagnostics/tests/coroutines/suspendFunctionAsSupertype/suspendFunctionN/mixingSuspendAndNonSuspendSupertypes.kt");
}
@TestMetadata("mixingSuspendAndNonSuspendSupertypesThruSuperClass.kt")
public void testMixingSuspendAndNonSuspendSupertypesThruSuperClass() throws Exception {
runTest("compiler/testData/diagnostics/tests/coroutines/suspendFunctionAsSupertype/suspendFunctionN/mixingSuspendAndNonSuspendSupertypesThruSuperClass.kt");
}
@TestMetadata("mixingSuspendAndNonSuspendSupertypesThruSuperFunInterface.kt")
public void testMixingSuspendAndNonSuspendSupertypesThruSuperFunInterface() throws Exception {
runTest("compiler/testData/diagnostics/tests/coroutines/suspendFunctionAsSupertype/suspendFunctionN/mixingSuspendAndNonSuspendSupertypesThruSuperFunInterface.kt");
}
@TestMetadata("mixingSuspendAndNonSuspendSupertypesThruSuperinterface.kt")
public void testMixingSuspendAndNonSuspendSupertypesThruSuperinterface() throws Exception {
runTest("compiler/testData/diagnostics/tests/coroutines/suspendFunctionAsSupertype/suspendFunctionN/mixingSuspendAndNonSuspendSupertypesThruSuperinterface.kt");
}
@TestMetadata("simple.kt")
public void testSimple() throws Exception {
runTest("compiler/testData/diagnostics/tests/coroutines/suspendFunctionAsSupertype/suspendFunctionN/simple.kt");
}
}
}
} }
@TestMetadata("compiler/testData/diagnostics/tests/cyclicHierarchy") @TestMetadata("compiler/testData/diagnostics/tests/cyclicHierarchy")
@@ -10824,6 +10951,11 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag
runTest("compiler/testData/diagnostics/tests/inference/violatingUpperBoundForSelfType.kt"); runTest("compiler/testData/diagnostics/tests/inference/violatingUpperBoundForSelfType.kt");
} }
@TestMetadata("violatingUpperBoundForSelfTypeError.kt")
public void testViolatingUpperBoundForSelfTypeError() throws Exception {
runTest("compiler/testData/diagnostics/tests/inference/violatingUpperBoundForSelfTypeError.kt");
}
@TestMetadata("compiler/testData/diagnostics/tests/inference/builderInference") @TestMetadata("compiler/testData/diagnostics/tests/inference/builderInference")
@TestDataPath("$PROJECT_ROOT") @TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class) @RunWith(JUnit3RunnerWithInners.class)
@@ -14569,6 +14701,11 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag
runTest("compiler/testData/diagnostics/tests/java8Overrides/abstractBaseClassMemberNotImplemented.kt"); runTest("compiler/testData/diagnostics/tests/java8Overrides/abstractBaseClassMemberNotImplemented.kt");
} }
@TestMetadata("abstractBaseClassMemberNotImplemented_15.kt")
public void testAbstractBaseClassMemberNotImplemented_15() throws Exception {
runTest("compiler/testData/diagnostics/tests/java8Overrides/abstractBaseClassMemberNotImplemented_15.kt");
}
@TestMetadata("abstractVsAbstract.kt") @TestMetadata("abstractVsAbstract.kt")
public void testAbstractVsAbstract() throws Exception { public void testAbstractVsAbstract() throws Exception {
runTest("compiler/testData/diagnostics/tests/java8Overrides/abstractVsAbstract.kt"); runTest("compiler/testData/diagnostics/tests/java8Overrides/abstractVsAbstract.kt");
@@ -14593,6 +14730,11 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag
runTest("compiler/testData/diagnostics/tests/java8Overrides/implementingMethodOfAny.kt"); runTest("compiler/testData/diagnostics/tests/java8Overrides/implementingMethodOfAny.kt");
} }
@TestMetadata("kt45508.kt")
public void testKt45508() throws Exception {
runTest("compiler/testData/diagnostics/tests/java8Overrides/kt45508.kt");
}
@TestMetadata("notAMethodOfAny.kt") @TestMetadata("notAMethodOfAny.kt")
public void testNotAMethodOfAny() throws Exception { public void testNotAMethodOfAny() throws Exception {
runTest("compiler/testData/diagnostics/tests/java8Overrides/notAMethodOfAny.kt"); runTest("compiler/testData/diagnostics/tests/java8Overrides/notAMethodOfAny.kt");
@@ -18391,6 +18533,16 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag
runTest("compiler/testData/diagnostics/tests/platformTypes/rawTypes/arrays.kt"); runTest("compiler/testData/diagnostics/tests/platformTypes/rawTypes/arrays.kt");
} }
@TestMetadata("dontSubstituteAnotherErasedRecursiveTypeArgumentAndNonRecursive.kt")
public void testDontSubstituteAnotherErasedRecursiveTypeArgumentAndNonRecursive() throws Exception {
runTest("compiler/testData/diagnostics/tests/platformTypes/rawTypes/dontSubstituteAnotherErasedRecursiveTypeArgumentAndNonRecursive.kt");
}
@TestMetadata("dontSubstituteAnotherErasedTypeArgumentIfRecursive.kt")
public void testDontSubstituteAnotherErasedTypeArgumentIfRecursive() throws Exception {
runTest("compiler/testData/diagnostics/tests/platformTypes/rawTypes/dontSubstituteAnotherErasedTypeArgumentIfRecursive.kt");
}
@TestMetadata("errorType.kt") @TestMetadata("errorType.kt")
public void testErrorType() throws Exception { public void testErrorType() throws Exception {
runTest("compiler/testData/diagnostics/tests/platformTypes/rawTypes/errorType.kt"); runTest("compiler/testData/diagnostics/tests/platformTypes/rawTypes/errorType.kt");
@@ -18466,6 +18618,26 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag
runTest("compiler/testData/diagnostics/tests/platformTypes/rawTypes/starProjectionToRaw.kt"); runTest("compiler/testData/diagnostics/tests/platformTypes/rawTypes/starProjectionToRaw.kt");
} }
@TestMetadata("substituteAnotherErasedTypeArgument.kt")
public void testSubstituteAnotherErasedTypeArgument() throws Exception {
runTest("compiler/testData/diagnostics/tests/platformTypes/rawTypes/substituteAnotherErasedTypeArgument.kt");
}
@TestMetadata("substituteOtherErasedDeepTypeArguments.kt")
public void testSubstituteOtherErasedDeepTypeArguments() throws Exception {
runTest("compiler/testData/diagnostics/tests/platformTypes/rawTypes/substituteOtherErasedDeepTypeArguments.kt");
}
@TestMetadata("substituteSeveralOtherErasedDependentTypeArguments.kt")
public void testSubstituteSeveralOtherErasedDependentTypeArguments() throws Exception {
runTest("compiler/testData/diagnostics/tests/platformTypes/rawTypes/substituteSeveralOtherErasedDependentTypeArguments.kt");
}
@TestMetadata("substituteSeveralOtherErasedTypeArguments.kt")
public void testSubstituteSeveralOtherErasedTypeArguments() throws Exception {
runTest("compiler/testData/diagnostics/tests/platformTypes/rawTypes/substituteSeveralOtherErasedTypeArguments.kt");
}
@TestMetadata("typeEnhancement.kt") @TestMetadata("typeEnhancement.kt")
public void testTypeEnhancement() throws Exception { public void testTypeEnhancement() throws Exception {
runTest("compiler/testData/diagnostics/tests/platformTypes/rawTypes/typeEnhancement.kt"); runTest("compiler/testData/diagnostics/tests/platformTypes/rawTypes/typeEnhancement.kt");
@@ -25394,6 +25566,11 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag
runTest("compiler/testData/diagnostics/tests/typeParameters/kt42042.kt"); runTest("compiler/testData/diagnostics/tests/typeParameters/kt42042.kt");
} }
@TestMetadata("kt42042Error.kt")
public void testKt42042Error() throws Exception {
runTest("compiler/testData/diagnostics/tests/typeParameters/kt42042Error.kt");
}
@TestMetadata("kt42396.kt") @TestMetadata("kt42396.kt")
public void testKt42396() throws Exception { public void testKt42396() throws Exception {
runTest("compiler/testData/diagnostics/tests/typeParameters/kt42396.kt"); runTest("compiler/testData/diagnostics/tests/typeParameters/kt42396.kt");