Change Gradle test expectations after KT-61969

This commit is contained in:
Ilya Gorbunov
2023-11-18 22:10:25 +01:00
committed by Space Team
parent 653fc03cbc
commit b0bee09948
3 changed files with 25 additions and 19 deletions
@@ -283,7 +283,9 @@ open class HierarchicalMppIT : KGPBaseTest() {
"kotlin-stdlib-${buildOptions.kotlinVersion}-all.jar", "kotlin-stdlib-${buildOptions.kotlinVersion}-all.jar",
"kotlin-dom-api-compat-${buildOptions.kotlinVersion}.klib", "kotlin-dom-api-compat-${buildOptions.kotlinVersion}.klib",
"kotlin-stdlib-js-${buildOptions.kotlinVersion}.klib", "kotlin-stdlib-js-${buildOptions.kotlinVersion}.klib",
"kotlin-test-${buildOptions.kotlinVersion}-all.jar",
"kotlin-test-js-${buildOptions.kotlinVersion}.klib", "kotlin-test-js-${buildOptions.kotlinVersion}.klib",
"kotlin-test-junit-${buildOptions.kotlinVersion}.jar",
).toSortedSet(), ).toSortedSet(),
transformedArtifacts().toSortedSet() transformedArtifacts().toSortedSet()
) )
@@ -720,7 +722,7 @@ open class HierarchicalMppIT : KGPBaseTest() {
publishThirdPartyLib(withGranularMetadata = true, gradleVersion = gradleVersion, localRepoDir = tempDir) publishThirdPartyLib(withGranularMetadata = true, gradleVersion = gradleVersion, localRepoDir = tempDir)
subProject("my-lib-foo").buildGradleKts subProject("my-lib-foo").buildGradleKts
.appendText("\ndependencies { \"jvmAndJsMainCompileOnly\"(kotlin(\"test-annotations-common\")) }") .appendText("\ndependencies { \"jvmAndJsMainCompileOnly\"(kotlin(\"test\")) }")
projectPath.resolve("my-lib-foo/src/jvmAndJsMain/kotlin/UseCompileOnlyDependency.kt").writeText( projectPath.resolve("my-lib-foo/src/jvmAndJsMain/kotlin/UseCompileOnlyDependency.kt").writeText(
""" """
import kotlin.test.Test import kotlin.test.Test
@@ -20,8 +20,7 @@ import kotlin.io.path.createDirectories
import kotlin.io.path.writeText import kotlin.io.path.writeText
import kotlin.streams.asStream import kotlin.streams.asStream
import kotlin.streams.toList import kotlin.streams.toList
import kotlin.test.assertFalse import kotlin.test.fail
import kotlin.test.assertTrue
@DisplayName("Kotlin default dependencies") @DisplayName("Kotlin default dependencies")
class KotlinSpecificDependenciesIT : KGPBaseTest() { class KotlinSpecificDependenciesIT : KGPBaseTest() {
@@ -422,7 +421,7 @@ class KotlinSpecificDependenciesIT : KGPBaseTest() {
project("simpleProject", gradleVersion) { project("simpleProject", gradleVersion) {
assertKotlinTestDependency( assertKotlinTestDependency(
listOf("testImplementation"), listOf("testImplementation"),
mapOf("compileTestKotlin" to listOf("kotlin-test-testng")) mapOf("compileTestKotlin" to listOf("kotlin-test-${defaultBuildOptions.kotlinVersion}.jar", "kotlin-test-testng"))
) )
} }
} }
@@ -451,18 +450,18 @@ class KotlinSpecificDependenciesIT : KGPBaseTest() {
assertKotlinTestDependency( assertKotlinTestDependency(
listOf("commonTestImplementation"), listOf("commonTestImplementation"),
mapOf( mapOf(
"compileTestKotlinJvm" to listOf("kotlin-test-junit"), "compileTestKotlinJvm" to listOf("kotlin-test-${defaultBuildOptions.kotlinVersion}.jar", "kotlin-test-junit"),
"compileTestKotlinJs" to listOf("kotlin-test-js") "compileTestKotlinJs" to listOf("kotlin-test-js")
), ),
mapOf( mapOf(
"commonTestImplementationDependenciesMetadata" to listOf("kotlin-test-common", "kotlin-test-annotations-common"), "commonTestImplementationDependenciesMetadata" to listOf("kotlin-test-${defaultBuildOptions.kotlinVersion}-all"),
/* /*
implementation, api and compileOnly scoped metadata configurations are deprecated and report the same dependencies. implementation, api and compileOnly scoped metadata configurations are deprecated and report the same dependencies.
The IDE does not rely on which exact configuration returned the dependencies. The IDE does not rely on which exact configuration returned the dependencies.
*/ */
"commonTestApiDependenciesMetadata" to listOf("kotlin-test-common", "kotlin-test-annotations-common"), "commonTestApiDependenciesMetadata" to listOf("kotlin-test-${defaultBuildOptions.kotlinVersion}-all"),
"commonTestCompileOnlyDependenciesMetadata" to listOf("kotlin-test-common", "kotlin-test-annotations-common"), "commonTestCompileOnlyDependenciesMetadata" to listOf("kotlin-test-${defaultBuildOptions.kotlinVersion}-all"),
), ),
isBuildGradleKts = true isBuildGradleKts = true
) )
@@ -477,14 +476,14 @@ class KotlinSpecificDependenciesIT : KGPBaseTest() {
assertKotlinTestDependency( assertKotlinTestDependency(
listOf("jvmAndJsTestApi", "jvmAndJsTestCompileOnly"), // add to the intermediate source set, and to two scopes listOf("jvmAndJsTestApi", "jvmAndJsTestCompileOnly"), // add to the intermediate source set, and to two scopes
mapOf( mapOf(
"compileTestKotlinJvm" to listOf("kotlin-test-junit"), "compileTestKotlinJvm" to listOf("kotlin-test-${defaultBuildOptions.kotlinVersion}.jar", "kotlin-test-junit"),
"compileTestKotlinJs" to listOf("kotlin-test-js") "compileTestKotlinJs" to listOf("kotlin-test-js")
), ),
mapOf( mapOf(
"commonTestApiDependenciesMetadata" to listOf("!kotlin-test-common"), "commonTestApiDependenciesMetadata" to listOf("!kotlin-test-${defaultBuildOptions.kotlinVersion}-all"),
"commonTestCompileOnlyDependenciesMetadata" to listOf("!kotlin-test-common"), "commonTestCompileOnlyDependenciesMetadata" to listOf("!kotlin-test-${defaultBuildOptions.kotlinVersion}-all"),
"jvmAndJsTestApiDependenciesMetadata" to listOf("kotlin-test-common"), "jvmAndJsTestApiDependenciesMetadata" to listOf("kotlin-test-${defaultBuildOptions.kotlinVersion}-all"),
"jvmAndJsTestCompileOnlyDependenciesMetadata" to listOf("kotlin-test-common"), "jvmAndJsTestCompileOnlyDependenciesMetadata" to listOf("kotlin-test-${defaultBuildOptions.kotlinVersion}-all"),
), ),
isBuildGradleKts = true isBuildGradleKts = true
) )
@@ -499,10 +498,10 @@ class KotlinSpecificDependenciesIT : KGPBaseTest() {
assertKotlinTestDependency( assertKotlinTestDependency(
listOf("commonTestImplementation"), listOf("commonTestImplementation"),
mapOf( mapOf(
"compileTestKotlinJvm" to listOf("kotlin-test-junit"), "compileTestKotlinJvm" to listOf("kotlin-test-${defaultBuildOptions.kotlinVersion}.jar", "kotlin-test-junit"),
), ),
mapOf( mapOf(
"commonTestImplementationDependenciesMetadata" to listOf("kotlin-test-common", "kotlin-test-annotations-common") "commonTestImplementationDependenciesMetadata" to listOf("kotlin-test-${defaultBuildOptions.kotlinVersion}-all")
), ),
isBuildGradleKts = true isBuildGradleKts = true
) )
@@ -759,10 +758,14 @@ class KotlinSpecificDependenciesIT : KGPBaseTest() {
val itemsLine = output.lines().single { "###$printingTaskName" in it }.substringAfter(printingTaskName) val itemsLine = output.lines().single { "###$printingTaskName" in it }.substringAfter(printingTaskName)
val items = itemsLine.removeSurrounding("[", "]").split(", ").toSet() val items = itemsLine.removeSurrounding("[", "]").split(", ").toSet()
checkAnyItemsContains.forEach { pattern -> checkAnyItemsContains.forEach { pattern ->
assertTrue("Dependencies($dependencyOwner) does not contain $pattern") { items.any { pattern in it } } if (!items.any { pattern in it }) {
fail("Dependencies($dependencyOwner) does not contain $pattern\nDependencies:\n${items.joinToString("\n")}")
}
} }
checkNoItemContains.forEach { pattern -> checkNoItemContains.forEach { pattern ->
assertFalse("Dependencies($dependencyOwner) unexpectedly contains $pattern") { items.any { pattern in it } } if (items.any { pattern in it }) {
fail("Dependencies($dependencyOwner) unexpectedly contains $pattern\nDependencies:\n${items.joinToString("\n")}")
}
} }
} }
} }
@@ -24,6 +24,7 @@ class IdeOriginalMetadataDependencyResolverTest {
@Test @Test
fun `test kotlin-test-common`() { fun `test kotlin-test-common`() {
val lastLegacyMetadataKotlinTestVersion = "1.9.20"
val project = buildProject { val project = buildProject {
enableDependencyVerification(false) enableDependencyVerification(false)
enableDefaultStdlibDependency(false) enableDefaultStdlibDependency(false)
@@ -39,13 +40,13 @@ class IdeOriginalMetadataDependencyResolverTest {
kotlin.linuxArm64() kotlin.linuxArm64()
kotlin.sourceSets.commonTest.dependencies { kotlin.sourceSets.commonTest.dependencies {
implementation("org.jetbrains.kotlin:kotlin-test-common:${kotlin.coreLibrariesVersion}") implementation("org.jetbrains.kotlin:kotlin-test-common:$lastLegacyMetadataKotlinTestVersion")
} }
project.evaluate() project.evaluate()
IdeOriginalMetadataDependencyResolver.resolve(kotlin.sourceSets.commonTest.get()).assertMatches( IdeOriginalMetadataDependencyResolver.resolve(kotlin.sourceSets.commonTest.get()).assertMatches(
binaryCoordinates("org.jetbrains.kotlin:kotlin-test-common:${kotlin.coreLibrariesVersion}") binaryCoordinates("org.jetbrains.kotlin:kotlin-test-common:$lastLegacyMetadataKotlinTestVersion")
) )
} }