[mpp, tests] Assert that all dependencies are resolved, fix misconfigurations
- Assert that all dependencies are resolved. Gradle won't fail the build by default, which might lead to test running in a weird misconfigured state and producing unreliable results (can be green even though there are bugs) - Fix several typos and misconfigurations that were revealed after adding assertion described above
This commit is contained in:
committed by
Space Team
parent
1832a6d936
commit
14b340c61e
+7
-12
@@ -62,33 +62,28 @@ class PreHmppDependenciesDeprecationIT : KGPBaseTest() {
|
|||||||
|
|
||||||
@GradleTest
|
@GradleTest
|
||||||
fun testNoWarningsOnProjectDependencies(gradleVersion: GradleVersion) {
|
fun testNoWarningsOnProjectDependencies(gradleVersion: GradleVersion) {
|
||||||
checkDiagnostics(gradleVersion, "noWarningsOnProjectDependencies", taskToCall = ":consumer:dependencies")
|
checkDiagnostics(gradleVersion, "noWarningsOnProjectDependencies", projectPathToCheck = ":consumer")
|
||||||
}
|
}
|
||||||
|
|
||||||
@GradleTest
|
@GradleTest
|
||||||
fun testNoWarningsInPlatformSpecificSourceSets(gradleVersion: GradleVersion) {
|
fun testNoWarningsInPlatformSpecificSourceSets(gradleVersion: GradleVersion, @TempDir tempDir: Path) {
|
||||||
checkDiagnostics(gradleVersion, "noWarningsInPlatformSpecificSourceSets")
|
|
||||||
}
|
|
||||||
|
|
||||||
@GradleTest
|
|
||||||
fun testNoWarningsInPreHmppProjects(gradleVersion: GradleVersion, @TempDir tempDir: Path) {
|
|
||||||
publishLibrary("preHmppLibrary", gradleVersion, tempDir)
|
publishLibrary("preHmppLibrary", gradleVersion, tempDir)
|
||||||
checkDiagnostics(gradleVersion, "simpleReport", tempDir) {
|
checkDiagnostics(gradleVersion, "noWarningsInPlatformSpecificSourceSets", tempDir)
|
||||||
gradleProperties.writeText("kotlin.internal.mpp.hierarchicalStructureByDefault=false")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun checkDiagnostics(
|
private fun checkDiagnostics(
|
||||||
gradleVersion: GradleVersion,
|
gradleVersion: GradleVersion,
|
||||||
projectName: String,
|
projectName: String,
|
||||||
tempDir: Path? = null,
|
tempDir: Path? = null,
|
||||||
taskToCall: String = "dependencies",
|
projectPathToCheck: String = "", // empty means rootProject
|
||||||
expectReportForDependency: String? = null,
|
expectReportForDependency: String? = null,
|
||||||
preBuildAction: TestProject.() -> Unit = {}
|
preBuildAction: TestProject.() -> Unit = {}
|
||||||
) {
|
) {
|
||||||
project("preHmppDependenciesDeprecation/$projectName", gradleVersion, localRepoDir = tempDir?.resolve("repo")) {
|
project("preHmppDependenciesDeprecation/$projectName", gradleVersion, localRepoDir = tempDir?.resolve("repo")) {
|
||||||
preBuildAction()
|
preBuildAction()
|
||||||
build(taskToCall) {
|
build("$projectPathToCheck:dependencies") {
|
||||||
|
// all dependencies should be resolved, Gradle won't fail the 'dependencies' task on its own
|
||||||
|
assertOutputDoesNotContain("FAILED")
|
||||||
if (expectReportForDependency != null) {
|
if (expectReportForDependency != null) {
|
||||||
output.assertHasDiagnostic(
|
output.assertHasDiagnostic(
|
||||||
KotlinToolingDiagnostics.PreHmppDependenciesUsedInBuild
|
KotlinToolingDiagnostics.PreHmppDependenciesUsedInBuild
|
||||||
|
|||||||
+4
-8
@@ -1,17 +1,13 @@
|
|||||||
plugins {
|
plugins {
|
||||||
kotlin("multiplatform")
|
kotlin("multiplatform")
|
||||||
id("maven-publish")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
publishing {
|
repositories {
|
||||||
repositories {
|
mavenCentral()
|
||||||
maven("<localRepo>")
|
mavenLocal()
|
||||||
}
|
maven("<localRepo>")
|
||||||
}
|
}
|
||||||
|
|
||||||
group = "org.jetbrains.kotlin.tests"
|
|
||||||
version = "0.1"
|
|
||||||
|
|
||||||
kotlin {
|
kotlin {
|
||||||
jvm()
|
jvm()
|
||||||
js()
|
js()
|
||||||
|
|||||||
+11
-3
@@ -8,13 +8,21 @@ repositories {
|
|||||||
}
|
}
|
||||||
|
|
||||||
kotlin {
|
kotlin {
|
||||||
jvm()
|
jvm() {
|
||||||
|
testRuns.named("test") {
|
||||||
|
executionTask.configure {
|
||||||
|
useJUnitPlatform()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
linuxX64()
|
linuxX64()
|
||||||
|
|
||||||
sourceSets.getByName("commonMain").dependencies {
|
sourceSets.getByName("commonMain").dependencies {
|
||||||
implementation(kotlin("stdlib"))
|
implementation(kotlin("stdlib"))
|
||||||
implementation(kotlin("kotlin-test"))
|
|
||||||
|
|
||||||
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4")
|
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sourceSets.getByName("commonTest").dependencies {
|
||||||
|
implementation(kotlin("test"))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
@@ -5,6 +5,7 @@ plugins {
|
|||||||
repositories {
|
repositories {
|
||||||
mavenLocal()
|
mavenLocal()
|
||||||
maven("<localRepo>")
|
maven("<localRepo>")
|
||||||
|
mavenCentral()
|
||||||
}
|
}
|
||||||
|
|
||||||
kotlin {
|
kotlin {
|
||||||
|
|||||||
Reference in New Issue
Block a user