diff --git a/compiler/tests-spec/testData/diagnostics/linked/expressions/constant-literals/boolean-literals/testsMap.txt b/compiler/tests-spec/testData/diagnostics/linked/expressions/constant-literals/boolean-literals/testsMap.txt deleted file mode 100644 index aabfe681088..00000000000 --- a/compiler/tests-spec/testData/diagnostics/linked/expressions/constant-literals/boolean-literals/testsMap.txt +++ /dev/null @@ -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 diff --git a/compiler/tests-spec/testData/diagnostics/linked/expressions/constant-literals/integer-literals/binary-integer-literals/testsMap.txt b/compiler/tests-spec/testData/diagnostics/linked/expressions/constant-literals/integer-literals/binary-integer-literals/testsMap.txt deleted file mode 100644 index 32fc004e4b6..00000000000 --- a/compiler/tests-spec/testData/diagnostics/linked/expressions/constant-literals/integer-literals/binary-integer-literals/testsMap.txt +++ /dev/null @@ -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 diff --git a/compiler/tests-spec/testData/diagnostics/linked/expressions/constant-literals/integer-literals/decimal-integer-literals/testsMap.txt b/compiler/tests-spec/testData/diagnostics/linked/expressions/constant-literals/integer-literals/decimal-integer-literals/testsMap.txt deleted file mode 100644 index 8c98e4da46e..00000000000 --- a/compiler/tests-spec/testData/diagnostics/linked/expressions/constant-literals/integer-literals/decimal-integer-literals/testsMap.txt +++ /dev/null @@ -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 diff --git a/compiler/tests-spec/testData/diagnostics/linked/expressions/constant-literals/integer-literals/hexadecimal-integer-literals/testsMap.txt b/compiler/tests-spec/testData/diagnostics/linked/expressions/constant-literals/integer-literals/hexadecimal-integer-literals/testsMap.txt deleted file mode 100644 index 32fc004e4b6..00000000000 --- a/compiler/tests-spec/testData/diagnostics/linked/expressions/constant-literals/integer-literals/hexadecimal-integer-literals/testsMap.txt +++ /dev/null @@ -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 diff --git a/compiler/tests-spec/testData/diagnostics/linked/expressions/constant-literals/real-literals/testsMap.txt b/compiler/tests-spec/testData/diagnostics/linked/expressions/constant-literals/real-literals/testsMap.txt deleted file mode 100644 index fe5996f47b7..00000000000 --- a/compiler/tests-spec/testData/diagnostics/linked/expressions/constant-literals/real-literals/testsMap.txt +++ /dev/null @@ -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 diff --git a/compiler/tests-spec/testData/diagnostics/linked/expressions/when-expression/exhaustive-when-expressions/testsMap.txt b/compiler/tests-spec/testData/diagnostics/linked/expressions/when-expression/exhaustive-when-expressions/testsMap.txt deleted file mode 100644 index ec9343d12d6..00000000000 --- a/compiler/tests-spec/testData/diagnostics/linked/expressions/when-expression/exhaustive-when-expressions/testsMap.txt +++ /dev/null @@ -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 diff --git a/compiler/tests-spec/testData/diagnostics/linked/expressions/when-expression/testsMap.txt b/compiler/tests-spec/testData/diagnostics/linked/expressions/when-expression/testsMap.txt deleted file mode 100644 index 73924e9cb46..00000000000 --- a/compiler/tests-spec/testData/diagnostics/linked/expressions/when-expression/testsMap.txt +++ /dev/null @@ -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 diff --git a/compiler/tests-spec/testData/diagnostics/linked/type-system/introduction-1/testsMap.txt b/compiler/tests-spec/testData/diagnostics/linked/type-system/introduction-1/testsMap.txt deleted file mode 100644 index f12d715f0df..00000000000 --- a/compiler/tests-spec/testData/diagnostics/linked/type-system/introduction-1/testsMap.txt +++ /dev/null @@ -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 diff --git a/compiler/tests-spec/testData/diagnostics/linked/type-system/type-kinds/built-in-types/kotlin.any/testsMap.txt b/compiler/tests-spec/testData/diagnostics/linked/type-system/type-kinds/built-in-types/kotlin.any/testsMap.txt deleted file mode 100644 index 1243e462d27..00000000000 --- a/compiler/tests-spec/testData/diagnostics/linked/type-system/type-kinds/built-in-types/kotlin.any/testsMap.txt +++ /dev/null @@ -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 diff --git a/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/consistency/SpecTestsConsistencyTest.kt b/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/consistency/SpecTestsConsistencyTest.kt index 027ae4ef196..ffb9239f04e 100644 --- a/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/consistency/SpecTestsConsistencyTest.kt +++ b/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/consistency/SpecTestsConsistencyTest.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>() diff --git a/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/utils/TestsJsonMapBuilder.kt b/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/utils/TestsJsonMapBuilder.kt deleted file mode 100644 index 5fc5e618b8f..00000000000 --- a/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/utils/TestsJsonMapBuilder.kt +++ /dev/null @@ -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>() {}.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)) - } -} \ No newline at end of file diff --git a/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/utils/TestsJsonMapGenerator.kt b/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/utils/TestsJsonMapGenerator.kt new file mode 100644 index 00000000000..f109177409b --- /dev/null +++ b/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/utils/TestsJsonMapGenerator.kt @@ -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 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(sections) + val testsByParagraph = testsBySection.getOrCreate(specPlace.paragraphNumber.toString()) + val testsByType = testsByParagraph.getOrCreate(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))) + } + } +} diff --git a/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/utils/spec/HtmlSpecLoader.kt b/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/utils/spec/HtmlSpecLoader.kt index 162d4ddcf02..ff9dd40b6d8 100644 --- a/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/utils/spec/HtmlSpecLoader.kt +++ b/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/utils/spec/HtmlSpecLoader.kt @@ -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 { diff --git a/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/utils/tasks/GenerateJsonTestsMap.kt b/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/utils/tasks/GenerateJsonTestsMap.kt deleted file mode 100644 index 1d7f7a38edc..00000000000 --- a/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/utils/tasks/GenerateJsonTestsMap.kt +++ /dev/null @@ -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()) -} \ No newline at end of file diff --git a/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/utils/tasks/GenerateSpecTests.kt b/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/utils/tasks/GenerateSpecTests.kt index 95bed21ffcb..438a37cc177 100644 --- a/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/utils/tasks/GenerateSpecTests.kt +++ b/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/utils/tasks/GenerateSpecTests.kt @@ -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 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(sections) - val testsByParagraph = testsBySection.getOrCreate(specPlace.paragraphNumber.toString()) - val testsByType = testsByParagraph.getOrCreate(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() }