Allow any classifiers for DEV maturity
Allow to have personal builds with custom versioning. KTI-922
This commit is contained in:
+2
-2
@@ -49,12 +49,12 @@ class KotlinToolingVersion(
|
||||
val classifier = this.classifier?.toLowerCase(Locale.ROOT)
|
||||
when {
|
||||
classifier == null || classifier.matches(Regex("""(release-)?\d+""")) -> Maturity.STABLE
|
||||
classifier == "snapshot" -> Maturity.SNAPSHOT
|
||||
classifier.matches(Regex("""(rc)(\d*)?(-release)?-?\d*""")) -> Maturity.RC
|
||||
classifier.matches(Regex("""beta(\d*)?(-release)?-?\d*""")) -> Maturity.BETA
|
||||
classifier.matches(Regex("""alpha(\d*)?(-release)?-?\d*""")) -> Maturity.ALPHA
|
||||
classifier.matches(Regex("""m\d+(-release)?(-\d*)?""")) -> Maturity.MILESTONE
|
||||
classifier.matches(Regex("""(dev|pub)(-(\w|-)+)?-?\d*""")) -> Maturity.DEV
|
||||
classifier == "snapshot" -> Maturity.SNAPSHOT
|
||||
classifier.matches(Regex("""([a-zA-Z]{3,})(-[a-zA-Z]\w*)*(-\d+)?""")) -> Maturity.DEV
|
||||
else -> throw IllegalArgumentException("Can't infer maturity of KotlinVersion $this")
|
||||
}
|
||||
}
|
||||
|
||||
+22
-2
@@ -163,6 +163,16 @@ class KotlinToolingVersionTest {
|
||||
assertMaturity(DEV, "1.6.20-pUb")
|
||||
assertMaturity(DEV, "1.6.20-dev-google-pr")
|
||||
assertMaturity(DEV, "1.6.20-dev-google-pr-510")
|
||||
assertMaturity(DEV, "1.8.0-one-two-three-2022")
|
||||
assertMaturity(DEV, "1.8.0-one-a1-b2-2022")
|
||||
assertMaturity(DEV, "1.8.0-temporary-999")
|
||||
assertMaturity(DEV, "1.8.0-snapshot-42", "Looks strange but snapshot is rather special to allow more usages")
|
||||
assertMaturity(null, "1.8.0-dev-", "Forbid dash at the end")
|
||||
assertMaturity(null, "1.8.0-t-1000", "Forbid too short first classifier")
|
||||
assertMaturity(null, "1.8.0-no-1", "First classifier should be strictly longer than 2 letters")
|
||||
assertMaturity(null, "1.8.0-dev----999", "Forbid many dashes in a row")
|
||||
assertMaturity(null, "1.8.0-999-0", "Forbid fully digit classifier")
|
||||
assertMaturity(null, "1.8.0-some-5-0", "Forbid fully digit second classifier")
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -201,6 +211,8 @@ class KotlinToolingVersionTest {
|
||||
assertBuildNumber(510, "1.6.20-pub-myWildcard-510")
|
||||
assertBuildNumber(510, "1.6.20-dev-myWildcard1-510")
|
||||
assertBuildNumber(510, "1.6.20-pub-myWildcard1-510")
|
||||
assertBuildNumber(510, "1.6.20-some-510")
|
||||
assertBuildNumber(510, "1.6.20-aaa-a2-a3-510")
|
||||
assertBuildNumber(null,"1.6.20-dev-myWildcard510")
|
||||
|
||||
/* dev with - in wildcards */
|
||||
@@ -305,7 +317,15 @@ class KotlinToolingVersionTest {
|
||||
assertEquals(classifierNumber, KotlinToolingVersion(version).classifierNumber, message)
|
||||
}
|
||||
|
||||
private fun assertMaturity(maturity: KotlinToolingVersion.Maturity?, version: String) {
|
||||
assertEquals(maturity, KotlinToolingVersion(version).maturity)
|
||||
private fun assertMaturity(maturity: KotlinToolingVersion.Maturity?, version: String, message: String? = null) {
|
||||
if (maturity == null) {
|
||||
val exception = assertFailsWith<IllegalArgumentException>(
|
||||
"Parsing maturity is expected to be failed for `$version`${message?.let { ". $it" } ?: ""}") {
|
||||
KotlinToolingVersion(version)
|
||||
}
|
||||
assertTrue("maturity" in exception.message.orEmpty().toLowerCase(), "Expected 'maturity' issue mentioned in error message")
|
||||
} else {
|
||||
assertEquals(maturity, KotlinToolingVersion(version).maturity, message)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user