From b672e5c131607dd8d117820fd9e82c67b1336a11 Mon Sep 17 00:00:00 2001 From: Alexander Korepanov Date: Tue, 16 Jan 2024 11:59:35 +0100 Subject: [PATCH] [JS FIR Tests] Add source map smoke test for FIR ^KT-64450 Fixed --- .../generators/tests/GenerateJsTests.kt | 4 ++ .../kotlin/js/test/fir/AbstractJsFirTest.kt | 16 ++++++ .../kotlin/js/test/ir/AbstractJsIrTest.kt | 2 +- ...SourceMapGenerationSmokeTestGenerated.java | 51 +++++++++++++++++++ 4 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirSourceMapGenerationSmokeTestGenerated.java diff --git a/js/js.tests/test/org/jetbrains/kotlin/generators/tests/GenerateJsTests.kt b/js/js.tests/test/org/jetbrains/kotlin/generators/tests/GenerateJsTests.kt index e71e029af4e..f39b8c21c62 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/generators/tests/GenerateJsTests.kt +++ b/js/js.tests/test/org/jetbrains/kotlin/generators/tests/GenerateJsTests.kt @@ -171,6 +171,10 @@ fun main(args: Array) { testClass { model("lineNumbers/") } + + testClass { + model("sourcemap/") + } } testGroup("js/js.tests/tests-gen", "compiler/testData", testRunnerMethodName = "runTest0") { diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/fir/AbstractJsFirTest.kt b/js/js.tests/test/org/jetbrains/kotlin/js/test/fir/AbstractJsFirTest.kt index bb8440689bc..b0256b3e7b0 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/fir/AbstractJsFirTest.kt +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/fir/AbstractJsFirTest.kt @@ -8,6 +8,7 @@ import org.jetbrains.kotlin.js.test.converters.incremental.RecompileModuleJsIrBa import org.jetbrains.kotlin.js.test.handlers.JsDebugRunner import org.jetbrains.kotlin.js.test.handlers.JsIrRecompiledArtifactsIdentityHandler import org.jetbrains.kotlin.js.test.handlers.createFirJsLineNumberHandler +import org.jetbrains.kotlin.js.test.ir.AbstractJsIrTest import org.jetbrains.kotlin.parsing.parseBoolean import org.jetbrains.kotlin.test.Constructor import org.jetbrains.kotlin.test.FirParser @@ -163,6 +164,21 @@ open class AbstractFirJsLineNumberTest : AbstractFirJsTest( } } +open class AbstractFirSourceMapGenerationSmokeTest : AbstractFirJsTest( + pathToTestDir = "${JsEnvironmentConfigurator.TEST_DATA_DIR_PATH}/sourcemap/", + testGroupOutputDirPrefix = "firSourcemap/" +) { + override fun configure(builder: TestConfigurationBuilder) { + super.configure(builder) + with(builder) { + defaultDirectives { + +JsEnvironmentConfigurationDirectives.GENERATE_SOURCE_MAP + -JsEnvironmentConfigurationDirectives.GENERATE_NODE_JS_RUNNER + } + } + } +} + open class AbstractFirJsSteppingTest : AbstractFirJsTest( pathToTestDir = "compiler/testData/debug/stepping/", testGroupOutputDirPrefix = "debug/firStepping/" diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/ir/AbstractJsIrTest.kt b/js/js.tests/test/org/jetbrains/kotlin/js/test/ir/AbstractJsIrTest.kt index d4ee9314df4..93a0c2a1e34 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/ir/AbstractJsIrTest.kt +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/ir/AbstractJsIrTest.kt @@ -154,7 +154,7 @@ open class AbstractJsIrLineNumberTest : AbstractJsIrTest( open class AbstractSourceMapGenerationSmokeTest : AbstractJsIrTest( pathToTestDir = "${JsEnvironmentConfigurator.TEST_DATA_DIR_PATH}/sourcemap/", - testGroupOutputDirPrefix = "sourcemap/" + testGroupOutputDirPrefix = "irSourcemap/" ) { override fun configure(builder: TestConfigurationBuilder) { super.configure(builder) diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirSourceMapGenerationSmokeTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirSourceMapGenerationSmokeTestGenerated.java new file mode 100644 index 00000000000..aaa35113771 --- /dev/null +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirSourceMapGenerationSmokeTestGenerated.java @@ -0,0 +1,51 @@ +/* + * Copyright 2010-2024 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.fir; + +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("js/js.translator/testData/sourcemap") +@TestDataPath("$PROJECT_ROOT") +public class FirSourceMapGenerationSmokeTestGenerated extends AbstractFirSourceMapGenerationSmokeTest { + @Test + public void testAllFilesPresentInSourcemap() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("js/js.translator/testData/sourcemap"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true); + } + + @Test + @TestMetadata("binaryOperation.kt") + public void testBinaryOperation() throws Exception { + runTest("js/js.translator/testData/sourcemap/binaryOperation.kt"); + } + + @Test + @TestMetadata("emptyIfInsideInlineLambda.kt") + public void testEmptyIfInsideInlineLambda() throws Exception { + runTest("js/js.translator/testData/sourcemap/emptyIfInsideInlineLambda.kt"); + } + + @Test + @TestMetadata("expressionBody.kt") + public void testExpressionBody() throws Exception { + runTest("js/js.translator/testData/sourcemap/expressionBody.kt"); + } + + @Test + @TestMetadata("methodCallInMethod.kt") + public void testMethodCallInMethod() throws Exception { + runTest("js/js.translator/testData/sourcemap/methodCallInMethod.kt"); + } +}