Remove bunch tool chunks

This commit is contained in:
Nikolay Krasko
2023-03-06 13:37:21 +01:00
committed by Space Team
parent 79fff92dc1
commit e42e2b28db
4 changed files with 0 additions and 80 deletions
-1
View File
@@ -1 +0,0 @@
203
-1
View File
@@ -379,7 +379,6 @@
*Generated.java "Kotlin" "Kotlin IDE"
# Singular files
/.bunch "Kotlin Build Infrastructure"
/.gitattributes "Kotlin Build Infrastructure"
/.space.kts "Kotlin Build Infrastructure"
/ChangeLog.md "Kotlin Release"
@@ -19,17 +19,8 @@ fun main() {
fun syncMutedTestsOnTeamCityWithDatabase() {
val remotelyMutedTests = RemotelyMutedTests()
val locallyMutedTests = LocallyMutedTests()
val bunches = Bunches.parseRulesToBunches(locallyMutedTests.tests.keys)
syncMutedTests(remotelyMutedTests.projectTests, locallyMutedTests.projectTests)
for ((originalBunchId, foundBunchId) in bunches) {
getBuildTypeIds(originalBunchId)?.let { buildTypeIds ->
for (buildTypeId in buildTypeIds.split(",")) {
syncMutedTests(remotelyMutedTests.getTestsJson(buildTypeId), locallyMutedTests.getTestsJson(foundBunchId, buildTypeId))
}
}
}
}
private fun syncMutedTests(
@@ -45,34 +36,8 @@ private fun syncMutedTests(
internal fun getMandatoryProperty(propertyName: String) = (System.getProperty(propertyName)
?: throw Exception("Property $propertyName must be set"))
object Bunches {
private val bunchRules: List<String> = readAllRulesFromFile()
internal val baseBunchId = bunchRules.first()
internal fun parseRulesToBunches(platforms: Set<String>): Map<String, String> {
return bunchRules
.map { it.split('_') }
.map { rule ->
rule.first() to (rule.find { platforms.contains(it) } ?: baseBunchId)
}.toMap()
}
private fun readAllRulesFromFile(): List<String> {
val file = File("../../..", ".bunch")
if (!file.exists()) {
throw BunchException("Can't build list of rules. File '${file.canonicalPath}' doesn't exist")
}
return file.readLines()
.map { it.trim() }
.filter { it.isNotEmpty() }
}
private class BunchException(msg: String? = null) : Exception(msg)
}
private const val mutesPackageName = "org.jetbrains.kotlin.test.mutes"
internal val projectId = getMandatoryProperty("$mutesPackageName.tests.project.id")
internal fun getBuildTypeIds(bunchId: String) = System.getProperty("$mutesPackageName.$bunchId")
class RemotelyMutedTests {
val tests = getMutedTestsOnTeamcityForRootProject(projectId)
@@ -154,49 +154,6 @@ class CodeConformanceTest : TestCase() {
}
}
private fun isCorrectExtension(filename: String, extensions: Set<String>): Boolean {
val additionalExtensions = listOf(
"after", "new", "before", "expected",
"todo", "delete", "touch", "prefix", "postfix", "map",
"fragment", "after2", "result", "log", "messages", "conflicts", "match", "imports", "txt", "xml"
)
val possibleAdditionalExtensions = extensions.plus(additionalExtensions)
val fileExtensions = filename.split("\\.").drop(1)
if (fileExtensions.size < 2) {
return true
}
val extension = fileExtensions.last()
return !((extension !in possibleAdditionalExtensions && (extension.toIntOrNull() ?: MAX_STEPS_COUNT) >= MAX_STEPS_COUNT))
}
fun testForgottenBunchDirectivesAndFiles() {
val sourceBunchFilePattern = Pattern.compile("(.+\\.java|.+\\.kt|.+\\.js)(\\.\\w+)?")
val root = nonSourcesMatcher.root
val extensions = File(root, ".bunch").readLines().map { it.split("_") }.flatten().toSet()
val failBuilder = mutableListOf<String>()
nonSourcesMatcher.excludeWalkTopDown(sourceBunchFilePattern).forEach { sourceFile ->
val matches = Regex("BUNCH (\\w+)")
.findAll(sourceFile.readText())
.map { it.groupValues[1] }
.toSet()
.filterNot { it in extensions }
for (bunch in matches) {
val filename = FileUtil.toSystemIndependentName(sourceFile.toRelativeString(root))
failBuilder.add("$filename has unregistered $bunch bunch directive")
}
if (!isCorrectExtension(sourceFile.name, extensions)) {
val filename = FileUtil.toSystemIndependentName(sourceFile.toRelativeString(root))
failBuilder.add("$filename has unknown bunch extension")
}
}
if (failBuilder.isNotEmpty()) {
fail("\n" + failBuilder.joinToString("\n"))
}
}
fun testNoBadSubstringsInProjectCode() {
class TestData(val message: String, val filter: (File, String) -> Boolean) {
val result: MutableList<File> = ArrayList()