[Wasm] Add K2 diagnostic tests (KT-56849)

This commit is contained in:
Svyatoslav Kuzmich
2023-09-11 12:01:48 +02:00
committed by Space Team
parent 1ddcdb95bd
commit 0da9cf8159
13 changed files with 626 additions and 4 deletions
@@ -8,6 +8,7 @@ package org.jetbrains.kotlin.generators.tests
import org.jetbrains.kotlin.generators.generateTestGroupSuiteWithJUnit5
import org.jetbrains.kotlin.wasm.test.*
import org.jetbrains.kotlin.wasm.test.diagnostics.AbstractDiagnosticsWasmTest
import org.jetbrains.kotlin.wasm.test.diagnostics.AbstractDiagnosticsFirWasmTest
fun main(args: Array<String>) {
System.setProperty("java.awt.headless", "true")
@@ -24,11 +25,16 @@ fun main(args: Array<String>) {
// Multimodal infra is not supported. Also, we don't use ES modules for cross-module refs in Wasm
"crossModuleRef", "crossModuleRefPerFile", "crossModuleRefPerModule"
)
val excludedFirTestdataPattern = "^(.+)\\.fir\\.kts?\$"
generateTestGroupSuiteWithJUnit5(args) {
testGroup("wasm/wasm.tests/tests-gen", "compiler/testData") {
testClass<AbstractDiagnosticsWasmTest> {
model("diagnostics/wasmTests")
model("diagnostics/wasmTests", excludedPattern = excludedFirTestdataPattern)
}
testClass<AbstractDiagnosticsFirWasmTest> {
model("diagnostics/wasmTests", excludedPattern = excludedFirTestdataPattern)
}
}
@@ -0,0 +1,64 @@
/*
* 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.wasm.test.diagnostics
import org.jetbrains.kotlin.platform.wasm.WasmPlatforms
import org.jetbrains.kotlin.test.FirParser
import org.jetbrains.kotlin.test.builders.TestConfigurationBuilder
import org.jetbrains.kotlin.test.builders.firHandlersStep
import org.jetbrains.kotlin.test.directives.configureFirParser
import org.jetbrains.kotlin.test.frontend.fir.FirFrontendFacade
import org.jetbrains.kotlin.test.frontend.fir.handlers.*
import org.jetbrains.kotlin.test.model.DependencyKind
import org.jetbrains.kotlin.test.model.FrontendKinds
import org.jetbrains.kotlin.test.runners.AbstractKotlinCompilerTest
import org.jetbrains.kotlin.test.runners.configurationForClassicAndFirTestsAlongside
import org.jetbrains.kotlin.test.services.LibraryProvider
import org.jetbrains.kotlin.test.services.configuration.CommonEnvironmentConfigurator
import org.jetbrains.kotlin.test.services.configuration.WasmEnvironmentConfiguratorJs
import org.jetbrains.kotlin.test.services.sourceProviders.AdditionalDiagnosticsSourceFilesProvider
import org.jetbrains.kotlin.test.services.sourceProviders.CoroutineHelpersSourceFilesProvider
abstract class AbstractFirWasmDiagnosticTestBase(val parser: FirParser) : AbstractKotlinCompilerTest() {
override fun TestConfigurationBuilder.configuration() {
globalDefaults {
frontend = FrontendKinds.FIR
targetPlatform = WasmPlatforms.Default
dependencyKind = DependencyKind.Source
}
configureFirParser(parser)
enableMetaInfoHandler()
configurationForClassicAndFirTestsAlongside()
useConfigurators(
::CommonEnvironmentConfigurator,
::WasmEnvironmentConfiguratorJs,
)
useAdditionalSourceProviders(
::AdditionalDiagnosticsSourceFilesProvider,
::CoroutineHelpersSourceFilesProvider,
)
useAdditionalService(::LibraryProvider)
facadeStep(::FirFrontendFacade)
firHandlersStep {
useHandlers(
::FirDiagnosticsHandler,
::FirDumpHandler,
::FirCfgDumpHandler,
::FirCfgConsistencyHandler,
::FirResolvedTypesVerifier,
::FirScopeDumpHandler,
)
}
}
}
abstract class AbstractDiagnosticsFirWasmTest : AbstractFirWasmDiagnosticTestBase(FirParser.Psi)
@@ -0,0 +1,100 @@
/*
* 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.wasm.test.diagnostics;
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 org.jetbrains.kotlin.generators.tests.GenerateWasmTestsKt}. DO NOT MODIFY MANUALLY */
@SuppressWarnings("all")
@TestMetadata("compiler/testData/diagnostics/wasmTests")
@TestDataPath("$PROJECT_ROOT")
public class DiagnosticsFirWasmTestGenerated extends AbstractDiagnosticsFirWasmTest {
@Test
public void testAllFilesPresentInWasmTests() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/wasmTests"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
}
@Nested
@TestMetadata("compiler/testData/diagnostics/wasmTests/jsInterop")
@TestDataPath("$PROJECT_ROOT")
public class JsInterop {
@Test
public void testAllFilesPresentInJsInterop() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/wasmTests/jsInterop"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
}
@Test
@TestMetadata("dynamicUnsupported.kt")
public void testDynamicUnsupported() throws Exception {
runTest("compiler/testData/diagnostics/wasmTests/jsInterop/dynamicUnsupported.kt");
}
@Test
@TestMetadata("external.kt")
public void testExternal() throws Exception {
runTest("compiler/testData/diagnostics/wasmTests/jsInterop/external.kt");
}
@Test
@TestMetadata("inheritance.kt")
public void testInheritance() throws Exception {
runTest("compiler/testData/diagnostics/wasmTests/jsInterop/inheritance.kt");
}
@Test
@TestMetadata("jsCode.kt")
public void testJsCode() throws Exception {
runTest("compiler/testData/diagnostics/wasmTests/jsInterop/jsCode.kt");
}
@Test
@TestMetadata("jsExport.kt")
public void testJsExport() throws Exception {
runTest("compiler/testData/diagnostics/wasmTests/jsInterop/jsExport.kt");
}
@Test
@TestMetadata("jsFun.kt")
public void testJsFun() throws Exception {
runTest("compiler/testData/diagnostics/wasmTests/jsInterop/jsFun.kt");
}
@Test
@TestMetadata("types.kt")
public void testTypes() throws Exception {
runTest("compiler/testData/diagnostics/wasmTests/jsInterop/types.kt");
}
}
@Nested
@TestMetadata("compiler/testData/diagnostics/wasmTests/wasmInterop")
@TestDataPath("$PROJECT_ROOT")
public class WasmInterop {
@Test
public void testAllFilesPresentInWasmInterop() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/wasmTests/wasmInterop"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
}
@Test
@TestMetadata("wasmExport.kt")
public void testWasmExport() throws Exception {
runTest("compiler/testData/diagnostics/wasmTests/wasmInterop/wasmExport.kt");
}
@Test
@TestMetadata("wasmImport.kt")
public void testWasmImport() throws Exception {
runTest("compiler/testData/diagnostics/wasmTests/wasmInterop/wasmImport.kt");
}
}
}
@@ -21,7 +21,7 @@ import java.util.regex.Pattern;
public class DiagnosticsWasmTestGenerated extends AbstractDiagnosticsWasmTest {
@Test
public void testAllFilesPresentInWasmTests() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/wasmTests"), Pattern.compile("^(.+)\\.kt$"), null, true);
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/wasmTests"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
}
@Nested
@@ -30,7 +30,7 @@ public class DiagnosticsWasmTestGenerated extends AbstractDiagnosticsWasmTest {
public class JsInterop {
@Test
public void testAllFilesPresentInJsInterop() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/wasmTests/jsInterop"), Pattern.compile("^(.+)\\.kt$"), null, true);
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/wasmTests/jsInterop"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
}
@Test
@@ -82,7 +82,7 @@ public class DiagnosticsWasmTestGenerated extends AbstractDiagnosticsWasmTest {
public class WasmInterop {
@Test
public void testAllFilesPresentInWasmInterop() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/wasmTests/wasmInterop"), Pattern.compile("^(.+)\\.kt$"), null, true);
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/wasmTests/wasmInterop"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
}
@Test