[Gradle] KT-56712: Add assertions for ide dependencies
^KT-56712 Verification Pending
This commit is contained in:
committed by
Space Team
parent
b83a490034
commit
1cce57b50b
+21
-1
@@ -318,7 +318,7 @@ class MppCompositeBuildIT : KGPBaseTest() {
|
||||
}
|
||||
|
||||
@GradleAndroidTest
|
||||
fun `test - sample6-KT-56712-umbrella-composite - compileCommonMainKotlinMetadata`(
|
||||
fun `test - sample6-KT-56712-umbrella-composite`(
|
||||
gradleVersion: GradleVersion, agpVersion: String, jdkVersion: JdkVersions.ProvidedJdk,
|
||||
) {
|
||||
val producer = project("mpp-composite-build/sample6-KT-56712-umbrella-composite/producer", gradleVersion)
|
||||
@@ -340,6 +340,26 @@ class MppCompositeBuildIT : KGPBaseTest() {
|
||||
build(":consumerB:compileCommonMainKotlinMetadata") {
|
||||
assertTasksExecuted(":consumerB:compileCommonMainKotlinMetadata")
|
||||
}
|
||||
|
||||
build(":consumerA:resolveIdeDependencies") {
|
||||
consumerA.readIdeDependencies()["commonMain"].assertMatches(
|
||||
regularSourceDependency("producer::/commonMain"),
|
||||
kotlinStdlibDependencies
|
||||
)
|
||||
}
|
||||
|
||||
build(":consumerB:resolveIdeDependencies") {
|
||||
consumerB.readIdeDependencies()["commonMain"].assertMatches(
|
||||
regularSourceDependency("producer::/commonMain"),
|
||||
kotlinStdlibDependencies
|
||||
)
|
||||
}
|
||||
|
||||
build(":producer:resolveIdeDependencies") {
|
||||
producer.readIdeDependencies()["commonMain"].assertMatches(
|
||||
kotlinStdlibDependencies
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+17
-12
@@ -24,22 +24,27 @@ internal fun TestProject.resolveIdeDependencies(
|
||||
assertions: BuildResult.(dependencies: IdeaKotlinDependenciesContainer) -> Unit
|
||||
) {
|
||||
build("${subproject.orEmpty()}:resolveIdeDependencies") {
|
||||
val subprojectPathPrefix = subproject?.removePrefix(":")?.takeIf { it.isNotEmpty() }?.replace(":", "/")?.plus("/") ?: ""
|
||||
val output = projectPath.resolve("${subprojectPathPrefix}build/ide/dependencies/proto").toFile()
|
||||
if (!output.isDirectory) fail("Missing output directory: $output")
|
||||
assertions(readIdeDependencies(subproject))
|
||||
}
|
||||
}
|
||||
|
||||
val dependenciesBySourceSetName = output.listFiles().orEmpty().associate { sourceSetDirectory ->
|
||||
if (!sourceSetDirectory.isDirectory) fail("Expected $sourceSetDirectory to be directory")
|
||||
val serializedDependencyFiles = sourceSetDirectory.listFiles().orEmpty()
|
||||
val deserializedDependencies = serializedDependencyFiles.map { dependencyFile ->
|
||||
deserializeIdeaKotlinDependencyOrFail(dependencyFile)
|
||||
}
|
||||
internal fun TestProject.readIdeDependencies(subproject: String? = null): IdeaKotlinDependenciesContainer {
|
||||
val subprojectPathPrefix = subproject?.removePrefix(":")?.takeIf { it.isNotEmpty() }?.replace(":", "/")?.plus("/") ?: ""
|
||||
val output = projectPath.resolve("${subprojectPathPrefix}build/ide/dependencies/proto").toFile()
|
||||
if (!output.isDirectory) fail("Missing output directory: $output")
|
||||
|
||||
sourceSetDirectory.name to deserializedDependencies.toSet()
|
||||
val dependenciesBySourceSetName = output.listFiles().orEmpty().associate { sourceSetDirectory ->
|
||||
if (!sourceSetDirectory.isDirectory) fail("Expected $sourceSetDirectory to be directory")
|
||||
val serializedDependencyFiles = sourceSetDirectory.listFiles().orEmpty()
|
||||
val deserializedDependencies = serializedDependencyFiles.map { dependencyFile ->
|
||||
deserializeIdeaKotlinDependencyOrFail(dependencyFile)
|
||||
}
|
||||
|
||||
assertions(IdeaKotlinDependenciesContainer(dependenciesBySourceSetName))
|
||||
sourceSetDirectory.name to deserializedDependencies.toSet()
|
||||
}
|
||||
|
||||
|
||||
return IdeaKotlinDependenciesContainer(dependenciesBySourceSetName)
|
||||
}
|
||||
|
||||
private fun deserializeIdeaKotlinDependencyOrFail(file: File): IdeaKotlinDependency {
|
||||
@@ -57,7 +62,7 @@ private object GradleIntegrationTestIdeaKotlinSerializationContext : IdeaKotlinS
|
||||
}
|
||||
}
|
||||
|
||||
class IdeaKotlinDependenciesContainer(
|
||||
class IdeaKotlinDependenciesContainer(
|
||||
private val dependencies: Map<String, Set<IdeaKotlinDependency>>
|
||||
) {
|
||||
operator fun get(sourceSetName: String) = dependencies[sourceSetName]
|
||||
|
||||
Reference in New Issue
Block a user