[Spec tests] Add linkType element to testMaps
This commit is contained in:
@@ -35,7 +35,16 @@ object TestsJsonMapGenerator {
|
||||
return testsByType.getOrCreate(specPlace.sentenceNumber.toString())
|
||||
}
|
||||
|
||||
private fun getTestInfo(test: LinkedSpecTest, testFile: File? = null) =
|
||||
enum class LinkType{
|
||||
MAIN,
|
||||
PRIMARY,
|
||||
SECONDARY;
|
||||
|
||||
override fun toString(): String {
|
||||
return name.toLowerCase()
|
||||
}
|
||||
}
|
||||
private fun getTestInfo(test: LinkedSpecTest, testFile: File? = null, linkType: LinkType = LinkType.MAIN) =
|
||||
JsonObject().apply {
|
||||
addProperty("specVersion", test.specVersion)
|
||||
addProperty("casesNumber", test.cases.byNumbers.size)
|
||||
@@ -45,6 +54,7 @@ object TestsJsonMapGenerator {
|
||||
"unexpectedBehaviour",
|
||||
test.unexpectedBehavior || test.cases.byNumbers.any { it.value.unexpectedBehavior }
|
||||
)
|
||||
addProperty("linkType", linkType.toString())
|
||||
}
|
||||
|
||||
private fun collectInfoFromSpecTests(testsMap: JsonObject) {
|
||||
@@ -54,7 +64,13 @@ object TestsJsonMapGenerator {
|
||||
if (!file.isFile || file.extension != "kt" || file.name.endsWith(".fir.kt")) return@testFiles
|
||||
val (specTest, _) = CommonParser.parseSpecTest(file.canonicalPath, mapOf("main.kt" to file.readText()))
|
||||
if (specTest is LinkedSpecTest) {
|
||||
collectInfoFromTests(testsMap, specTest, getTestInfo(specTest), getTestInfo(specTest, file))
|
||||
collectInfoFromTestsTemp(
|
||||
testsMap = testsMap,
|
||||
specTest = specTest,
|
||||
testInfoForMainLink = getTestInfo(specTest),
|
||||
testInfoForPrimaryLink = getTestInfo(specTest, file, LinkType.PRIMARY),
|
||||
testInfoForSecondaryLink = getTestInfo(specTest, file, LinkType.SECONDARY)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -80,9 +96,28 @@ object TestsJsonMapGenerator {
|
||||
testInfoForRelevantLink: JsonObject = testInfoForMainLink
|
||||
) {
|
||||
testsMap.getOrCreateSpecTestObject(specTest.place, specTest.testArea, specTest.testType).add(testInfoForMainLink)
|
||||
specTest.relevantPlaces?.forEach {
|
||||
specTest.primaryLinks?.forEach {
|
||||
testsMap.getOrCreateSpecTestObject(it, specTest.testArea, specTest.testType).add(testInfoForRelevantLink)
|
||||
}
|
||||
specTest.secondaryLinks?.forEach {
|
||||
testsMap.getOrCreateSpecTestObject(it, specTest.testArea, specTest.testType).add(testInfoForRelevantLink)
|
||||
}
|
||||
}
|
||||
|
||||
private fun collectInfoFromTestsTemp( //todo add same for implementation tests
|
||||
testsMap: JsonObject,
|
||||
specTest: LinkedSpecTest,
|
||||
testInfoForMainLink: JsonObject,
|
||||
testInfoForPrimaryLink: JsonObject = testInfoForMainLink,
|
||||
testInfoForSecondaryLink: JsonObject = testInfoForMainLink
|
||||
) {
|
||||
testsMap.getOrCreateSpecTestObject(specTest.place, specTest.testArea, specTest.testType).add(testInfoForMainLink)
|
||||
specTest.primaryLinks?.forEach {
|
||||
testsMap.getOrCreateSpecTestObject(it, specTest.testArea, specTest.testType).add(testInfoForPrimaryLink)
|
||||
}
|
||||
specTest.secondaryLinks?.forEach {
|
||||
testsMap.getOrCreateSpecTestObject(it, specTest.testArea, specTest.testType).add(testInfoForSecondaryLink)
|
||||
}
|
||||
}
|
||||
|
||||
fun buildTestsMapPerSection() {
|
||||
|
||||
@@ -41,7 +41,8 @@ class LinkedSpecTest(
|
||||
testArea: TestArea,
|
||||
testType: TestType,
|
||||
val place: SpecPlace,
|
||||
val relevantPlaces: Set<SpecPlace>?,
|
||||
val primaryLinks: Set<SpecPlace>?,
|
||||
val secondaryLinks: Set<SpecPlace>?,
|
||||
testNumber: Int,
|
||||
description: String,
|
||||
cases: SpecTestCasesSet,
|
||||
@@ -80,7 +81,8 @@ class LinkedSpecTest(
|
||||
append("${testArea.name.withSpaces()} $testType SPEC TEST (${testType.toString().withSpaces()})$ls")
|
||||
append("SPEC VERSION: $specVersion$ls")
|
||||
append("SPEC PLACE: ${sections.joinToString()} -> paragraph: ${place.paragraphNumber} -> sentence: ${place.sentenceNumber}$ls")
|
||||
relevantPlaces?.let { append("OTHER RELEVANT SPEC PLACES:${it.joinToString { "$ls\t${sections.joinToString()} -> paragraph: ${place.paragraphNumber} -> sentence: ${place.sentenceNumber}" }}$ls") }
|
||||
primaryLinks?.let { append("PRIMARY LINKS:${it.joinToString { "$ls\t${sections.joinToString()} -> paragraph: ${place.paragraphNumber} -> sentence: ${place.sentenceNumber}" }}$ls") }
|
||||
secondaryLinks?.let { append("SECONDARY LINKS:${it.joinToString { "$ls\t${sections.joinToString()} -> paragraph: ${place.paragraphNumber} -> sentence: ${place.sentenceNumber}" }}$ls") }
|
||||
append("NUMBER: $testNumber$ls")
|
||||
append("TEST CASES: ${cases.byNumbers.size.coerceAtLeast(1)}$ls")
|
||||
append("DESCRIPTION: $description$ls")
|
||||
|
||||
@@ -69,19 +69,20 @@ object CommonParser {
|
||||
}
|
||||
|
||||
fun parseLinkedSpecTest(testFilePath: String, testFiles: TestFiles, isImplementationTest: Boolean = false): LinkedSpecTest {
|
||||
val relevantPlaces = mutableSetOf<SpecPlace>()
|
||||
val primaryLinks = mutableSetOf<SpecPlace>()
|
||||
val secondaryLinks = mutableSetOf<SpecPlace>()
|
||||
val parsedTestFile = tryParseTestInfo(testFilePath, testFiles, SpecTestLinkedType.LINKED, isImplementationTest)
|
||||
|
||||
val testInfoElements = parsedTestFile.testInfoElements
|
||||
|
||||
parseRelevantPlaces(
|
||||
testInfoElements[LinkedSpecTestFileInfoElementType.PRIMARY_LINKS]?.additionalMatcher,
|
||||
relevantPlaces
|
||||
primaryLinks
|
||||
)
|
||||
|
||||
parseRelevantPlaces(
|
||||
testInfoElements[LinkedSpecTestFileInfoElementType.SECONDARY_LINKS]?.additionalMatcher,
|
||||
relevantPlaces
|
||||
secondaryLinks
|
||||
)
|
||||
|
||||
val placeMatcher = testInfoElements[LinkedSpecTestFileInfoElementType.MAIN_LINK]?.additionalMatcher
|
||||
@@ -90,15 +91,16 @@ object CommonParser {
|
||||
if (placeMatcher != null) {
|
||||
mainPlace = createSpecPlace(placeMatcher)
|
||||
} else {
|
||||
mainPlace = relevantPlaces.first()
|
||||
relevantPlaces.remove(mainPlace)
|
||||
mainPlace = primaryLinks.first()
|
||||
primaryLinks.remove(mainPlace)
|
||||
}
|
||||
return LinkedSpecTest(
|
||||
testInfoElements[LinkedSpecTestFileInfoElementType.SPEC_VERSION]!!.content,
|
||||
parsedTestFile.testArea,
|
||||
parsedTestFile.testType,
|
||||
mainPlace,
|
||||
relevantPlaces,
|
||||
primaryLinks,
|
||||
secondaryLinks,
|
||||
parsedTestFile.testNumber,
|
||||
parsedTestFile.testDescription,
|
||||
parsedTestFile.testCasesSet,
|
||||
|
||||
Reference in New Issue
Block a user