Reformat KotlinVersionsTest

This commit is contained in:
Mikhail Glukhikh
2023-09-19 13:53:25 +02:00
committed by Space Team
parent d1e4e6cc2e
commit a40951d65d
@@ -38,8 +38,8 @@ class KotlinVersionsTest : KtUsefulTestCase() {
data class Version(val major: Int, val minor: Int, val patch: Int?, val versionString: String, val source: String) {
fun isConsistentWith(other: Version): Boolean {
return major == other.major &&
minor == other.minor &&
(patch == null || other.patch == null || patch == other.patch)
minor == other.minor &&
(patch == null || other.patch == null || patch == other.patch)
}
}
@@ -50,37 +50,37 @@ class KotlinVersionsTest : KtUsefulTestCase() {
}
fun String.toVersion(source: String): Version =
toVersionOrNull(source) ?: error("Version ($source) is in an unknown format: $this")
toVersionOrNull(source) ?: error("Version ($source) is in an unknown format: $this")
val versions = arrayListOf<Version>()
// This version is null in case of a local build when KotlinCompilerVersion.VERSION = "@snapshot@"
versions.addIfNotNull(
KotlinCompilerVersion.VERSION.substringBefore('-').toVersionOrNull("KotlinCompilerVersion.VERSION")
KotlinCompilerVersion.VERSION.substringBefore('-').toVersionOrNull("KotlinCompilerVersion.VERSION")
)
versions.add(
ForTestCompileRuntime.runtimeJarClassLoader().loadClass(KotlinVersion::class.qualifiedName!!)
.getDeclaredField(KotlinVersion.Companion::CURRENT.name)
.get(null)
.toString()
.toVersion("KotlinVersion.CURRENT")
ForTestCompileRuntime.runtimeJarClassLoader().loadClass(KotlinVersion::class.qualifiedName!!)
.getDeclaredField(KotlinVersion.Companion::CURRENT.name)
.get(null)
.toString()
.toVersion("KotlinVersion.CURRENT")
)
versions.add(
loadValueFromPomXml("libraries/pom.xml", listOf("project", "version"))
?.toVersion("version in pom.xml")
loadValueFromPomXml("libraries/pom.xml", listOf("project", "version"))
?.toVersion("version in pom.xml")
?: error("No version in libraries/pom.xml")
)
versions.add(
LanguageVersion.LATEST_STABLE.versionString.toVersion("LanguageVersion.LATEST_STABLE")
LanguageVersion.LATEST_STABLE.versionString.toVersion("LanguageVersion.LATEST_STABLE")
)
if (versions.any { v1 -> versions.any { v2 -> !v1.isConsistentWith(v2) } }) {
Assert.fail(
"Some versions are inconsistent. Please change the versions so that they are consistent:\n\n" +
versions.joinToString(separator = "\n") { with(it) { "$versionString ($source)" } }
"Some versions are inconsistent. Please change the versions so that they are consistent:\n\n" +
versions.joinToString(separator = "\n") { with(it) { "$versionString ($source)" } }
)
}
}
@@ -103,14 +103,14 @@ class KotlinVersionsTest : KtUsefulTestCase() {
}
Assert.assertTrue(
"Too few (<= 10) pom.xml files found. Something must be wrong in the test or in the project structure",
poms.size > 10
"Too few (<= 10) pom.xml files found. Something must be wrong in the test or in the project structure",
poms.size > 10
)
if (!poms.map(Pom::version).areEqual()) {
Assert.fail(
"Some versions in pom.xml files are different. Please change the versions so that they are equal:\n\n" +
poms.joinToString(separator = "\n") { (path, version) -> "$version $path" }
"Some versions in pom.xml files are different. Please change the versions so that they are equal:\n\n" +
poms.joinToString(separator = "\n") { (path, version) -> "$version $path" }
)
}
}