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