[K/JS] Add a secret system property to enable the old Kotlin/JS compiler only for tests until it will be removed from the sources
This commit is contained in:
@@ -11,6 +11,7 @@ import com.intellij.mock.MockProject
|
||||
import com.intellij.openapi.project.Project
|
||||
import org.jetbrains.kotlin.analyzer.AnalysisResult
|
||||
import org.jetbrains.kotlin.cli.common.CLITool
|
||||
import org.jetbrains.kotlin.cli.common.CompilerSystemProperties
|
||||
import org.jetbrains.kotlin.cli.common.ExitCode
|
||||
import org.jetbrains.kotlin.cli.js.K2JSCompiler
|
||||
import org.jetbrains.kotlin.cli.jvm.K2JVMCompiler
|
||||
@@ -70,6 +71,12 @@ class AnalysisHandlerExtensionTest : TestCaseWithTmpdir() {
|
||||
listOf("-Xuse-deprecated-legacy-compiler", "-output", tmpdir.resolve("out.js").absolutePath)
|
||||
else
|
||||
listOf("-d", tmpdir.resolve("out").absolutePath)
|
||||
|
||||
if (compiler is K2JSCompiler) {
|
||||
// TODO: It will be deleted after all of our internal vendors will use the new Kotlin/JS compiler
|
||||
CompilerSystemProperties.KOTLIN_JS_COMPILER_LEGACY_FORCE_ENABLED.value = "true"
|
||||
}
|
||||
|
||||
val (output, exitCode) = CompilerTestUtil.executeCompiler(compiler, args + outputPath + extras)
|
||||
assertEquals(expectedExitCode, exitCode, output)
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ package org.jetbrains.kotlin.cli
|
||||
|
||||
import com.intellij.openapi.util.SystemInfo
|
||||
import com.intellij.openapi.util.text.StringUtil
|
||||
import org.jetbrains.kotlin.cli.common.CompilerSystemProperties
|
||||
import org.jetbrains.kotlin.cli.common.ExitCode
|
||||
import org.jetbrains.kotlin.cli.jvm.K2JVMCompiler
|
||||
import org.jetbrains.kotlin.test.KotlinTestUtils
|
||||
@@ -142,7 +143,12 @@ class LauncherScriptTest : TestCaseWithTmpdir() {
|
||||
runProcess(
|
||||
"kotlinc-js",
|
||||
"$testDataDirectory/emptyMain.kt",
|
||||
"-Xlegacy-deprecated-no-warn", "-Xuse-deprecated-legacy-compiler", "-output", File(tmpdir, "out.js").path
|
||||
"-nowarn",
|
||||
"-Xlegacy-deprecated-no-warn",
|
||||
"-Xuse-deprecated-legacy-compiler",
|
||||
"-D${CompilerSystemProperties.KOTLIN_JS_COMPILER_LEGACY_FORCE_ENABLED.property}=true",
|
||||
"-output",
|
||||
File(tmpdir, "out.js").path,
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
+19
-2
@@ -7,6 +7,7 @@ package org.jetbrains.kotlin.jvm.compiler
|
||||
|
||||
import com.intellij.openapi.util.io.FileUtil
|
||||
import org.jetbrains.kotlin.cli.common.CLICompiler
|
||||
import org.jetbrains.kotlin.cli.common.CompilerSystemProperties
|
||||
import org.jetbrains.kotlin.cli.common.ExitCode
|
||||
import org.jetbrains.kotlin.cli.common.messages.AnalyzerWithCompilerReport
|
||||
import org.jetbrains.kotlin.cli.common.messages.MessageRenderer
|
||||
@@ -101,7 +102,13 @@ class CompileKotlinAgainstCustomBinariesTest : AbstractKotlinCompilerIntegration
|
||||
|
||||
private fun doTestKotlinLibraryWithWrongMetadataVersionJs(libraryName: String, vararg additionalOptions: String) {
|
||||
val library = compileJsLibrary(libraryName, additionalOptions = listOf("-Xmetadata-version=42.0.0"))
|
||||
compileKotlin("source.kt", File(tmpdir, "usage.js"), listOf(library), K2JSCompiler(), additionalOptions.toList())
|
||||
compileKotlin(
|
||||
"source.kt",
|
||||
File(tmpdir, "usage.js"),
|
||||
listOf(library),
|
||||
K2JSCompiler(),
|
||||
additionalOptions.toList()
|
||||
)
|
||||
}
|
||||
|
||||
private fun doTestPreReleaseKotlinLibrary(
|
||||
@@ -130,6 +137,11 @@ class CompileKotlinAgainstCustomBinariesTest : AbstractKotlinCompilerIntegration
|
||||
else -> throw UnsupportedOperationException(compiler.toString())
|
||||
}
|
||||
|
||||
if (compiler is K2JSCompiler) {
|
||||
// TODO: It will be deleted after all of our internal vendors will use the new Kotlin/JS compiler
|
||||
CompilerSystemProperties.KOTLIN_JS_COMPILER_LEGACY_FORCE_ENABLED.value = "true"
|
||||
}
|
||||
|
||||
compileKotlin(
|
||||
"source.kt", usageDestination, listOf(result), compiler,
|
||||
additionalOptions.toList() + listOf("-language-version", LanguageVersion.LATEST_STABLE.versionString)
|
||||
@@ -590,7 +602,12 @@ class CompileKotlinAgainstCustomBinariesTest : AbstractKotlinCompilerIntegration
|
||||
}
|
||||
|
||||
fun testInternalFromForeignModuleJs() {
|
||||
compileKotlin("source.kt", File(tmpdir, "usage.js"), listOf(compileJsLibrary("library")), K2JSCompiler())
|
||||
compileKotlin(
|
||||
"source.kt",
|
||||
File(tmpdir, "usage.js"),
|
||||
listOf(compileJsLibrary("library")),
|
||||
K2JSCompiler(),
|
||||
)
|
||||
}
|
||||
|
||||
fun testInternalFromFriendModuleJs() {
|
||||
|
||||
+3
@@ -18,6 +18,7 @@ package org.jetbrains.kotlin.multiplatform
|
||||
|
||||
import org.jetbrains.kotlin.cli.AbstractCliTest
|
||||
import org.jetbrains.kotlin.cli.common.CLICompiler
|
||||
import org.jetbrains.kotlin.cli.common.CompilerSystemProperties
|
||||
import org.jetbrains.kotlin.cli.js.K2JSCompiler
|
||||
import org.jetbrains.kotlin.cli.jvm.K2JVMCompiler
|
||||
import org.jetbrains.kotlin.cli.metadata.K2MetadataCompiler
|
||||
@@ -65,6 +66,8 @@ abstract class AbstractMultiPlatformIntegrationTest : KtUsefulTestCase() {
|
||||
if (jsSrc != null) {
|
||||
appendLine()
|
||||
appendLine("-- JS --")
|
||||
// TODO: It will be deleted after all of our internal vendors will use the new Kotlin/JS compiler
|
||||
CompilerSystemProperties.KOTLIN_JS_COMPILER_LEGACY_FORCE_ENABLED.value = "true"
|
||||
appendLine(K2JSCompiler().compile(jsSrc, commonSrc, "-Xuse-deprecated-legacy-compiler", "-output", jsDest!!))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user