[Gradle] Fix NewMultiplatformIT.testLanguageSettingsApplied

KTIJ-24976
This commit is contained in:
Sebastian Sellmair
2023-03-29 13:41:01 +02:00
committed by Space Team
parent cc47fb3d31
commit 2b086946ef
2 changed files with 36 additions and 12 deletions
@@ -341,6 +341,7 @@ open class NewMultiplatformIT : BaseGradleIT() {
assertTasksExecuted(*compileTasksNames.toTypedArray(), ":allMetadataJar")
val groupDir = projectDir.resolve("repo/com/example")
@Suppress("DEPRECATION")
val jsExtension = if (jsCompilerType == KotlinJsCompilerType.LEGACY) "jar" else "klib"
val jsJarName = "sample-lib-nodejs/1.0/sample-lib-nodejs-1.0.$jsExtension"
@@ -830,10 +831,16 @@ open class NewMultiplatformIT : BaseGradleIT() {
build(task) {
assertSuccessful()
assertTasksExecuted(":$task")
val arguments = parseCompilerArguments<K2NativeCompilerArguments>()
assertTrue(arguments.progressiveMode, "Expected progressiveMode")
assertTrue(arguments.noInline, "Expected no-inline")
assertEquals(
setOf("kotlin.ExperimentalUnsignedTypes", "kotlin.contracts.ExperimentalContracts"),
arguments.optIn?.toSet()
)
assertContains(
"-XXLanguage:+InlineClasses",
"-progressive", "-opt-in=kotlin.ExperimentalUnsignedTypes",
"-opt-in=kotlin.contracts.ExperimentalContracts",
"-progressive",
"-Xno-inline"
)
}
@@ -1561,8 +1568,9 @@ open class NewMultiplatformIT : BaseGradleIT() {
"jvm6", "nodeJs", "mingw64", "mingw86", "linux64", "macos64", "linuxMipsel32", "wasm"
).flatMapTo(mutableSetOf()) { target ->
listOf("main", "test").map { compilation ->
Triple(target, compilation,
"$target${compilation.replaceFirstChar { if (it.isLowerCase()) it.titlecase(Locale.getDefault()) else it.toString() }}"
Triple(
target, compilation,
"$target${compilation.replaceFirstChar { if (it.isLowerCase()) it.titlecase(Locale.getDefault()) else it.toString() }}"
)
}
} + Triple("metadata", "main", "commonMain")
@@ -1771,7 +1779,8 @@ open class NewMultiplatformIT : BaseGradleIT() {
Locale.getDefault()
) else it.toString()
}
}" }
}"
}
build(
*tasks.toTypedArray()
@@ -1956,12 +1965,14 @@ open class NewMultiplatformIT : BaseGradleIT() {
}
@Test
fun testWasmJs() = with(Project(
"new-mpp-wasm-js",
// TODO: this test fails with deprecation error on Gradle <7.0
// Should be fixed via planned fixes in Kotlin/JS plugin: https://youtrack.jetbrains.com/issue/KFC-252
gradleVersionRequirement = GradleVersionRequired.AtLeast(TestVersions.Gradle.G_7_0)
)) {
fun testWasmJs() = with(
Project(
"new-mpp-wasm-js",
// TODO: this test fails with deprecation error on Gradle <7.0
// Should be fixed via planned fixes in Kotlin/JS plugin: https://youtrack.jetbrains.com/issue/KFC-252
gradleVersionRequirement = GradleVersionRequired.AtLeast(TestVersions.Gradle.G_7_0)
)
) {
setupWorkingDir()
gradleBuildScript().modify(::transformBuildScriptWithPluginsDsl)
build("build") {
@@ -8,14 +8,27 @@ package org.jetbrains.kotlin.gradle.util
import org.gradle.testkit.runner.BuildResult
import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments
import org.jetbrains.kotlin.cli.common.arguments.parseCommandLineArguments
import org.jetbrains.kotlin.gradle.BaseGradleIT
import kotlin.reflect.KClass
inline fun <reified T : CommonCompilerArguments> BuildResult.parseCompilerArguments(): T {
return parseCompilerArguments(T::class)
}
inline fun <reified T : CommonCompilerArguments> BaseGradleIT.CompiledProject.parseCompilerArguments(): T {
return parseCompilerArguments(T::class)
}
fun <T : CommonCompilerArguments> BuildResult.parseCompilerArguments(type: KClass<T>): T {
val arguments = findCommandLineArguments(output).lines().map { it.trim() }
return parseCompilerArgumentsFromBuildOutput(type, output)
}
fun <T : CommonCompilerArguments> BaseGradleIT.CompiledProject.parseCompilerArguments(type: KClass<T>): T {
return parseCompilerArgumentsFromBuildOutput(type, output)
}
fun <T : CommonCompilerArguments> parseCompilerArgumentsFromBuildOutput(type: KClass<T>, buildOutput: String): T {
val arguments = findCommandLineArguments(buildOutput).lines().map { it.trim() }
return parseCommandLineArguments(type, arguments)
}