[Spec tests] Fix mistakes during parsing compiler tests to extract spec links
This commit is contained in:
Generated
+4
-4
@@ -25,7 +25,7 @@ public class BlackBoxCodegenTestSpecGenerated extends AbstractBlackBoxCodegenTes
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInBox() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/tests-spec/testData/codegen/box"), Pattern.compile("^(.+)\\.kt$"), null, true, "helpers", "templates", "linked/overload-resolution/building-the-overload-candidate-set-ocs/call-with-an-explicit-receiver");
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/tests-spec/testData/codegen/box"), Pattern.compile("^(.+)\\.kt$"), null, true, "helpers", "templates", "linked/type-inference", "linked/expressions/when-expression/exhaustive-when-expressions", "linked/overload-resolution/building-the-overload-candidate-set-ocs/call-with-an-explicit-receiver");
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/tests-spec/testData/codegen/box/linked")
|
||||
@@ -37,7 +37,7 @@ public class BlackBoxCodegenTestSpecGenerated extends AbstractBlackBoxCodegenTes
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInLinked() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/tests-spec/testData/codegen/box/linked"), Pattern.compile("^(.+)\\.kt$"), null, true, "overload-resolution/building-the-overload-candidate-set-ocs/call-with-an-explicit-receiver");
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/tests-spec/testData/codegen/box/linked"), Pattern.compile("^(.+)\\.kt$"), null, true, "type-inference", "expressions/when-expression/exhaustive-when-expressions", "overload-resolution/building-the-overload-candidate-set-ocs/call-with-an-explicit-receiver");
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/tests-spec/testData/codegen/box/linked/expressions")
|
||||
@@ -49,7 +49,7 @@ public class BlackBoxCodegenTestSpecGenerated extends AbstractBlackBoxCodegenTes
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInExpressions() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/tests-spec/testData/codegen/box/linked/expressions"), Pattern.compile("^(.+)\\.kt$"), null, true);
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/tests-spec/testData/codegen/box/linked/expressions"), Pattern.compile("^(.+)\\.kt$"), null, true, "when-expression/exhaustive-when-expressions");
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/tests-spec/testData/codegen/box/linked/expressions/additive-expression")
|
||||
@@ -3160,7 +3160,7 @@ public class BlackBoxCodegenTestSpecGenerated extends AbstractBlackBoxCodegenTes
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInWhen_expression() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/tests-spec/testData/codegen/box/linked/expressions/when-expression"), Pattern.compile("^(.+)\\.kt$"), null, true);
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/tests-spec/testData/codegen/box/linked/expressions/when-expression"), Pattern.compile("^(.+)\\.kt$"), null, true, "exhaustive-when-expressions");
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/tests-spec/testData/codegen/box/linked/expressions/when-expression/p-4")
|
||||
|
||||
+4
-4
@@ -25,7 +25,7 @@ public class ParsingTestSpecGenerated extends AbstractParsingTestSpec {
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInPsi() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/tests-spec/testData/psi"), Pattern.compile("^(.+)\\.kt$"), null, true, "helpers", "templates");
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/tests-spec/testData/psi"), Pattern.compile("^(.+)\\.kt$"), null, true, "helpers", "templates", "linked/type-inference", "linked/expressions/when-expression/exhaustive-when-expressions");
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/tests-spec/testData/psi/linked")
|
||||
@@ -37,7 +37,7 @@ public class ParsingTestSpecGenerated extends AbstractParsingTestSpec {
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInLinked() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/tests-spec/testData/psi/linked"), Pattern.compile("^(.+)\\.kt$"), null, true);
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/tests-spec/testData/psi/linked"), Pattern.compile("^(.+)\\.kt$"), null, true, "type-inference", "expressions/when-expression/exhaustive-when-expressions");
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/tests-spec/testData/psi/linked/expressions")
|
||||
@@ -49,7 +49,7 @@ public class ParsingTestSpecGenerated extends AbstractParsingTestSpec {
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInExpressions() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/tests-spec/testData/psi/linked/expressions"), Pattern.compile("^(.+)\\.kt$"), null, true);
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/tests-spec/testData/psi/linked/expressions"), Pattern.compile("^(.+)\\.kt$"), null, true, "when-expression/exhaustive-when-expressions");
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/tests-spec/testData/psi/linked/expressions/constant-literals")
|
||||
@@ -981,7 +981,7 @@ public class ParsingTestSpecGenerated extends AbstractParsingTestSpec {
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInWhen_expression() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/tests-spec/testData/psi/linked/expressions/when-expression"), Pattern.compile("^(.+)\\.kt$"), null, true);
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/tests-spec/testData/psi/linked/expressions/when-expression"), Pattern.compile("^(.+)\\.kt$"), null, true, "exhaustive-when-expressions");
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/tests-spec/testData/psi/linked/expressions/when-expression/p-1")
|
||||
|
||||
+13
-23
@@ -10,11 +10,9 @@ 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.LinkedSpecTest.Companion.getInstanceForImplementationTest
|
||||
import org.jetbrains.kotlin.spec.utils.models.SpecPlace
|
||||
import org.jetbrains.kotlin.spec.utils.parsers.CommonParser
|
||||
import org.jetbrains.kotlin.spec.utils.parsers.CommonParser.parseImplementationTest
|
||||
import org.jetbrains.kotlin.spec.utils.parsers.ImplementationTestPatterns
|
||||
import java.io.File
|
||||
|
||||
object TestsJsonMapGenerator {
|
||||
@@ -49,9 +47,7 @@ object TestsJsonMapGenerator {
|
||||
)
|
||||
}
|
||||
|
||||
private fun collectInfoFromSpecTests(): JsonObject {
|
||||
val testsMap = JsonObject()
|
||||
|
||||
private fun collectInfoFromSpecTests(testsMap: JsonObject) {
|
||||
TestArea.values().forEach { testArea ->
|
||||
File("${GeneralConfiguration.SPEC_TESTDATA_PATH}/${testArea.testDataPath}/$LINKED_TESTS_PATH").walkTopDown()
|
||||
.forEach testFiles@{ file ->
|
||||
@@ -71,41 +67,35 @@ object TestsJsonMapGenerator {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return testsMap
|
||||
}
|
||||
|
||||
private fun collectInfoFromImplementationTests(): JsonObject {
|
||||
val testsMap = JsonObject()
|
||||
|
||||
private fun collectInfoFromImplementationTests(testsMap: JsonObject) {
|
||||
TestArea.values().forEach { testArea ->
|
||||
val files = File("${GeneralConfiguration.TESTDATA_PATH}/${testArea.testDataPath}").walkTopDown()
|
||||
|
||||
for (file in files) {
|
||||
if (!file.isFile || file.extension != "kt") continue
|
||||
|
||||
val parserImplementationTest = parseImplementationTest(file, testArea)
|
||||
val relevantPlaces = parserImplementationTest.relevantPlaces ?: listOf()
|
||||
val parsedImplementationTest = parseImplementationTest(file, testArea) ?: continue
|
||||
val relevantPlaces = parsedImplementationTest.relevantPlaces ?: listOf()
|
||||
|
||||
(relevantPlaces + parserImplementationTest.place).forEach { specPlace ->
|
||||
testsMap.getOrCreateSpecTestObject(specPlace, testArea, parserImplementationTest.testType).add(
|
||||
getTestInfo(parseImplementationTest(file, testArea), file)
|
||||
(relevantPlaces + parsedImplementationTest.place).forEach specPlaces@ { specPlace ->
|
||||
val parsedAdditionalImplementationTest = parseImplementationTest(file, testArea) ?: return@specPlaces
|
||||
|
||||
testsMap.getOrCreateSpecTestObject(specPlace, testArea, parsedImplementationTest.testType).add(
|
||||
getTestInfo(parsedAdditionalImplementationTest, file)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return testsMap
|
||||
}
|
||||
|
||||
operator fun JsonObject.plus(other: JsonObject) =
|
||||
JsonObject().also { new ->
|
||||
this.keySet().forEach { new.add(it, this.get(it)) }
|
||||
other.keySet().forEach { new.add(it, other.get(it)) }
|
||||
fun buildTestsMapPerSection() {
|
||||
val testsMap = JsonObject().apply {
|
||||
collectInfoFromSpecTests(this)
|
||||
collectInfoFromImplementationTests(this)
|
||||
}
|
||||
|
||||
fun buildTestsMapPerSection() {
|
||||
val testsMap = collectInfoFromSpecTests() + collectInfoFromImplementationTests()
|
||||
val gson = GsonBuilder().setPrettyPrinting().create()
|
||||
|
||||
testsMap.keySet().forEach { testPath ->
|
||||
|
||||
@@ -63,7 +63,7 @@ class LinkedSpecTest(
|
||||
|
||||
return LinkedSpecTest(
|
||||
specVersion, testArea, testType, specPlaces.first(),
|
||||
specPlaces.subList(1, specPlaces.size - 1), 0, description,
|
||||
if (specPlaces.size > 1) specPlaces.subList(1, specPlaces.size) else null, 0, description,
|
||||
SpecTestCasesSet(mutableMapOf(), mutableMapOf(), mutableMapOf()),
|
||||
unexpectedBehavior = false, unspecifiedBehavior = false, issues = setOf(), helpers = null, exception = null
|
||||
)
|
||||
|
||||
@@ -44,11 +44,11 @@ object CommonParser {
|
||||
throw SpecTestValidationException(SpecTestValidationFailedReason.FILENAME_NOT_VALID)
|
||||
}
|
||||
|
||||
fun parseImplementationTest(file: File, testArea: TestArea): LinkedSpecTest {
|
||||
fun parseImplementationTest(file: File, testArea: TestArea): LinkedSpecTest? {
|
||||
val matcher = ImplementationTestPatterns.testInfoPattern.matcher(file.readText())
|
||||
|
||||
if (!matcher.find())
|
||||
throw SpecTestValidationException(SpecTestValidationFailedReason.TESTINFO_NOT_VALID)
|
||||
return null
|
||||
|
||||
val testType = TestType.fromValue(matcher.group("testType"))
|
||||
?: throw SpecTestValidationException(SpecTestValidationFailedReason.TESTINFO_NOT_VALID)
|
||||
|
||||
Reference in New Issue
Block a user