[FIR-TEST] Add identity checker of old frontend and fir testdata to old FE diagnostics tests
This commit is contained in:
-8
@@ -11,14 +11,6 @@ import org.jetbrains.kotlin.test.KotlinTestUtils
|
||||
import java.io.File
|
||||
|
||||
abstract class AbstractFirOldFrontendDiagnosticsTest : AbstractFirDiagnosticsTest() {
|
||||
companion object {
|
||||
private val DIAGNOSTIC_PATTERN = Regex("(<!>|(<!(.(\".*\")*?)+?!>))")
|
||||
|
||||
private fun loadTestDataWithoutDiagnostics(file: File): String {
|
||||
return KotlinTestUtils.doLoadFile(file).replace(DIAGNOSTIC_PATTERN, "")
|
||||
}
|
||||
}
|
||||
|
||||
override fun createTestFileFromPath(filePath: String): File {
|
||||
val newPath = filePath.replace(".kt", ".fir.kt")
|
||||
return File(newPath).also {
|
||||
|
||||
@@ -214,6 +214,16 @@ abstract class AbstractDiagnosticsTest : BaseDiagnosticsTest() {
|
||||
performAdditionalChecksAfterDiagnostics(
|
||||
testDataFile, files, groupedByModule, modules, moduleBindings, languageVersionSettingsByModule
|
||||
)
|
||||
checkOriginalAndFirTestdataIdentity(testDataFile)
|
||||
}
|
||||
|
||||
private fun checkOriginalAndFirTestdataIdentity(testDataFile: File) {
|
||||
val firTestDataFile = File(testDataFile.absolutePath.replace(".kt", ".fir.kt"))
|
||||
if (!firTestDataFile.exists()) return
|
||||
val originalTestData = loadTestDataWithoutDiagnostics(testDataFile)
|
||||
val firTestData = loadTestDataWithoutDiagnostics(firTestDataFile)
|
||||
val message = "Original and fir test data doesn't identical. Please, add changes from ${testDataFile.name} to ${firTestDataFile.name}"
|
||||
TestCase.assertEquals(message, originalTestData, firTestData)
|
||||
}
|
||||
|
||||
private fun StringBuilder.cleanupInferenceDiagnostics(): String = replace(Regex("NI;([\\S]*), OI;\\1([,!])")) { it.groupValues[1] + it.groupValues[2] }
|
||||
|
||||
@@ -475,6 +475,12 @@ abstract class BaseDiagnosticsTest : KotlinMultiFileTestWithJava<TestModule, Tes
|
||||
Condition { diagnostic -> diagnostic.factory in DIAGNOSTICS_TO_INCLUDE_ANYWAY }
|
||||
)
|
||||
}
|
||||
|
||||
private val DIAGNOSTIC_IN_TESTDATA_PATTERN = Regex("(<!>|(<!(.(\".*\")*?)+?!>))")
|
||||
|
||||
fun loadTestDataWithoutDiagnostics(file: File): String {
|
||||
return KotlinTestUtils.doLoadFile(file).replace(DIAGNOSTIC_IN_TESTDATA_PATTERN, "")
|
||||
}
|
||||
}
|
||||
|
||||
private fun parseJvmTarget(directiveMap: Map<String, String>) = directiveMap[JVM_TARGET]?.let { JvmTarget.fromString(it) }
|
||||
|
||||
Reference in New Issue
Block a user