Fix flaky JS tests.

They are disabling error for using JS/Legacy backend via System property
by passing it to the Kotlin Daemon. But daemon may already be started
and not contain such property.

Workaround for now is to use 'in-process' compilation for such cases.
This commit is contained in:
Yahor Berdnikau
2023-02-07 14:05:45 +01:00
committed by Space Team
parent 78dc59f759
commit 4e705d2f40
5 changed files with 53 additions and 8 deletions
@@ -322,6 +322,13 @@ class NewMultiplatformIT : BaseGradleIT() {
).map { ":compileKotlin$it" } ).map { ":compileKotlin$it" }
with(libProject) { with(libProject) {
gradleProperties().appendText(
"""
systemProp.kotlin.js.compiler.legacy.force_enabled=true
kotlin.compiler.execution.strategy=in-process
""".trimIndent()
)
build( build(
"publish", "publish",
options = defaultBuildOptions().copy(jsCompilerType = jsCompilerType) options = defaultBuildOptions().copy(jsCompilerType = jsCompilerType)
@@ -378,6 +385,14 @@ class NewMultiplatformIT : BaseGradleIT() {
with(appProject) { with(appProject) {
setupWorkingDir() setupWorkingDir()
gradleProperties().appendText(
"""
systemProp.kotlin.js.compiler.legacy.force_enabled=true
kotlin.compiler.execution.strategy=in-process
""".trimIndent()
)
// we use `maven { setUrl(...) }` because this syntax actually works both for Groovy and Kotlin DSLs in Gradle // we use `maven { setUrl(...) }` because this syntax actually works both for Groovy and Kotlin DSLs in Gradle
gradleBuildScript().appendText("\nrepositories { maven { setUrl(\"$libLocalRepoUri\") } }") gradleBuildScript().appendText("\nrepositories { maven { setUrl(\"$libLocalRepoUri\") } }")
@@ -973,6 +988,14 @@ class NewMultiplatformIT : BaseGradleIT() {
val appProject = Project("sample-app", gradleVersion, "new-mpp-lib-and-app") val appProject = Project("sample-app", gradleVersion, "new-mpp-lib-and-app")
val buildOptions = hmppFlags.buildOptions val buildOptions = hmppFlags.buildOptions
libProject.setupWorkingDir()
libProject.gradleProperties().appendText(
"""
systemProp.kotlin.js.compiler.legacy.force_enabled=true
kotlin.compiler.execution.strategy=in-process
""".trimIndent()
)
@Suppress("DEPRECATION") @Suppress("DEPRECATION")
libProject.build( libProject.build(
"publish", "publish",
@@ -986,6 +1009,14 @@ class NewMultiplatformIT : BaseGradleIT() {
with(appProject) { with(appProject) {
setupWorkingDir() setupWorkingDir()
gradleProperties().appendText(
"""
systemProp.kotlin.js.compiler.legacy.force_enabled=true
kotlin.compiler.execution.strategy=in-process
""".trimIndent()
)
val pathPrefix = "metadataDependency: " val pathPrefix = "metadataDependency: "
gradleBuildScript().appendText( gradleBuildScript().appendText(
@@ -1463,6 +1494,15 @@ class NewMultiplatformIT : BaseGradleIT() {
@Test @Test
fun testJsDceInMpp() = with(Project("new-mpp-js-dce", gradleVersion)) { fun testJsDceInMpp() = with(Project("new-mpp-js-dce", gradleVersion)) {
setupWorkingDir()
gradleProperties().appendText(
"""
systemProp.kotlin.js.compiler.legacy.force_enabled=true
kotlin.compiler.execution.strategy=in-process
""".trimIndent()
)
@Suppress("DEPRECATION") @Suppress("DEPRECATION")
build( build(
"runRhino", "runRhino",
@@ -1593,6 +1633,8 @@ class NewMultiplatformIT : BaseGradleIT() {
@Test @Test
fun testIncrementalCompilation() = with(Project("new-mpp-jvm-js-ic", gradleVersion)) { fun testIncrementalCompilation() = with(Project("new-mpp-jvm-js-ic", gradleVersion)) {
setupWorkingDir()
build("build") { build("build") {
assertSuccessful() assertSuccessful()
} }
@@ -1634,6 +1676,14 @@ class NewMultiplatformIT : BaseGradleIT() {
setupWorkingDir() setupWorkingDir()
gradleBuildScript().modify(::transformBuildScriptWithPluginsDsl) gradleBuildScript().modify(::transformBuildScriptWithPluginsDsl)
gradleProperties().appendText(
"""
systemProp.kotlin.js.compiler.legacy.force_enabled=true
kotlin.compiler.execution.strategy=in-process
""".trimIndent()
)
val groupDir = "build/repo/com/example/" val groupDir = "build/repo/com/example/"
build(":mpp-lib:publish") { build(":mpp-lib:publish") {
@@ -1 +0,0 @@
kotlin.daemon.jvmargs=-Dkotlin.js.compiler.legacy.force_enabled=true
@@ -1,10 +1,9 @@
apply plugin: "kotlin-multiplatform" apply plugin: "kotlin-multiplatform"
kotlin { kotlin {
targets { jvm {}
fromPreset(presets.jvm, 'jvm') js(IR) {}
fromPreset(presets.js, 'js')
}
sourceSets { sourceSets {
commonMain { commonMain {
dependencies { dependencies {
@@ -1,2 +0,0 @@
kotlin.js.compiler=legacy
kotlin.daemon.jvmargs=-Dkotlin.js.compiler.legacy.force_enabled=true
@@ -1 +0,0 @@
kotlin.daemon.jvmargs=-Dkotlin.js.compiler.legacy.force_enabled=true