[Gradle] CommonizerIT: Parameterize test on commonizeMultipleCInteropsWithTests
Testing the project w/ and w/o the commonon mistake of declaring dependsOn edges from test to main source sets ^KT-47775 ^KT-47053
This commit is contained in:
committed by
Space
parent
db10732d6c
commit
153df1dd1a
+32
-8
@@ -354,15 +354,32 @@ class CommonizerIT : BaseGradleIT() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `test multiple cinterops with test source sets and compilations - test source sets depending on main`() {
|
||||||
|
`test multiple cinterops with test source sets and compilations`(true)
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `test multiple cinterops with test source sets and compilations`() {
|
fun `test multiple cinterops with test source sets and compilations`() {
|
||||||
|
`test multiple cinterops with test source sets and compilations`(false)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun `test multiple cinterops with test source sets and compilations`(testSourceSetsDependingOnMain: Boolean) {
|
||||||
with(Project("commonizeMultipleCInteropsWithTests", minLogLevel = INFO)) {
|
with(Project("commonizeMultipleCInteropsWithTests", minLogLevel = INFO)) {
|
||||||
|
|
||||||
val isUnix = HostManager.hostIsMac || HostManager.hostIsLinux
|
val isUnix = HostManager.hostIsMac || HostManager.hostIsLinux
|
||||||
val isMac = HostManager.hostIsMac
|
val isMac = HostManager.hostIsMac
|
||||||
val isWindows = HostManager.hostIsMingw
|
val isWindows = HostManager.hostIsMingw
|
||||||
|
|
||||||
reportSourceSetCommonizerDependencies(this) {
|
val testSourceSetsDependingOnMainParameter = "-PtestSourceSetsDependingOnMain=$testSourceSetsDependingOnMain"
|
||||||
|
|
||||||
|
fun CompiledProject.assertTestSourceSetsDependingOnMainParameter() {
|
||||||
|
val message = "testSourceSetsDependingOnMain is set"
|
||||||
|
if (testSourceSetsDependingOnMain) assertContains(message) else assertNotContains(message)
|
||||||
|
}
|
||||||
|
|
||||||
|
reportSourceSetCommonizerDependencies(this, testSourceSetsDependingOnMainParameter) {
|
||||||
|
it.assertTestSourceSetsDependingOnMainParameter()
|
||||||
getCommonizerDependencies("nativeMain").onlyCInterops().apply {
|
getCommonizerDependencies("nativeMain").onlyCInterops().apply {
|
||||||
assertDependencyFilesMatches(".*nativeHelper", ".*unixHelper".takeIf { isUnix })
|
assertDependencyFilesMatches(".*nativeHelper", ".*unixHelper".takeIf { isUnix })
|
||||||
assertTargetOnAllDependencies(
|
assertTargetOnAllDependencies(
|
||||||
@@ -453,38 +470,45 @@ class CommonizerIT : BaseGradleIT() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
build(":assemble") {
|
build(":assemble", testSourceSetsDependingOnMainParameter) {
|
||||||
|
assertTestSourceSetsDependingOnMainParameter()
|
||||||
assertSuccessful()
|
assertSuccessful()
|
||||||
assertTasksUpToDate(":commonizeNativeDistribution")
|
assertTasksUpToDate(":commonizeNativeDistribution")
|
||||||
assertTasksUpToDate(":commonizeCInterop")
|
assertTasksUpToDate(":commonizeCInterop")
|
||||||
}
|
}
|
||||||
|
|
||||||
build(":compileNativeMainKotlinMetadata") {
|
build(":compileNativeMainKotlinMetadata", testSourceSetsDependingOnMainParameter) {
|
||||||
|
assertTestSourceSetsDependingOnMainParameter()
|
||||||
assertSuccessful()
|
assertSuccessful()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isUnix) {
|
if (isUnix) {
|
||||||
build(":compileUnixMainKotlinMetadata") {
|
build(":compileUnixMainKotlinMetadata", testSourceSetsDependingOnMainParameter) {
|
||||||
|
assertTestSourceSetsDependingOnMainParameter()
|
||||||
assertSuccessful()
|
assertSuccessful()
|
||||||
}
|
}
|
||||||
|
|
||||||
build(":compileLinuxMainKotlinMetadata") {
|
build(":compileLinuxMainKotlinMetadata", testSourceSetsDependingOnMainParameter) {
|
||||||
|
assertTestSourceSetsDependingOnMainParameter()
|
||||||
assertSuccessful()
|
assertSuccessful()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isMac) {
|
if (isMac) {
|
||||||
build(":compileAppleMainKotlinMetadata") {
|
build(":compileAppleMainKotlinMetadata", testSourceSetsDependingOnMainParameter) {
|
||||||
|
assertTestSourceSetsDependingOnMainParameter()
|
||||||
assertSuccessful()
|
assertSuccessful()
|
||||||
}
|
}
|
||||||
|
|
||||||
build(":compileIosMainKotlinMetadata") {
|
build(":compileIosMainKotlinMetadata", testSourceSetsDependingOnMainParameter) {
|
||||||
|
assertTestSourceSetsDependingOnMainParameter()
|
||||||
assertSuccessful()
|
assertSuccessful()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isWindows) {
|
if (isWindows) {
|
||||||
build(":compileWindowsMainKotlinMetadata") {
|
build(":compileWindowsMainKotlinMetadata", testSourceSetsDependingOnMainParameter) {
|
||||||
|
assertTestSourceSetsDependingOnMainParameter()
|
||||||
assertSuccessful()
|
assertSuccessful()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-4
@@ -12,6 +12,7 @@ import org.jetbrains.kotlin.commonizer.SharedCommonizerTarget
|
|||||||
import org.jetbrains.kotlin.commonizer.parseCommonizerTargetOrNull
|
import org.jetbrains.kotlin.commonizer.parseCommonizerTargetOrNull
|
||||||
import org.jetbrains.kotlin.commonizer.util.transitiveClosure
|
import org.jetbrains.kotlin.commonizer.util.transitiveClosure
|
||||||
import org.jetbrains.kotlin.gradle.BaseGradleIT
|
import org.jetbrains.kotlin.gradle.BaseGradleIT
|
||||||
|
import org.jetbrains.kotlin.gradle.BaseGradleIT.CompiledProject
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import javax.annotation.RegEx
|
import javax.annotation.RegEx
|
||||||
import kotlin.test.fail
|
import kotlin.test.fail
|
||||||
@@ -88,7 +89,8 @@ fun interface WithSourceSetCommonizerDependencies {
|
|||||||
|
|
||||||
fun BaseGradleIT.reportSourceSetCommonizerDependencies(
|
fun BaseGradleIT.reportSourceSetCommonizerDependencies(
|
||||||
project: BaseGradleIT.Project,
|
project: BaseGradleIT.Project,
|
||||||
test: WithSourceSetCommonizerDependencies.() -> Unit
|
vararg additionalBuildParameters: String,
|
||||||
|
test: WithSourceSetCommonizerDependencies.(compiledProject: CompiledProject) -> Unit
|
||||||
) = with(project) {
|
) = with(project) {
|
||||||
|
|
||||||
if (!projectDir.exists()) {
|
if (!projectDir.exists()) {
|
||||||
@@ -102,8 +104,7 @@ fun BaseGradleIT.reportSourceSetCommonizerDependencies(
|
|||||||
}
|
}
|
||||||
|
|
||||||
build(
|
build(
|
||||||
":reportCommonizerSourceSetDependencies",
|
*(listOf(":reportCommonizerSourceSetDependencies") + additionalBuildParameters).toTypedArray(),
|
||||||
options = defaultBuildOptions().copy(forceOutputToStdout = true)
|
|
||||||
) {
|
) {
|
||||||
assertSuccessful()
|
assertSuccessful()
|
||||||
|
|
||||||
@@ -126,7 +127,7 @@ fun BaseGradleIT.reportSourceSetCommonizerDependencies(
|
|||||||
SourceSetCommonizerDependencies(sourceSetName, dependencies.toSet())
|
SourceSetCommonizerDependencies(sourceSetName, dependencies.toSet())
|
||||||
}
|
}
|
||||||
|
|
||||||
withSourceSetCommonizerDependencies.test()
|
withSourceSetCommonizerDependencies.test(this)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
-2
@@ -14,8 +14,6 @@ import org.jetbrains.kotlin.gradle.plugin.sources.DefaultKotlinSourceSet
|
|||||||
import org.jetbrains.kotlin.gradle.utils.filesProvider
|
import org.jetbrains.kotlin.gradle.utils.filesProvider
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
// TODO NOW: Integration tests!
|
|
||||||
|
|
||||||
internal fun Project.setupCInteropCommonizerDependencies() {
|
internal fun Project.setupCInteropCommonizerDependencies() {
|
||||||
val kotlin = this.multiplatformExtensionOrNull ?: return
|
val kotlin = this.multiplatformExtensionOrNull ?: return
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user