FIR JS: add K2 variants of all other JS tests

except tests that are not possible to add without some modifications in
the test infra. See todos on the commented-out test declarations
This commit is contained in:
Ilya Chernikov
2022-08-17 18:32:23 +02:00
parent 5baf4a55c1
commit 78ca733c38
133 changed files with 42615 additions and 147 deletions
@@ -120,9 +120,19 @@ fun main(args: Array<String>) {
model("lineNumbers/")
}
testClass<AbstractFirJsTest> {
testClass<AbstractFirBoxJsTest> {
model("box/", pattern = "^([^_](.+))\\.kt$")
}
// see todo on defining class
// testClass<AbstractFirJsTypeScriptExportTest> {
// model("typescript-export/", pattern = "^([^_](.+))\\.kt$")
// }
// see todo on defining class
// testClass<AbstractJsFirLineNumberTest> {
// model("lineNumbers/")
// }
}
testGroup("js/js.tests/tests-gen", "compiler/testData", testRunnerMethodName = "runTest0") {
@@ -167,6 +177,27 @@ fun main(args: Array<String>) {
) {
model("ir/irJsText")
}
testClass<AbstractFirJsCodegenBoxTest> {
model("codegen/box", excludeDirs = jvmOnlyBoxTests)
}
testClass<AbstractFirJsCodegenBoxErrorTest> {
model("codegen/boxError", excludeDirs = jvmOnlyBoxTests)
}
testClass<AbstractFirJsCodegenInlineTest> {
model("codegen/boxInline")
}
testClass<AbstractFirCodegenWasmJsInteropJsTest> {
model("codegen/boxWasmJsInterop")
}
// see todo on AbstractFirJsSteppingTest
// testClass<AbstractFirJsSteppingTest> {
// model("debug/stepping")
// }
}
}
}
@@ -6,28 +6,32 @@
package org.jetbrains.kotlin.js.test.ir
import org.jetbrains.kotlin.js.test.AbstractJsBlackBoxCodegenTestBase
import org.jetbrains.kotlin.js.test.JsSteppingTestAdditionalSourceProvider
import org.jetbrains.kotlin.js.test.converters.FirJsKlibBackendFacade
import org.jetbrains.kotlin.js.test.JsSteppingTestAdditionalSourceProvider
import org.jetbrains.kotlin.js.test.converters.JsIrBackendFacade
import org.jetbrains.kotlin.js.test.converters.JsKlibBackendFacade
import org.jetbrains.kotlin.js.test.converters.incremental.RecompileModuleJsIrBackendFacade
import org.jetbrains.kotlin.js.test.handlers.*
import org.jetbrains.kotlin.js.test.handlers.JsDebugRunner
import org.jetbrains.kotlin.js.test.handlers.JsDtsHandler
import org.jetbrains.kotlin.js.test.handlers.JsIrRecompiledArtifactsIdentityHandler
import org.jetbrains.kotlin.js.test.handlers.JsLineNumberHandler
import org.jetbrains.kotlin.parsing.parseBoolean
import org.jetbrains.kotlin.test.Constructor
import org.jetbrains.kotlin.test.TargetBackend
import org.jetbrains.kotlin.test.backend.ir.IrBackendInput
import org.jetbrains.kotlin.test.builders.*
import org.jetbrains.kotlin.test.directives.*
import org.jetbrains.kotlin.test.directives.JsEnvironmentConfigurationDirectives
import org.jetbrains.kotlin.test.directives.LanguageSettingsDirectives
import org.jetbrains.kotlin.test.frontend.classic.ClassicFrontend2IrConverter
import org.jetbrains.kotlin.test.frontend.classic.ClassicFrontendFacade
import org.jetbrains.kotlin.test.frontend.classic.ClassicFrontendOutputArtifact
import org.jetbrains.kotlin.test.frontend.fir.Fir2IrJsResultsConverter
import org.jetbrains.kotlin.test.frontend.fir.FirFrontendFacade
import org.jetbrains.kotlin.test.frontend.fir.FirMetaInfoDiffSuppressor
import org.jetbrains.kotlin.test.frontend.fir.FirOutputArtifact
import org.jetbrains.kotlin.test.frontend.fir.handlers.*
import org.jetbrains.kotlin.test.model.*
import org.jetbrains.kotlin.test.services.MetaTestConfigurator
import org.jetbrains.kotlin.test.services.TestServices
import org.jetbrains.kotlin.test.runners.codegen.commonFirHandlersForCodegenTest
import org.jetbrains.kotlin.test.services.configuration.JsEnvironmentConfigurator
import java.lang.Boolean.getBoolean
@@ -107,17 +111,21 @@ open class AbstractIrJsTypeScriptExportTest : AbstractJsIrTest(
) {
override fun configure(builder: TestConfigurationBuilder) {
super.configure(builder)
with(builder) {
defaultDirectives {
+JsEnvironmentConfigurationDirectives.GENERATE_DTS
if (getBoolean("kotlin.js.updateReferenceDtsFiles")) +JsEnvironmentConfigurationDirectives.UPDATE_REFERENCE_DTS_FILES
}
configureIrJsTypeScriptExportTest(builder)
}
}
configureJsArtifactsHandlersStep {
useHandlers(
::JsDtsHandler
)
}
private fun configureIrJsTypeScriptExportTest(builder: TestConfigurationBuilder) {
with(builder) {
defaultDirectives {
+JsEnvironmentConfigurationDirectives.GENERATE_DTS
if (getBoolean("kotlin.js.updateReferenceDtsFiles")) +JsEnvironmentConfigurationDirectives.UPDATE_REFERENCE_DTS_FILES
}
configureJsArtifactsHandlersStep {
useHandlers(
::JsDtsHandler
)
}
}
}
@@ -128,16 +136,20 @@ open class AbstractJsIrLineNumberTest : AbstractJsIrTest(
) {
override fun configure(builder: TestConfigurationBuilder) {
super.configure(builder)
with(builder) {
defaultDirectives {
+JsEnvironmentConfigurationDirectives.KJS_WITH_FULL_RUNTIME
+JsEnvironmentConfigurationDirectives.NO_COMMON_FILES
-JsEnvironmentConfigurationDirectives.GENERATE_NODE_JS_RUNNER
JsEnvironmentConfigurationDirectives.DONT_RUN_GENERATED_CODE.with(listOf("JS", "JS_IR", "JS_IR_ES6"))
}
configureJsArtifactsHandlersStep {
useHandlers(::JsLineNumberHandler)
}
configureJsIrLineNumberTest(builder)
}
}
private fun configureJsIrLineNumberTest(builder: TestConfigurationBuilder) {
with(builder) {
defaultDirectives {
+JsEnvironmentConfigurationDirectives.KJS_WITH_FULL_RUNTIME
+JsEnvironmentConfigurationDirectives.NO_COMMON_FILES
-JsEnvironmentConfigurationDirectives.GENERATE_NODE_JS_RUNNER
JsEnvironmentConfigurationDirectives.DONT_RUN_GENERATED_CODE.with(listOf("JS", "JS_IR", "JS_IR_ES6"))
}
configureJsArtifactsHandlersStep {
useHandlers(::JsLineNumberHandler)
}
}
}
@@ -179,14 +191,6 @@ open class AbstractIrCodegenWasmJsInteropJsTest : AbstractJsIrTest(
testGroupOutputDirPrefix = "codegen/wasmJsInteropJs"
)
private class SkipMultiModuleTestsMetaConfigurator(testServices: TestServices) : MetaTestConfigurator(testServices) {
override fun shouldSkipTest(): Boolean {
return testServices.moduleStructure.originalTestDataFiles.any {
it.isDirectiveDefined("// IGNORE_FIR")
}
}
}
open class AbstractFirJsTest(
pathToTestDir: String = "${JsEnvironmentConfigurator.TEST_DATA_DIR_PATH}/box/",
testGroupOutputDirPrefix: String = "firBox/",
@@ -246,3 +250,72 @@ open class AbstractFirJsTest(
}
}
}
open class AbstractFirBoxJsTest : AbstractFirJsTest(
pathToTestDir = "${JsEnvironmentConfigurator.TEST_DATA_DIR_PATH}/box/",
testGroupOutputDirPrefix = "irBox/"
)
open class AbstractFirJsCodegenBoxTest : AbstractFirJsTest(
pathToTestDir = "compiler/testData/codegen/box/",
testGroupOutputDirPrefix = "codegen/irBox/"
) {
override fun configure(builder: TestConfigurationBuilder) {
super.configure(builder)
builder.configureFirHandlersStep {
commonFirHandlersForCodegenTest()
}
builder.useAfterAnalysisCheckers(
::FirMetaInfoDiffSuppressor
)
}
}
open class AbstractFirJsCodegenBoxErrorTest : AbstractFirJsTest(
pathToTestDir = "compiler/testData/codegen/boxError/",
testGroupOutputDirPrefix = "codegen/irBoxError/"
)
open class AbstractFirJsCodegenInlineTest : AbstractFirJsTest(
pathToTestDir = "compiler/testData/codegen/boxInline/",
testGroupOutputDirPrefix = "codegen/irBoxInline/"
)
// TODO: implement method order independent comparison to reuse testdata, disabled for now
//open class AbstractFirJsTypeScriptExportTest : AbstractFirJsTest(
// pathToTestDir = "${JsEnvironmentConfigurator.TEST_DATA_DIR_PATH}/typescript-export/",
// testGroupOutputDirPrefix = "typescript-export/"
//) {
// override fun configure(builder: TestConfigurationBuilder) {
// super.configure(builder)
// configureIrJsTypeScriptExportTest(builder)
// }
//}
// TODO: implement separate expectations for FIR/JS to reuse testdata, disabled for now
//open class AbstractJsFirLineNumberTest : AbstractFirJsTest(
// pathToTestDir = "${JsEnvironmentConfigurator.TEST_DATA_DIR_PATH}/lineNumbers/",
// testGroupOutputDirPrefix = "irLineNumbers/"
//) {
// override fun configure(builder: TestConfigurationBuilder) {
// super.configure(builder)
// configureJsIrLineNumberTest(builder)
// }
//}
// TODO: implement separate expectations for FIR/JS to reuse testdata, disabled for now
//open class AbstractFirJsSteppingTest : AbstractFirJsTest(
// pathToTestDir = "compiler/testData/debug/stepping/",
// testGroupOutputDirPrefix = "debug/stepping/"
//) {
// override fun TestConfigurationBuilder.configuration() {
// commonConfigurationForJsBlackBoxCodegenTest()
// configurationForIrJsSteppingTest()
// }
//}
open class AbstractFirCodegenWasmJsInteropJsTest : AbstractFirJsTest(
pathToTestDir = "compiler/testData/codegen/wasmJsInterop",
testGroupOutputDirPrefix = "codegen/wasmJsInteropJs"
)
@@ -19,7 +19,7 @@ import java.util.regex.Pattern;
@SuppressWarnings("all")
@TestMetadata("js/js.translator/testData/box")
@TestDataPath("$PROJECT_ROOT")
public class FirJsTestGenerated extends AbstractFirJsTest {
public class FirBoxJsTestGenerated extends AbstractFirBoxJsTest {
@Test
public void testAllFilesPresentInBox() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("js/js.translator/testData/box"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.JS_IR, true);
@@ -0,0 +1,81 @@
/*
* 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.js.test.ir;
import com.intellij.testFramework.TestDataPath;
import org.jetbrains.kotlin.test.util.KtTestUtil;
import org.jetbrains.kotlin.test.TargetBackend;
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.GenerateJsTestsKt}. DO NOT MODIFY MANUALLY */
@SuppressWarnings("all")
@TestMetadata("compiler/testData/codegen/boxWasmJsInterop")
@TestDataPath("$PROJECT_ROOT")
public class FirCodegenWasmJsInteropJsTestGenerated extends AbstractFirCodegenWasmJsInteropJsTest {
@Test
public void testAllFilesPresentInBoxWasmJsInterop() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/boxWasmJsInterop"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true);
}
@Test
@TestMetadata("defaultValues.kt")
public void testDefaultValues() throws Exception {
runTest("compiler/testData/codegen/boxWasmJsInterop/defaultValues.kt");
}
@Test
@TestMetadata("externalTypeOperators.kt")
public void testExternalTypeOperators() throws Exception {
runTest("compiler/testData/codegen/boxWasmJsInterop/externalTypeOperators.kt");
}
@Test
@TestMetadata("externals.kt")
public void testExternals() throws Exception {
runTest("compiler/testData/codegen/boxWasmJsInterop/externals.kt");
}
@Test
@TestMetadata("functionTypes.kt")
public void testFunctionTypes() throws Exception {
runTest("compiler/testData/codegen/boxWasmJsInterop/functionTypes.kt");
}
@Test
@TestMetadata("jsExport.kt")
public void testJsExport() throws Exception {
runTest("compiler/testData/codegen/boxWasmJsInterop/jsExport.kt");
}
@Test
@TestMetadata("jsToKotlinAdapters.kt")
public void testJsToKotlinAdapters() throws Exception {
runTest("compiler/testData/codegen/boxWasmJsInterop/jsToKotlinAdapters.kt");
}
@Test
@TestMetadata("kotlinToJsAdapters.kt")
public void testKotlinToJsAdapters() throws Exception {
runTest("compiler/testData/codegen/boxWasmJsInterop/kotlinToJsAdapters.kt");
}
@Test
@TestMetadata("longStrings.kt")
public void testLongStrings() throws Exception {
runTest("compiler/testData/codegen/boxWasmJsInterop/longStrings.kt");
}
@Test
@TestMetadata("types.kt")
public void testTypes() throws Exception {
runTest("compiler/testData/codegen/boxWasmJsInterop/types.kt");
}
}
@@ -0,0 +1,131 @@
/*
* 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.js.test.ir;
import com.intellij.testFramework.TestDataPath;
import org.jetbrains.kotlin.test.util.KtTestUtil;
import org.jetbrains.kotlin.test.TargetBackend;
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.GenerateJsTestsKt}. DO NOT MODIFY MANUALLY */
@SuppressWarnings("all")
@TestMetadata("compiler/testData/codegen/boxError")
@TestDataPath("$PROJECT_ROOT")
public class FirJsCodegenBoxErrorTestGenerated extends AbstractFirJsCodegenBoxErrorTest {
@Test
public void testAllFilesPresentInBoxError() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/boxError"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true, "compileKotlinAgainstKotlin");
}
@Nested
@TestMetadata("compiler/testData/codegen/boxError/semantic")
@TestDataPath("$PROJECT_ROOT")
public class Semantic {
@Test
public void testAllFilesPresentInSemantic() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/boxError/semantic"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true);
}
@Test
@TestMetadata("castToErrorType.kt")
public void testCastToErrorType() throws Exception {
runTest("compiler/testData/codegen/boxError/semantic/castToErrorType.kt");
}
@Test
@TestMetadata("catchErrorType.kt")
public void testCatchErrorType() throws Exception {
runTest("compiler/testData/codegen/boxError/semantic/catchErrorType.kt");
}
@Test
@TestMetadata("evaluationOrder.kt")
public void testEvaluationOrder() throws Exception {
runTest("compiler/testData/codegen/boxError/semantic/evaluationOrder.kt");
}
@Test
@TestMetadata("mismatchTypeParameters.kt")
public void testMismatchTypeParameters() throws Exception {
runTest("compiler/testData/codegen/boxError/semantic/mismatchTypeParameters.kt");
}
@Test
@TestMetadata("missedBody.kt")
public void testMissedBody() throws Exception {
runTest("compiler/testData/codegen/boxError/semantic/missedBody.kt");
}
@Test
@TestMetadata("reifiedNonInline.kt")
public void testReifiedNonInline() throws Exception {
runTest("compiler/testData/codegen/boxError/semantic/reifiedNonInline.kt");
}
@Test
@TestMetadata("reifiedWithWrongArguments.kt")
public void testReifiedWithWrongArguments() throws Exception {
runTest("compiler/testData/codegen/boxError/semantic/reifiedWithWrongArguments.kt");
}
@Test
@TestMetadata("typeMismatch.kt")
public void testTypeMismatch() throws Exception {
runTest("compiler/testData/codegen/boxError/semantic/typeMismatch.kt");
}
@Test
@TestMetadata("unmatchedArguments.kt")
public void testUnmatchedArguments() throws Exception {
runTest("compiler/testData/codegen/boxError/semantic/unmatchedArguments.kt");
}
@Test
@TestMetadata("unresolvedFunctionReferece.kt")
public void testUnresolvedFunctionReferece() throws Exception {
runTest("compiler/testData/codegen/boxError/semantic/unresolvedFunctionReferece.kt");
}
}
@Nested
@TestMetadata("compiler/testData/codegen/boxError/syntax")
@TestDataPath("$PROJECT_ROOT")
public class Syntax {
@Test
public void testAllFilesPresentInSyntax() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/boxError/syntax"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true);
}
@Test
@TestMetadata("arrowReference.kt")
public void testArrowReference() throws Exception {
runTest("compiler/testData/codegen/boxError/syntax/arrowReference.kt");
}
@Test
@TestMetadata("evaluationOrder.kt")
public void testEvaluationOrder() throws Exception {
runTest("compiler/testData/codegen/boxError/syntax/evaluationOrder.kt");
}
@Test
@TestMetadata("incorectLexicalName.kt")
public void testIncorectLexicalName() throws Exception {
runTest("compiler/testData/codegen/boxError/syntax/incorectLexicalName.kt");
}
@Test
@TestMetadata("missedArgument.kt")
public void testMissedArgument() throws Exception {
runTest("compiler/testData/codegen/boxError/syntax/missedArgument.kt");
}
}
}
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -2,6 +2,7 @@
// EXPECTED_REACHABLE_NODES: 1270
// SKIP_MINIFICATION
// ES_MODULES
// WITH_STDLIB
// MODULE: vararg
// FILE: lib.kt