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"
)