[FIR] Implement Native test infrastructure, add FirNativeSessionFactory
This commit is contained in:
+68
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* 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.test.runners;
|
||||
|
||||
import com.intellij.testFramework.TestDataPath;
|
||||
import org.jetbrains.kotlin.test.util.KtTestUtil;
|
||||
import org.jetbrains.kotlin.test.TestMetadata;
|
||||
import org.junit.jupiter.api.Nested;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/** This class is generated by {@link GenerateNewCompilerTests.kt}. DO NOT MODIFY MANUALLY */
|
||||
@SuppressWarnings("all")
|
||||
@TestMetadata("compiler/testData/diagnostics/nativeTests")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class FirOldFrontendNativeDiagnosticsTestGenerated extends AbstractFirNativeDiagnosticsTest {
|
||||
@Test
|
||||
public void testAllFilesPresentInNativeTests() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/nativeTests"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("identifiers.kt")
|
||||
public void testIdentifiers() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/nativeTests/identifiers.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("objCName.kt")
|
||||
public void testObjCName() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/nativeTests/objCName.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("sharedImmutable.kt")
|
||||
public void testSharedImmutable() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/nativeTests/sharedImmutable.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("threadLocal.kt")
|
||||
public void testThreadLocal() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/nativeTests/threadLocal.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("throws.kt")
|
||||
public void testThrows() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/nativeTests/throws.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("throwsClash.kt")
|
||||
public void testThrowsClash() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/nativeTests/throwsClash.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("topLevelSingleton.kt")
|
||||
public void testTopLevelSingleton() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/nativeTests/topLevelSingleton.kt");
|
||||
}
|
||||
}
|
||||
+68
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* 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.test.runners;
|
||||
|
||||
import com.intellij.testFramework.TestDataPath;
|
||||
import org.jetbrains.kotlin.test.util.KtTestUtil;
|
||||
import org.jetbrains.kotlin.test.TestMetadata;
|
||||
import org.junit.jupiter.api.Nested;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/** This class is generated by {@link GenerateNewCompilerTests.kt}. DO NOT MODIFY MANUALLY */
|
||||
@SuppressWarnings("all")
|
||||
@TestMetadata("compiler/testData/diagnostics/nativeTests")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class FirOldFrontendNativeDiagnosticsWithLightTreeTestGenerated extends AbstractFirNativeDiagnosticsWithLightTreeTest {
|
||||
@Test
|
||||
public void testAllFilesPresentInNativeTests() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/nativeTests"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("identifiers.kt")
|
||||
public void testIdentifiers() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/nativeTests/identifiers.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("objCName.kt")
|
||||
public void testObjCName() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/nativeTests/objCName.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("sharedImmutable.kt")
|
||||
public void testSharedImmutable() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/nativeTests/sharedImmutable.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("threadLocal.kt")
|
||||
public void testThreadLocal() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/nativeTests/threadLocal.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("throws.kt")
|
||||
public void testThrows() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/nativeTests/throws.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("throwsClash.kt")
|
||||
public void testThrowsClash() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/nativeTests/throwsClash.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("topLevelSingleton.kt")
|
||||
public void testTopLevelSingleton() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/nativeTests/topLevelSingleton.kt");
|
||||
}
|
||||
}
|
||||
@@ -37,6 +37,7 @@ val generationRoot = projectDir.resolve("gen")
|
||||
val platformGenerationRoots = listOf(
|
||||
"checkers.jvm",
|
||||
"checkers.js",
|
||||
"checkers.native",
|
||||
).map { projectDir.resolve(it).resolve("gen") }
|
||||
|
||||
val generateCheckersComponents by tasks.registering(NoDebugJavaExec::class) {
|
||||
|
||||
+3
@@ -14,6 +14,7 @@ import org.jetbrains.kotlin.fir.expressions.*
|
||||
import org.jetbrains.kotlin.fir.types.FirTypeRef
|
||||
import java.io.File
|
||||
import org.jetbrains.kotlin.fir.builder.SYNTAX_DIAGNOSTIC_LIST
|
||||
import org.jetbrains.kotlin.fir.checkers.generator.diagnostics.NATIVE_DIAGNOSTICS_LIST
|
||||
import org.jetbrains.kotlin.fir.checkers.generator.diagnostics.model.ErrorListDiagnosticListRenderer
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
@@ -97,11 +98,13 @@ fun main(args: Array<String>) {
|
||||
|
||||
val jvmGenerationPath = File(arguments.getOrElse(1) { "compiler/fir/checkers/checkers.jvm/gen" })
|
||||
val jsGenerationPath = File(arguments.getOrElse(2) { "compiler/fir/checkers/checkers.js/gen" })
|
||||
val nativeGenerationPath = File(arguments.getOrElse(3) { "compiler/fir/checkers/checkers.native/gen" })
|
||||
val rawFirGenerationPath = File("compiler/fir/raw-fir/raw-fir.common/gen")
|
||||
|
||||
generateDiagnostics(generationPath, "$basePackage.diagnostics", DIAGNOSTICS_LIST, starImportsToAdd = setOf(ErrorListDiagnosticListRenderer.BASE_PACKAGE, ErrorListDiagnosticListRenderer.DIAGNOSTICS_PACKAGE))
|
||||
generateDiagnostics(jvmGenerationPath, "$basePackage.diagnostics.jvm", JVM_DIAGNOSTICS_LIST, starImportsToAdd = setOf(ErrorListDiagnosticListRenderer.BASE_PACKAGE, ErrorListDiagnosticListRenderer.DIAGNOSTICS_PACKAGE))
|
||||
generateDiagnostics(jsGenerationPath, "$basePackage.diagnostics.js", JS_DIAGNOSTICS_LIST, starImportsToAdd = setOf(ErrorListDiagnosticListRenderer.BASE_PACKAGE, ErrorListDiagnosticListRenderer.DIAGNOSTICS_PACKAGE))
|
||||
generateDiagnostics(nativeGenerationPath, "$basePackage.diagnostics.native", NATIVE_DIAGNOSTICS_LIST, starImportsToAdd = setOf(ErrorListDiagnosticListRenderer.BASE_PACKAGE, ErrorListDiagnosticListRenderer.DIAGNOSTICS_PACKAGE))
|
||||
generateDiagnostics(rawFirGenerationPath, "org.jetbrains.kotlin.fir.builder", SYNTAX_DIAGNOSTIC_LIST, starImportsToAdd = setOf(ErrorListDiagnosticListRenderer.DIAGNOSTICS_PACKAGE))
|
||||
}
|
||||
|
||||
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
/*
|
||||
* 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.fir.checkers.generator.diagnostics
|
||||
|
||||
import org.jetbrains.kotlin.fir.PrivateForInline
|
||||
import org.jetbrains.kotlin.fir.checkers.generator.diagnostics.model.DiagnosticList
|
||||
|
||||
@Suppress("UNUSED_VARIABLE", "LocalVariableName", "ClassName", "unused")
|
||||
@OptIn(PrivateForInline::class)
|
||||
object NATIVE_DIAGNOSTICS_LIST : DiagnosticList("FirNativeErrors") {
|
||||
val ALL by object : DiagnosticGroup("All") {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
import org.jetbrains.kotlin.ideaExt.idea
|
||||
|
||||
plugins {
|
||||
kotlin("jvm")
|
||||
id("jps-compatible")
|
||||
}
|
||||
|
||||
dependencies {
|
||||
api(project(":compiler:fir:checkers"))
|
||||
|
||||
/*
|
||||
* We can't remove this dependency until we use
|
||||
* diagnostics framework from FE 1.0
|
||||
*/
|
||||
implementation(project(":compiler:frontend"))
|
||||
implementation(project(":compiler:psi"))
|
||||
|
||||
compileOnly(project(":kotlin-reflect-api"))
|
||||
compileOnly(intellijCore())
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
"main" {
|
||||
projectDefault()
|
||||
this.java.srcDir("gen")
|
||||
}
|
||||
"test" { none() }
|
||||
}
|
||||
|
||||
val compileKotlin by tasks
|
||||
compileKotlin.dependsOn(":compiler:fir:checkers:generateCheckersComponents")
|
||||
|
||||
if (kotlinBuildProperties.isInJpsBuildIdeaSync) {
|
||||
apply(plugin = "idea")
|
||||
idea {
|
||||
this.module.generatedSourceDirs.add(projectDir.resolve("gen"))
|
||||
}
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* 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.fir.analysis.diagnostics.native
|
||||
|
||||
import org.jetbrains.kotlin.diagnostics.*
|
||||
import org.jetbrains.kotlin.diagnostics.rendering.RootDiagnosticRendererFactory
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.*
|
||||
|
||||
/*
|
||||
* This file was generated automatically
|
||||
* DO NOT MODIFY IT MANUALLY
|
||||
*/
|
||||
|
||||
object FirNativeErrors {
|
||||
// All
|
||||
|
||||
init {
|
||||
RootDiagnosticRendererFactory.registerFactory(FirNativeErrorsDefaultMessages)
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
/*
|
||||
* 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.fir.analysis.diagnostics.native
|
||||
|
||||
import org.jetbrains.kotlin.diagnostics.KtDiagnosticFactoryToRendererMap
|
||||
import org.jetbrains.kotlin.diagnostics.rendering.BaseDiagnosticRendererFactory
|
||||
|
||||
object FirNativeErrorsDefaultMessages : BaseDiagnosticRendererFactory() {
|
||||
override val MAP = KtDiagnosticFactoryToRendererMap("FIR")
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
/*
|
||||
* 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.fir.analysis.native.checkers
|
||||
|
||||
import org.jetbrains.kotlin.fir.analysis.checkers.declaration.DeclarationCheckers
|
||||
|
||||
object NativeDeclarationCheckers : DeclarationCheckers() {
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
/*
|
||||
* 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.fir.analysis.native.checkers
|
||||
|
||||
import org.jetbrains.kotlin.fir.analysis.checkers.expression.ExpressionCheckers
|
||||
|
||||
object NativeExpressionCheckers : ExpressionCheckers() {
|
||||
}
|
||||
@@ -13,6 +13,7 @@ dependencies {
|
||||
api(project(":compiler:fir:checkers"))
|
||||
api(project(":compiler:fir:checkers:checkers.jvm"))
|
||||
api(project(":compiler:fir:checkers:checkers.js"))
|
||||
api(project(":compiler:fir:checkers:checkers.native"))
|
||||
|
||||
// TODO: do not use GeneratorExtensions in `FirAnalyzerFacade.convertToIr`, and make this an 'implementation' dependency.
|
||||
api(project(":compiler:ir.psi2ir"))
|
||||
|
||||
@@ -11,6 +11,8 @@ import org.jetbrains.kotlin.fir.analysis.js.checkers.JsExpressionCheckers
|
||||
import org.jetbrains.kotlin.fir.analysis.jvm.checkers.JvmDeclarationCheckers
|
||||
import org.jetbrains.kotlin.fir.analysis.jvm.checkers.JvmExpressionCheckers
|
||||
import org.jetbrains.kotlin.fir.analysis.jvm.checkers.JvmTypeCheckers
|
||||
import org.jetbrains.kotlin.fir.analysis.native.checkers.NativeDeclarationCheckers
|
||||
import org.jetbrains.kotlin.fir.analysis.native.checkers.NativeExpressionCheckers
|
||||
import org.jetbrains.kotlin.fir.session.FirSessionConfigurator
|
||||
|
||||
fun FirSessionConfigurator.registerCommonCheckers() {
|
||||
@@ -35,3 +37,8 @@ fun FirSessionConfigurator.registerJsCheckers() {
|
||||
useCheckers(JsDeclarationCheckers)
|
||||
useCheckers(JsExpressionCheckers)
|
||||
}
|
||||
|
||||
fun FirSessionConfigurator.registerNativeCheckers() {
|
||||
useCheckers(NativeDeclarationCheckers)
|
||||
useCheckers(NativeExpressionCheckers)
|
||||
}
|
||||
Reference in New Issue
Block a user