[Gradle] Implement KotlinMultiplatformSourceSetConventionsTest
^KT-58676 Verification Pending
This commit is contained in:
committed by
Space Team
parent
c31c5ea0be
commit
8d6c4019c5
+1
-3
@@ -59,9 +59,7 @@ interface KotlinMultiplatformSourceSetConventions {
|
|||||||
|
|
||||||
fun NamedDomainObjectProvider<KotlinSourceSet>.dependencies(
|
fun NamedDomainObjectProvider<KotlinSourceSet>.dependencies(
|
||||||
handler: KotlinDependencyHandler.() -> Unit,
|
handler: KotlinDependencyHandler.() -> Unit,
|
||||||
) = configure { sourceSet ->
|
) = get().dependencies(handler)
|
||||||
sourceSet.dependencies(handler)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun NamedDomainObjectProvider<KotlinSourceSet>.languageSettings(
|
fun NamedDomainObjectProvider<KotlinSourceSet>.languageSettings(
|
||||||
configure: LanguageSettingsBuilder.() -> Unit,
|
configure: LanguageSettingsBuilder.() -> Unit,
|
||||||
|
|||||||
+95
@@ -0,0 +1,95 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2023 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
@file:Suppress("FunctionName")
|
||||||
|
|
||||||
|
package org.jetbrains.kotlin.gradle.unitTests
|
||||||
|
|
||||||
|
import org.gradle.kotlin.dsl.provideDelegate
|
||||||
|
import org.jetbrains.kotlin.gradle.dsl.multiplatformExtension
|
||||||
|
import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet
|
||||||
|
import org.jetbrains.kotlin.gradle.plugin.configurationResult
|
||||||
|
import org.jetbrains.kotlin.gradle.plugin.sources.internal
|
||||||
|
import org.jetbrains.kotlin.gradle.util.assertContainsDependencies
|
||||||
|
import org.jetbrains.kotlin.gradle.util.buildProjectWithMPP
|
||||||
|
import org.jetbrains.kotlin.gradle.util.runLifecycleAwareTest
|
||||||
|
import org.jetbrains.kotlin.tooling.core.extrasReadWriteProperty
|
||||||
|
import java.util.concurrent.atomic.AtomicBoolean
|
||||||
|
import kotlin.test.Test
|
||||||
|
import kotlin.test.assertEquals
|
||||||
|
import kotlin.test.assertFalse
|
||||||
|
|
||||||
|
class KotlinMultiplatformSourceSetConventionsTest {
|
||||||
|
private var KotlinSourceSet.testMarker by extrasReadWriteProperty<String>("testMarker")
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `test - invoke`() = buildProjectWithMPP().runLifecycleAwareTest {
|
||||||
|
|
||||||
|
val mainConfigurationCalled = AtomicBoolean(false)
|
||||||
|
val testConfigurationCalled = AtomicBoolean(false)
|
||||||
|
|
||||||
|
multiplatformExtension.apply {
|
||||||
|
jvm()
|
||||||
|
|
||||||
|
sourceSets.jvmMain {
|
||||||
|
testMarker = "jvmMain"
|
||||||
|
assertFalse(mainConfigurationCalled.getAndSet(true))
|
||||||
|
}
|
||||||
|
|
||||||
|
sourceSets.jvmTest {
|
||||||
|
testMarker = "jvmTest"
|
||||||
|
assertFalse(testConfigurationCalled.getAndSet(true))
|
||||||
|
}
|
||||||
|
|
||||||
|
configurationResult.await()
|
||||||
|
assertEquals("jvmMain", sourceSets.jvmMain.get().testMarker)
|
||||||
|
assertEquals("jvmTest", sourceSets.jvmTest.get().testMarker)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `test - languageSettings`() = buildProjectWithMPP().runLifecycleAwareTest {
|
||||||
|
multiplatformExtension.apply {
|
||||||
|
jvm()
|
||||||
|
|
||||||
|
sourceSets.jvmMain.languageSettings {
|
||||||
|
this.optIn("jvmMain.optIn")
|
||||||
|
}
|
||||||
|
|
||||||
|
sourceSets.jvmTest.languageSettings {
|
||||||
|
this.optIn("jvmTest.optIn")
|
||||||
|
}
|
||||||
|
|
||||||
|
assertEquals(setOf("jvmMain.optIn"), sourceSets.jvmMain.get().languageSettings.optInAnnotationsInUse)
|
||||||
|
assertEquals(setOf("jvmTest.optIn"), sourceSets.jvmTest.get().languageSettings.optInAnnotationsInUse)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `test - dependencies`() = buildProjectWithMPP().runLifecycleAwareTest {
|
||||||
|
multiplatformExtension.apply {
|
||||||
|
jvm()
|
||||||
|
|
||||||
|
sourceSets.jvmMain.dependencies {
|
||||||
|
implementation("my:jvmMain:library")
|
||||||
|
}
|
||||||
|
|
||||||
|
sourceSets.jvmTest.dependencies {
|
||||||
|
implementation("my:jvmTest:library")
|
||||||
|
}
|
||||||
|
|
||||||
|
assertContainsDependencies(
|
||||||
|
sourceSets.jvmMain.get().implementationConfigurationName,
|
||||||
|
"my:jvmMain:library"
|
||||||
|
)
|
||||||
|
|
||||||
|
assertContainsDependencies(
|
||||||
|
sourceSets.jvmTest.get().implementationConfigurationName,
|
||||||
|
"my:jvmTest:library"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user