[Gradle] Update HierarchicalMppIT to reflect changes in stdlib

^KT-60901 Verification Pending
This commit is contained in:
Sebastian Sellmair
2023-08-09 14:35:53 +02:00
committed by Space Team
parent 00362390eb
commit ada446b68f
8 changed files with 49 additions and 41 deletions
@@ -280,10 +280,9 @@ open class HierarchicalMppIT : KGPBaseTest() {
"my-lib-bar-metadata-1.0-all.jar",
"third-party-lib-metadata-1.0.jar",
"kotlin-stdlib-${buildOptions.kotlinVersion}-all.jar",
"kotlin-test-js-${buildOptions.kotlinVersion}.jar",
"kotlin-dom-api-compat-${buildOptions.kotlinVersion}.klib"
),
transformedArtifacts()
).toSortedSet(),
transformedArtifacts().toSortedSet()
)
}
}
@@ -390,7 +389,7 @@ open class HierarchicalMppIT : KGPBaseTest() {
withGranularMetadata: Boolean,
gradleVersion: GradleVersion,
localRepoDir: Path,
beforePublishing: TestProject.() -> Unit = { }
beforePublishing: TestProject.() -> Unit = { },
): TestProject =
nativeProject(
projectName = projectName,
@@ -435,10 +434,15 @@ open class HierarchicalMppIT : KGPBaseTest() {
sourceSetModuleDependencies = mapOf(
"jvmAndJsMain" to setOf("com.example.thirdparty" to "third-party-lib"),
"linuxAndJsMain" to emptySet(),
"commonMain" to emptySet()
"commonMain" to setOf("org.jetbrains.kotlin" to "kotlin-stdlib")
)
)
assertEquals(
expectedProjectStructureMetadata.sourceSetModuleDependencies.toSortedMap(),
parsedProjectStructureMetadata.sourceSetModuleDependencies.toSortedMap()
)
assertEquals(expectedProjectStructureMetadata, parsedProjectStructureMetadata)
}
@@ -483,12 +487,20 @@ open class HierarchicalMppIT : KGPBaseTest() {
val expectedProjectStructureMetadata = expectedProjectStructureMetadata(
sourceSetModuleDependencies = mapOf(
"jvmAndJsMain" to setOf(),
"jvmAndJsMain" to emptySet(),
"linuxAndJsMain" to emptySet(),
"commonMain" to setOf("com.example.foo" to "my-lib-foo")
"commonMain" to setOf(
"org.jetbrains.kotlin" to "kotlin-stdlib",
"com.example.foo" to "my-lib-foo"
)
)
)
assertEquals(
expectedProjectStructureMetadata.sourceSetModuleDependencies.toSortedMap(),
parsedProjectStructureMetadata.sourceSetModuleDependencies.toSortedMap()
)
assertEquals(expectedProjectStructureMetadata, parsedProjectStructureMetadata)
}
@@ -597,7 +609,7 @@ open class HierarchicalMppIT : KGPBaseTest() {
private fun BuildResult.checkNamesOnCompileClasspath(
taskPath: String,
shouldInclude: Iterable<Pair<String, String>> = emptyList(),
shouldNotInclude: Iterable<Pair<String, String>> = emptyList()
shouldNotInclude: Iterable<Pair<String, String>> = emptyList(),
) {
val compilerArgsLine = output.lines().single { "$taskPath Kotlin compiler args:" in it }
val classpathItems = compilerArgsLine.substringAfter("-classpath").substringBefore(" -").split(File.pathSeparator)
@@ -634,7 +646,7 @@ open class HierarchicalMppIT : KGPBaseTest() {
// the projects used in these tests are similar and only the dependencies differ:
private fun expectedProjectStructureMetadata(
sourceSetModuleDependencies: Map<String, Set<Pair<String, String>>>
sourceSetModuleDependencies: Map<String, Set<Pair<String, String>>>,
): KotlinProjectStructureMetadata {
val jvmSourceSets = setOf("commonMain", "jvmAndJsMain")
@@ -878,7 +890,8 @@ open class HierarchicalMppIT : KGPBaseTest() {
gradleVersion = gradleVersion,
localRepoDir = tempDir
) {
buildGradleKts.appendText("""
buildGradleKts.appendText(
"""
testResolutionToSourcesVariant(
"common",
KotlinPlatformType.common,
@@ -900,7 +913,8 @@ open class HierarchicalMppIT : KGPBaseTest() {
KotlinPlatformType.native,
nativePlatform = "linux_x64"
)
""".trimIndent())
""".trimIndent()
)
val expectedReports = mapOf(
"common" to SourcesVariantResolutionReport(
@@ -909,18 +923,24 @@ open class HierarchicalMppIT : KGPBaseTest() {
),
"jvm" to SourcesVariantResolutionReport(
files = listOf("lib-jvm-1.0-sources.jar"),
dependencyToVariant = mapOf("test:lib:1.0" to "jvmSourcesElements-published",
"test:lib-jvm:1.0" to "jvmSourcesElements-published")
dependencyToVariant = mapOf(
"test:lib:1.0" to "jvmSourcesElements-published",
"test:lib-jvm:1.0" to "jvmSourcesElements-published"
)
),
"jvm2" to SourcesVariantResolutionReport(
files = listOf("lib-jvm2-1.0-sources.jar"),
dependencyToVariant = mapOf("test:lib:1.0" to "jvm2SourcesElements-published",
"test:lib-jvm2:1.0" to "jvm2SourcesElements-published")
dependencyToVariant = mapOf(
"test:lib:1.0" to "jvm2SourcesElements-published",
"test:lib-jvm2:1.0" to "jvm2SourcesElements-published"
)
),
"linuxX64" to SourcesVariantResolutionReport(
files = listOf("lib-linuxx64-1.0-sources.jar"),
dependencyToVariant = mapOf("test:lib:1.0" to "linuxX64SourcesElements-published",
"test:lib-linuxx64:1.0" to "linuxX64SourcesElements-published")
dependencyToVariant = mapOf(
"test:lib:1.0" to "linuxX64SourcesElements-published",
"test:lib-linuxx64:1.0" to "linuxX64SourcesElements-published"
)
),
)
@@ -1028,7 +1048,11 @@ open class HierarchicalMppIT : KGPBaseTest() {
fun testNativeLeafTestSourceSetsKt46417(gradleVersion: GradleVersion) {
with(project("kt-46417-ios-test-source-sets", gradleVersion = gradleVersion)) {
testDependencyTransformations("p2") { reports ->
val report = reports.singleOrNull { it.sourceSetName == "iosArm64Test" && it.scope == "implementation" }
val report = reports.singleOrNull {
it.sourceSetName == "iosArm64Test" &&
it.scope == "implementation" &&
it.groupAndModule.endsWith(":p1")
}
assertNotNull(report, "No single report for 'iosArm64' and implementation scope")
assertEquals(setOf("commonMain", "iosMain"), report.allVisibleSourceSets)
assertTrue(report.groupAndModule.endsWith(":p1"))
@@ -1217,7 +1241,7 @@ open class HierarchicalMppIT : KGPBaseTest() {
private fun TestProject.testDependencyTransformations(
subproject: String? = null,
check: BuildResult.(reports: Iterable<DependencyTransformationReport>) -> Unit
check: BuildResult.(reports: Iterable<DependencyTransformationReport>) -> Unit,
) {
val buildGradleKts = (subproject?.let { subProject(subproject).buildGradleKts } ?: buildGradleKts).toFile()
assert(buildGradleKts.exists()) { "Kotlin scripts are not found." }
@@ -1277,7 +1301,7 @@ open class HierarchicalMppIT : KGPBaseTest() {
val groupAndModule: String,
val allVisibleSourceSets: Set<String>,
val newVisibleSourceSets: Set<String>, // those which the dependsOn parents don't see
val useFiles: List<File>
val useFiles: List<File>,
) {
val isExcluded: Boolean get() = allVisibleSourceSets.isEmpty()
@@ -1304,7 +1328,7 @@ open class HierarchicalMppIT : KGPBaseTest() {
private data class SourcesVariantResolutionReport(
val files: List<String>,
val dependencyToVariant: Map<String, String>
val dependencyToVariant: Map<String, String>,
) {
companion object {
fun parse(output: String, targetNames: Iterable<String>): Map<String, SourcesVariantResolutionReport> {
@@ -1319,7 +1343,7 @@ open class HierarchicalMppIT : KGPBaseTest() {
private fun List<String>.betweenMarkers(
start: String,
end: String
end: String,
): List<String> {
val startPos = indexOf(start)
val endPos = indexOf(end)
@@ -20,7 +20,6 @@ kotlin {
val commonMain by getting {
dependencies {
api(project(":my-lib-bar"))
implementation(kotlin("stdlib-common"))
}
}
@@ -21,7 +21,6 @@ kotlin {
val commonMain by getting {
dependencies {
api(project(":my-lib-foo"))
implementation(kotlin("stdlib-common"))
}
}
@@ -19,11 +19,7 @@ kotlin {
linuxX64()
sourceSets {
val commonMain by getting {
dependencies {
implementation(kotlin("stdlib-common"))
}
}
val commonMain by getting
val commonTest by getting {
dependencies {
@@ -16,11 +16,7 @@ kotlin {
js()
sourceSets {
val commonMain by getting {
dependencies {
implementation(kotlin("stdlib-common"))
}
}
val commonMain by getting
val commonTest by getting {
dependencies {
implementation(kotlin("test-common"))
@@ -21,7 +21,6 @@ kotlin {
val commonMain by getting {
dependencies {
api("com.example.bar:my-lib-bar:1.0")
implementation(kotlin("stdlib-common"))
}
}
@@ -22,7 +22,6 @@ kotlin {
val commonMain by getting {
dependencies {
api("com.example.foo:my-lib-foo:1.0")
implementation(kotlin("stdlib-common"))
}
}
@@ -20,11 +20,7 @@ kotlin {
linuxX64()
sourceSets {
val commonMain by getting {
dependencies {
implementation(kotlin("stdlib-common"))
}
}
val commonMain by getting
val commonTest by getting {
dependencies {