Remove deprecated spec tests map generators

This commit is contained in:
victor.petukhov
2019-08-29 18:18:12 +03:00
parent e4938c6c36
commit aa79064a96
15 changed files with 81 additions and 287 deletions
@@ -1,13 +0,0 @@
/*
* This file is generated by {@link org.jetbrains.kotlin.spec.tasks.generateTests}. DO NOT MODIFY MANUALLY.
* This file is used in the HTML version of the Kotlin Specification (https://kotlin.github.io/kotlin-spec) to show tests coverage for sentences.
*
* Content format:
*
* {paragraphNumber}
* {testType: neg|pos}: {sentenceNumber}-{numberOfTests|testPathToAnotherSection}, ...
*/
1
neg: 3-1
pos: 3-2
@@ -1,12 +0,0 @@
/*
* This file is generated by {@link org.jetbrains.kotlin.spec.tasks.generateTests}. DO NOT MODIFY MANUALLY.
* This file is used in the HTML version of the Kotlin Specification (https://kotlin.github.io/kotlin-spec) to show tests coverage for sentences.
*
* Content format:
*
* {paragraphNumber}
* {testType: neg|pos}: {sentenceNumber}-{numberOfTests|testPathToAnotherSection}, ...
*/
1
neg: 2-3, 1-1
@@ -1,12 +0,0 @@
/*
* This file is generated by {@link org.jetbrains.kotlin.spec.tasks.generateTests}. DO NOT MODIFY MANUALLY.
* This file is used in the HTML version of the Kotlin Specification (https://kotlin.github.io/kotlin-spec) to show tests coverage for sentences.
*
* Content format:
*
* {paragraphNumber}
* {testType: neg|pos}: {sentenceNumber}-{numberOfTests|testPathToAnotherSection}, ...
*/
1
neg: 2-2
@@ -1,12 +0,0 @@
/*
* This file is generated by {@link org.jetbrains.kotlin.spec.tasks.generateTests}. DO NOT MODIFY MANUALLY.
* This file is used in the HTML version of the Kotlin Specification (https://kotlin.github.io/kotlin-spec) to show tests coverage for sentences.
*
* Content format:
*
* {paragraphNumber}
* {testType: neg|pos}: {sentenceNumber}-{numberOfTests|testPathToAnotherSection}, ...
*/
1
neg: 2-3, 1-1
@@ -1,24 +0,0 @@
/*
* This file is generated by {@link org.jetbrains.kotlin.spec.tasks.generateTests}. DO NOT MODIFY MANUALLY.
* This file is used in the HTML version of the Kotlin Specification (https://kotlin.github.io/kotlin-spec) to show tests coverage for sentences.
*
* Content format:
*
* {paragraphNumber}
* {testType: neg|pos}: {sentenceNumber}-{numberOfTests|testPathToAnotherSection}, ...
*/
1
neg: 3-1, 1-1
pos: 1-2, 3-2
4
neg: 2-3, 1-2
pos: 1-5
3
neg: 2-1, 1-2
pos: 2-3, 1-5
2
neg: 1-4
pos: 1-2
5
pos: 1-5
@@ -1,13 +0,0 @@
/*
* This file is generated by {@link org.jetbrains.kotlin.spec.tasks.generateTests}. DO NOT MODIFY MANUALLY.
* This file is used in the HTML version of the Kotlin Specification (https://kotlin.github.io/kotlin-spec) to show tests coverage for sentences.
*
* Content format:
*
* {paragraphNumber}
* {testType: neg|pos}: {sentenceNumber}-{numberOfTests|testPathToAnotherSection}, ...
*/
2
neg: 1-2, 3-1, 8-3, 6-1, 7-1
pos: 1-3, 3-1, 8-3, 6-1, 7-1
@@ -1,27 +0,0 @@
/*
* This file is generated by {@link org.jetbrains.kotlin.spec.tasks.generateTests}. DO NOT MODIFY MANUALLY.
* This file is used in the HTML version of the Kotlin Specification (https://kotlin.github.io/kotlin-spec) to show tests coverage for sentences.
*
* Content format:
*
* {paragraphNumber}
* {testType: neg|pos}: {sentenceNumber}-{numberOfTests|testPathToAnotherSection}, ...
*/
9
neg: 1-4
pos: 1-4
7
neg: 1-2, 3-2, 5-2, 7-1
pos: 1-4, 3-2, 5-2, 7-1
6
neg: 1-1
pos: 1-1
3
neg: 2-2, 1-1
pos: 2-3, 1-1
2
pos: 3-2
5
neg: 1-1
pos: 1-1
@@ -1,14 +0,0 @@
/*
* This file is generated by {@link org.jetbrains.kotlin.spec.tasks.generateTests}. DO NOT MODIFY MANUALLY.
* This file is used in the HTML version of the Kotlin Specification (https://kotlin.github.io/kotlin-spec) to show tests coverage for sentences.
*
* Content format:
*
* {paragraphNumber}
* {testType: neg|pos}: {sentenceNumber}-{numberOfTests|testPathToAnotherSection}, ...
*/
7
pos: 2-1, 1-1
5
neg: 2-3
@@ -1,12 +0,0 @@
/*
* This file is generated by {@link org.jetbrains.kotlin.spec.tasks.generateTests}. DO NOT MODIFY MANUALLY.
* This file is used in the HTML version of the Kotlin Specification (https://kotlin.github.io/kotlin-spec) to show tests coverage for sentences.
*
* Content format:
*
* {paragraphNumber}
* {testType: neg|pos}: {sentenceNumber}-{numberOfTests|testPathToAnotherSection}, ...
*/
1
pos: 1-2, 1-type-system/introduction-1/7/pos/1.1.kt
@@ -26,8 +26,6 @@ class SpecTestsConsistencyTest : TestCase() {
companion object {
private val specSentencesStorage = SpecSentencesStorage()
private const val CURRENT_VERSION = "0.1-99"
@org.junit.runners.Parameterized.Parameters(name = "{0}")
@JvmStatic
fun getTestFiles() = emptyList<Array<Any>>()
@@ -1,41 +0,0 @@
/*
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.spec.utils
import com.google.gson.*
import com.google.gson.reflect.TypeToken
import org.jetbrains.kotlin.spec.utils.models.LinkedSpecTest
object TestsJsonMapBuilder {
private val stringListType = object : TypeToken<List<String>>() {}.type
private fun addJsonIfNotExist(element: JsonObject, key: Any): JsonObject {
val stringKey = key.toString()
if (!element.has(stringKey)) element.add(stringKey, JsonObject())
return element.get(stringKey).asJsonObject
}
fun buildJsonElement(testInfo: LinkedSpecTest, testsMap: JsonObject) {
val sectionElement = addJsonIfNotExist(testsMap, testInfo.sections[0])
val paragraphElement =
addJsonIfNotExist(sectionElement, testInfo.place.paragraphNumber)
val sentenceElement =
addJsonIfNotExist(paragraphElement, testInfo.place.sentenceNumber)
val testAreaElement =
addJsonIfNotExist(sentenceElement, testInfo.testArea.name.toLowerCase())
val testTypeElement = addJsonIfNotExist(testAreaElement, testInfo.testType.type)
val testNumberElement = addJsonIfNotExist(testTypeElement, testInfo.testNumber)
testNumberElement.addProperty("description", testInfo.description)
testNumberElement.addProperty("caseNumber", testInfo.cases.byFiles.size)
if (testInfo.unexpectedBehavior)
testNumberElement.addProperty("unexpectedBehavior", testInfo.unexpectedBehavior)
if (testInfo.issues.isNotEmpty())
testNumberElement.add("issues", Gson().toJsonTree(testInfo.issues, stringListType))
}
}
@@ -0,0 +1,78 @@
/*
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.spec.utils
import com.google.gson.GsonBuilder
import com.google.gson.JsonArray
import com.google.gson.JsonElement
import com.google.gson.JsonObject
import org.jetbrains.kotlin.spec.utils.models.LinkedSpecTest
import org.jetbrains.kotlin.spec.utils.models.SpecPlace
import org.jetbrains.kotlin.spec.utils.parsers.CommonParser
import java.io.File
object TestsJsonMapGenerator {
private const val LINKED_TESTS_PATH = "linked"
private const val TESTS_MAP_FILENAME = "testsMap.json"
private inline fun <reified T : JsonElement> JsonObject.getOrCreate(key: String): T {
if (!has(key)) {
add(key, T::class.java.newInstance())
}
return get(key) as T
}
private fun JsonObject.getOrCreateSpecTestObject(specPlace: SpecPlace, testArea: TestArea, testType: TestType): JsonArray {
val sections = "${testArea.testDataPath}/$LINKED_TESTS_PATH/${specPlace.sections.joinToString("/")}"
val testsBySection = getOrCreate<JsonObject>(sections)
val testsByParagraph = testsBySection.getOrCreate<JsonObject>(specPlace.paragraphNumber.toString())
val testsByType = testsByParagraph.getOrCreate<JsonObject>(testType.type)
return testsByType.getOrCreate(specPlace.sentenceNumber.toString())
}
private fun getTestInfo(test: LinkedSpecTest, testFile: File? = null) =
JsonObject().apply {
addProperty("specVersion", test.specVersion)
addProperty("casesNumber", test.cases.byNumbers.size)
addProperty("description", test.description)
addProperty("path", testFile?.path)
addProperty(
"unexpectedBehaviour",
test.unexpectedBehavior || test.cases.byNumbers.any { it.value.unexpectedBehavior }
)
}
fun buildTestsMapPerSection() {
val testsMap = JsonObject()
TestArea.values().forEach { testArea ->
File("${GeneralConfiguration.TESTDATA_PATH}/${testArea.testDataPath}/$LINKED_TESTS_PATH").walkTopDown()
.forEach testFiles@{ file ->
if (!file.isFile || file.extension != "kt") return@testFiles
val (specTest, _) = CommonParser.parseSpecTest(file.canonicalPath, mapOf("main.kt" to file.readText()))
if (specTest is LinkedSpecTest) {
val testInfo = getTestInfo(specTest)
val testInfoWithFilePath = getTestInfo(specTest, file)
testsMap.getOrCreateSpecTestObject(specTest.place, specTest.testArea, specTest.testType).add(testInfo)
specTest.relevantPlaces?.forEach {
testsMap.getOrCreateSpecTestObject(it, specTest.testArea, specTest.testType).add(testInfoWithFilePath)
}
}
}
}
val gson = GsonBuilder().setPrettyPrinting().create()
testsMap.keySet().forEach { testPath ->
File("${GeneralConfiguration.TESTDATA_PATH}/$testPath/$TESTS_MAP_FILENAME").writeText(gson.toJson(testsMap.get(testPath)))
}
}
}
@@ -18,7 +18,7 @@ object HtmlSpecLoader {
private const val SPEC_DOCS_TC_CONFIGURATION_ID = "Kotlin_Spec_DocsMaster"
private const val TC_URL = "https://teamcity.jetbrains.com"
private const val TC_PATH_PREFIX = "guestAuth/app/rest/builds"
private const val HTML_SPEC_PATH = "/html/kotlin-spec.html"
private const val HTML_SPEC_PATH = "/web/kotlin-spec.html"
private const val STABLE_BRANCH = "master"
private fun loadRawHtmlSpec(specVersion: String, buildNumber: String): String {
@@ -1,33 +0,0 @@
/*
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.spec.utils.tasks
import com.google.gson.JsonObject
import org.jetbrains.kotlin.spec.utils.GeneralConfiguration.MODULE_PATH
import org.jetbrains.kotlin.spec.utils.GeneralConfiguration.TESTDATA_PATH
import org.jetbrains.kotlin.spec.utils.TestsJsonMapBuilder
import org.jetbrains.kotlin.spec.utils.models.LinkedSpecTest
import org.jetbrains.kotlin.spec.utils.parsers.CommonParser
import java.io.File
private const val OUT_DIR = "out"
private const val OUT_FILENAME = "testsMap.json"
fun main() {
val testsMap = JsonObject()
File(TESTDATA_PATH).walkTopDown().forEach {
val (specTest, _) = CommonParser.parseSpecTest(it.canonicalPath, mapOf("main.kt" to it.readText()))
if (specTest is LinkedSpecTest)
TestsJsonMapBuilder.buildJsonElement(specTest, testsMap)
}
val outDir = "$MODULE_PATH/$OUT_DIR"
File(outDir).mkdir()
File("$outDir/$OUT_FILENAME").writeText(testsMap.toString())
}
@@ -5,82 +5,13 @@
package org.jetbrains.kotlin.spec.utils.tasks
import com.google.gson.GsonBuilder
import com.google.gson.JsonArray
import com.google.gson.JsonElement
import com.google.gson.JsonObject
import org.jetbrains.kotlin.generators.tests.generator.testGroup
import org.jetbrains.kotlin.spec.checkers.AbstractDiagnosticsTestSpec
import org.jetbrains.kotlin.spec.codegen.AbstractBlackBoxCodegenTestSpec
import org.jetbrains.kotlin.spec.parsing.AbstractParsingTestSpec
import org.jetbrains.kotlin.spec.utils.GeneralConfiguration.TESTDATA_PATH
import org.jetbrains.kotlin.spec.utils.GeneralConfiguration.TEST_PATH
import org.jetbrains.kotlin.spec.utils.TestArea
import org.jetbrains.kotlin.spec.utils.TestType
import org.jetbrains.kotlin.spec.utils.models.LinkedSpecTest
import org.jetbrains.kotlin.spec.utils.models.SpecPlace
import org.jetbrains.kotlin.spec.utils.parsers.CommonParser
import java.io.File
private object TestsMapGenerator {
private const val LINKED_TESTS_PATH = "linked"
private const val TESTS_MAP_FILENAME = "testsMap.json"
private inline fun <reified T : JsonElement> JsonObject.getOrCreate(key: String): T {
if (!has(key)) {
add(key, T::class.java.newInstance())
}
return get(key) as T
}
private fun JsonObject.getOrCreateSpecTestObject(specPlace: SpecPlace, testArea: TestArea, testType: TestType): JsonArray {
val sections = "${testArea.testDataPath}/$LINKED_TESTS_PATH/${specPlace.sections.joinToString("/")}"
val testsBySection = getOrCreate<JsonObject>(sections)
val testsByParagraph = testsBySection.getOrCreate<JsonObject>(specPlace.paragraphNumber.toString())
val testsByType = testsByParagraph.getOrCreate<JsonObject>(testType.type)
return testsByType.getOrCreate(specPlace.sentenceNumber.toString())
}
private fun getTestInfo(test: LinkedSpecTest) =
JsonObject().apply {
addProperty("specVersion", test.specVersion)
addProperty("casesNumber", test.cases.byNumbers.size)
addProperty("description", test.description)
addProperty(
"unexpectedBehaviour",
test.unexpectedBehavior || test.cases.byNumbers.any { it.value.unexpectedBehavior }
)
}
fun buildTestsMapPerSection() {
val testsMap = JsonObject()
TestArea.values().forEach { testArea ->
File("$TESTDATA_PATH/${testArea.testDataPath}/$LINKED_TESTS_PATH").walkTopDown().forEach testFiles@ { file ->
if (!file.isFile || file.extension != "kt") return@testFiles
val (specTest, _) = CommonParser.parseSpecTest(file.canonicalPath, mapOf("main.kt" to file.readText()))
if (specTest is LinkedSpecTest) {
val testInfo = getTestInfo(specTest)
testsMap.getOrCreateSpecTestObject(specTest.place, specTest.testArea, specTest.testType).add(testInfo)
specTest.relevantPlaces?.forEach {
testsMap.getOrCreateSpecTestObject(it, specTest.testArea, specTest.testType).add(testInfo)
}
}
}
}
val gson = GsonBuilder().setPrettyPrinting().create()
testsMap.keySet().forEach { testPath ->
File("$TESTDATA_PATH/$testPath/$TESTS_MAP_FILENAME").writeText(gson.toJson(testsMap.get(testPath)))
}
}
}
import org.jetbrains.kotlin.spec.utils.TestsJsonMapGenerator
fun generateTests() {
testGroup(TEST_PATH, TESTDATA_PATH) {
@@ -97,6 +28,6 @@ fun generateTests() {
}
fun main() {
TestsMapGenerator.buildTestsMapPerSection()
TestsJsonMapGenerator.buildTestsMapPerSection()
generateTests()
}