[Spec tests] Fix test-info parser for relevant places

This commit is contained in:
anastasiia.spaseeva
2020-03-31 19:46:08 +03:00
parent 9f684bfd65
commit b1dbacf45f
42 changed files with 2676 additions and 72 deletions
@@ -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/exceptions", "linked/overloadable-operators", "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, "exceptions", "overloadable-operators", "overload-resolution/building-the-overload-candidate-set-ocs/call-with-an-explicit-receiver");
}
@TestMetadata("compiler/tests-spec/testData/codegen/box/linked/expressions")
@@ -143,7 +143,15 @@ object CommonParser {
SpecTestValidationFailedReason.TESTINFO_NOT_VALID,
"Unknown '$testInfoOriginalElementName' test info element name."
)
val testInfoElementValue = testInfoElementMatcher.group("value")
val testInfoElementValue: String?
testInfoElementValue = if (testInfoOriginalElementName == "RELEVANT PLACES") {
val relevantPlacesMatcher = LinkedSpecTestPatterns.relevantPlaces.matcher(rawElements)
if (relevantPlacesMatcher.find()) {
relevantPlacesMatcher.group("places")
} else throw Exception("Relevant link is incorrect")
} else {
testInfoElementMatcher.group("value")
}
val testInfoElementValueMatcher = testInfoElementName.valuePattern?.matcher(testInfoElementValue)
if (testInfoElementValueMatcher != null && !testInfoElementValueMatcher.find())
@@ -153,7 +161,7 @@ object CommonParser {
)
testInfoElementsMap[testInfoElementName] =
SpecTestInfoElementContent(testInfoElementValue ?: "", testInfoElementValueMatcher)
SpecTestInfoElementContent(testInfoElementValue ?: "", testInfoElementValueMatcher)
}
rules.forEach {
@@ -9,6 +9,7 @@ import org.jetbrains.kotlin.spec.utils.SpecTestLinkedType
import org.jetbrains.kotlin.spec.utils.TestArea
import org.jetbrains.kotlin.spec.utils.TestType
import org.jetbrains.kotlin.spec.utils.models.SpecTestCaseInfoElementType
import org.jetbrains.kotlin.spec.utils.parsers.CommonParser.withSpaces
import org.jetbrains.kotlin.spec.utils.parsers.CommonPatterns.ASTERISK_REGEX
import org.jetbrains.kotlin.spec.utils.parsers.CommonPatterns.INTEGER_REGEX
import org.jetbrains.kotlin.spec.utils.parsers.CommonPatterns.MULTILINE_COMMENT_REGEX
@@ -18,7 +19,6 @@ import org.jetbrains.kotlin.spec.utils.parsers.CommonPatterns.directiveRegex
import org.jetbrains.kotlin.spec.utils.parsers.CommonPatterns.ps
import org.jetbrains.kotlin.spec.utils.parsers.CommonPatterns.sectionsInPathRegex
import org.jetbrains.kotlin.spec.utils.parsers.CommonPatterns.testAreaRegex
import org.jetbrains.kotlin.spec.utils.parsers.CommonParser.withSpaces
import org.jetbrains.kotlin.spec.utils.parsers.CommonPatterns.testPathRegexTemplate
import org.jetbrains.kotlin.spec.utils.parsers.CommonPatterns.testTypeRegex
import java.io.File
@@ -79,6 +79,11 @@ object LinkedSpecTestPatterns : BasePatterns {
val relevantPlacesPattern: Pattern =
Pattern.compile("""(( $ASTERISK_REGEX )?\s*((?<sections>$SECTIONS_IN_FILE_REGEX) -> )?(paragraph (?<paragraphNumber>$INTEGER_REGEX) -> )?sentence (?<sentenceNumber>$INTEGER_REGEX))+""")
private val relevantPlaceRegex =
Regex("""(( $ASTERISK_REGEX )?\s*($SECTIONS_IN_FILE_REGEX -> )?(paragraph $INTEGER_REGEX -> )?sentence $INTEGER_REGEX)""")
val relevantPlaces: Pattern = Pattern.compile("""RELEVANT PLACES: (?<places>(${relevantPlaceRegex}(\s)*\n)+)""")
}
object TestCasePatterns {