[Gradle, JS] DCE and minimized names could be falsify
[Gradle, JS] Add test on falsify compiler flags [Gradle, JS] DCE and minimized names could be falsify Merge-request: KT-MR-6167 Merged-by: Ilya Goncharov <Ilya.Goncharov@jetbrains.com> ^KT-51957 fixed
This commit is contained in:
+32
@@ -219,6 +219,38 @@ class Kotlin2JsIrGradlePluginIT : AbstractKotlin2JsGradlePluginIT(true) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@DisplayName("falsify kotlin js compiler args")
|
||||
@GradleTest
|
||||
fun testFalsifyKotlinJsCompilerArgs(gradleVersion: GradleVersion) {
|
||||
project("simple-js-executable", gradleVersion) {
|
||||
buildGradleKts.appendText(
|
||||
"""
|
||||
|
|
||||
|tasks.named<org.jetbrains.kotlin.gradle.targets.js.ir.KotlinJsIrLink>("compileProductionExecutableKotlinJs").configure {
|
||||
| kotlinOptions {
|
||||
| freeCompilerArgs += "-Xir-dce=false"
|
||||
| freeCompilerArgs += "-Xir-minimized-member-names=false"
|
||||
| }
|
||||
|
|
||||
| doLast {
|
||||
| kotlinOptions {
|
||||
| if (freeCompilerArgs.single { it.startsWith("-Xir-dce") } != "-Xir-dce=false") throw GradleException("fail1")
|
||||
| if (
|
||||
| freeCompilerArgs
|
||||
| .single { it.startsWith("-Xir-minimized-member-names") } != "-Xir-minimized-member-names=false"
|
||||
| ) throw GradleException("fail2")
|
||||
| }
|
||||
| }
|
||||
|}
|
||||
""".trimMargin()
|
||||
)
|
||||
|
||||
build("build") {
|
||||
assertFileInProjectNotExists("build/js/packages/kotlin-js-nodejs/kotlin/")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@JsGradlePluginTests
|
||||
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
plugins {
|
||||
kotlin("js")
|
||||
}
|
||||
|
||||
group = "com.example"
|
||||
version = "1.0"
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
kotlin {
|
||||
js {
|
||||
binaries.executable()
|
||||
nodejs()
|
||||
}
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
rootProject.name = "js-executable"
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
/*
|
||||
* Copyright 2010-2019 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 com.example
|
||||
|
||||
fun main() {
|
||||
println("Hello, Yarn")
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
console.log("hello")
|
||||
+6
-1
@@ -179,7 +179,12 @@ abstract class KotlinJsIrLink @Inject constructor(
|
||||
}
|
||||
|
||||
private fun KotlinJsOptions.configureOptions(vararg additionalCompilerArgs: String) {
|
||||
freeCompilerArgs += additionalCompilerArgs.toList() +
|
||||
freeCompilerArgs += additionalCompilerArgs
|
||||
.mapNotNull { arg ->
|
||||
if (kotlinOptions.freeCompilerArgs
|
||||
.any { it.startsWith(arg) }
|
||||
) null else arg
|
||||
} +
|
||||
PRODUCE_JS +
|
||||
"$ENTRY_IR_MODULE=${entryModule.get().asFile.canonicalPath}"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user