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" }
with(libProject) {
gradleProperties().appendText(
"""
systemProp.kotlin.js.compiler.legacy.force_enabled=true
kotlin.compiler.execution.strategy=in-process
""".trimIndent()
)
build(
"publish",
options = defaultBuildOptions().copy(jsCompilerType = jsCompilerType)
@@ -378,6 +385,14 @@ class NewMultiplatformIT : BaseGradleIT() {
with(appProject) {
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
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 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")
libProject.build(
"publish",
@@ -986,6 +1009,14 @@ class NewMultiplatformIT : BaseGradleIT() {
with(appProject) {
setupWorkingDir()
gradleProperties().appendText(
"""
systemProp.kotlin.js.compiler.legacy.force_enabled=true
kotlin.compiler.execution.strategy=in-process
""".trimIndent()
)
val pathPrefix = "metadataDependency: "
gradleBuildScript().appendText(
@@ -1463,6 +1494,15 @@ class NewMultiplatformIT : BaseGradleIT() {
@Test
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")
build(
"runRhino",
@@ -1593,6 +1633,8 @@ class NewMultiplatformIT : BaseGradleIT() {
@Test
fun testIncrementalCompilation() = with(Project("new-mpp-jvm-js-ic", gradleVersion)) {
setupWorkingDir()
build("build") {
assertSuccessful()
}
@@ -1634,6 +1676,14 @@ class NewMultiplatformIT : BaseGradleIT() {
setupWorkingDir()
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/"
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"
kotlin {
targets {
fromPreset(presets.jvm, 'jvm')
fromPreset(presets.js, 'js')
}
jvm {}
js(IR) {}
sourceSets {
commonMain {
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