[Gradle] [MPP] Implement integration test to cover ^KT-48856

This commit is contained in:
sebastian.sellmair
2021-09-24 09:56:52 +02:00
committed by Space
parent 9799ad7bd8
commit e7d8804bdf
8 changed files with 93 additions and 1 deletions
@@ -386,6 +386,27 @@ class CommonizerIT : BaseGradleIT() {
}
}
@Test
fun `test KT-48856 single native target dependency propagation - test source set - cinterop`() {
fun CompiledProject.containsCinteropDependency(): Boolean {
val nativeMainContainsCInteropDependencyRegex = Regex(""".*Dependency:.*cinterop-sampleInterop.*""")
return output.lineSequence().any { line ->
line.matches(nativeMainContainsCInteropDependencyRegex)
}
}
with(Project("commonize-kt-48856-singleNativeTargetPropagation-testSourceSet")) {
build("listNativeTestDependencies") {
assertSuccessful()
assertTrue(containsCinteropDependency(), "Expected sourceSet 'nativeTest' to list cinterop dependency")
}
build("assemble") {
assertSuccessful()
}
}
}
@Test
fun `test KT-46856 filename too long - all native targets configured`() {
with(Project("commonize-kt-46856-all-targets")) {
@@ -663,4 +684,3 @@ private object CommonizableTargets {
else -> fail("Unsupported os: ${os.name}")
}
}
@@ -0,0 +1,40 @@
import org.jetbrains.kotlin.gradle.plugin.sources.DefaultKotlinSourceSet
import org.jetbrains.kotlin.konan.target.HostManager
plugins {
kotlin("multiplatform")
}
repositories {
mavenCentral()
mavenLocal()
}
kotlin {
val platformTarget = when {
HostManager.hostIsMac -> macosX64("platform")
HostManager.hostIsMingw -> mingwX64("platform")
HostManager.hostIsLinux -> linuxX64("platform")
else -> error("Unexpected host: ${HostManager.host}")
}
platformTarget.compilations["main"].cinterops.create("sampleInterop") {
header(file("src/nativeInterop/cinterop/sampleInterop.h"))
}
val platformTest by sourceSets.getting
val nativeTest = sourceSets.create("nativeTest")
platformTest.dependsOn(nativeTest)
tasks.create("listNativeTestDependencies") {
nativeTest as DefaultKotlinSourceSet
val nativeTestMetadataConfiguration = configurations[nativeTest.intransitiveMetadataConfigurationName]
dependsOn(nativeTestMetadataConfiguration)
doFirst {
nativeTestMetadataConfiguration.files.forEach { dependencyFile ->
logger.quiet("Dependency: ${dependencyFile.path}")
}
}
}
}
@@ -0,0 +1,6 @@
kotlin.code.style=official
kotlin.js.generate.executable.default=false
kotlin.mpp.enableGranularSourceSetsMetadata=true
kotlin.mpp.enableCInteropCommonization=true
kotlin.native.enableDependencyPropagation=false
kotlin.mpp.enableIntransitiveMetadataConfiguration=true
@@ -0,0 +1,10 @@
pluginManagement {
repositories {
mavenLocal()
gradlePluginPortal()
}
val kotlin_version: String by settings
plugins {
kotlin("multiplatform").version(kotlin_version)
}
}
@@ -0,0 +1,7 @@
@file:Suppress("unused")
import sampleInterop.sampleInterop
object NativeIntermediateTest {
fun x() = sampleInterop()
}
@@ -0,0 +1,7 @@
@file:Suppress("unused")
import sampleInterop.sampleInterop
object NativeMain {
fun x() = sampleInterop()
}