Reformat KotlinVersionsTest
This commit is contained in:
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) {
|
data class Version(val major: Int, val minor: Int, val patch: Int?, val versionString: String, val source: String) {
|
||||||
fun isConsistentWith(other: Version): Boolean {
|
fun isConsistentWith(other: Version): Boolean {
|
||||||
return major == other.major &&
|
return major == other.major &&
|
||||||
minor == other.minor &&
|
minor == other.minor &&
|
||||||
(patch == null || other.patch == null || patch == other.patch)
|
(patch == null || other.patch == null || patch == other.patch)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -50,37 +50,37 @@ class KotlinVersionsTest : KtUsefulTestCase() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun String.toVersion(source: String): Version =
|
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>()
|
val versions = arrayListOf<Version>()
|
||||||
|
|
||||||
// This version is null in case of a local build when KotlinCompilerVersion.VERSION = "@snapshot@"
|
// This version is null in case of a local build when KotlinCompilerVersion.VERSION = "@snapshot@"
|
||||||
versions.addIfNotNull(
|
versions.addIfNotNull(
|
||||||
KotlinCompilerVersion.VERSION.substringBefore('-').toVersionOrNull("KotlinCompilerVersion.VERSION")
|
KotlinCompilerVersion.VERSION.substringBefore('-').toVersionOrNull("KotlinCompilerVersion.VERSION")
|
||||||
)
|
)
|
||||||
|
|
||||||
versions.add(
|
versions.add(
|
||||||
ForTestCompileRuntime.runtimeJarClassLoader().loadClass(KotlinVersion::class.qualifiedName!!)
|
ForTestCompileRuntime.runtimeJarClassLoader().loadClass(KotlinVersion::class.qualifiedName!!)
|
||||||
.getDeclaredField(KotlinVersion.Companion::CURRENT.name)
|
.getDeclaredField(KotlinVersion.Companion::CURRENT.name)
|
||||||
.get(null)
|
.get(null)
|
||||||
.toString()
|
.toString()
|
||||||
.toVersion("KotlinVersion.CURRENT")
|
.toVersion("KotlinVersion.CURRENT")
|
||||||
)
|
)
|
||||||
|
|
||||||
versions.add(
|
versions.add(
|
||||||
loadValueFromPomXml("libraries/pom.xml", listOf("project", "version"))
|
loadValueFromPomXml("libraries/pom.xml", listOf("project", "version"))
|
||||||
?.toVersion("version in pom.xml")
|
?.toVersion("version in pom.xml")
|
||||||
?: error("No version in libraries/pom.xml")
|
?: error("No version in libraries/pom.xml")
|
||||||
)
|
)
|
||||||
|
|
||||||
versions.add(
|
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) } }) {
|
if (versions.any { v1 -> versions.any { v2 -> !v1.isConsistentWith(v2) } }) {
|
||||||
Assert.fail(
|
Assert.fail(
|
||||||
"Some versions are inconsistent. Please change the versions so that they are consistent:\n\n" +
|
"Some versions are inconsistent. Please change the versions so that they are consistent:\n\n" +
|
||||||
versions.joinToString(separator = "\n") { with(it) { "$versionString ($source)" } }
|
versions.joinToString(separator = "\n") { with(it) { "$versionString ($source)" } }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -103,14 +103,14 @@ class KotlinVersionsTest : KtUsefulTestCase() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Assert.assertTrue(
|
Assert.assertTrue(
|
||||||
"Too few (<= 10) pom.xml files found. Something must be wrong in the test or in the project structure",
|
"Too few (<= 10) pom.xml files found. Something must be wrong in the test or in the project structure",
|
||||||
poms.size > 10
|
poms.size > 10
|
||||||
)
|
)
|
||||||
|
|
||||||
if (!poms.map(Pom::version).areEqual()) {
|
if (!poms.map(Pom::version).areEqual()) {
|
||||||
Assert.fail(
|
Assert.fail(
|
||||||
"Some versions in pom.xml files are different. Please change the versions so that they are equal:\n\n" +
|
"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" }
|
poms.joinToString(separator = "\n") { (path, version) -> "$version $path" }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user