Diagnostic test: make messages about FIR_IDENTICAL inconsistency clearer

This commit is contained in:
Mikhail Glukhikh
2020-03-05 08:36:13 +03:00
parent 737c91c5cf
commit db38dfc21b
2 changed files with 14 additions and 2 deletions
@@ -9,6 +9,7 @@ import com.intellij.openapi.util.io.FileUtil
import com.intellij.openapi.util.text.StringUtil import com.intellij.openapi.util.text.StringUtil
import com.intellij.psi.PsiElement import com.intellij.psi.PsiElement
import com.intellij.psi.search.GlobalSearchScope import com.intellij.psi.search.GlobalSearchScope
import com.intellij.rt.execution.junit.FileComparisonFailure
import junit.framework.AssertionFailedError import junit.framework.AssertionFailedError
import junit.framework.TestCase import junit.framework.TestCase
import org.jetbrains.kotlin.TestsCompilerError import org.jetbrains.kotlin.TestsCompilerError
@@ -281,7 +282,16 @@ abstract class AbstractDiagnosticsTest : BaseDiagnosticsTest() {
} }
} }
if (testDataFile.readText().contains("// FIR_IDENTICAL")) { if (testDataFile.readText().contains("// FIR_IDENTICAL")) {
testRunner.analyzeAndCheckUnhandled(testDataFile, files) try {
testRunner.analyzeAndCheckUnhandled(testDataFile, files)
} catch (e: FileComparisonFailure) {
println("Old FE & FIR produces different diagnostics for this file. Please remove FIR_IDENTICAL line manually")
throw FileComparisonFailure(
"Old FE & FIR produces different diagnostics for this file. Please remove FIR_IDENTICAL line manually\n" +
e.message,
e.expected, e.actual, e.filePath, e.actualFilePath
)
}
} else { } else {
FileUtil.copy(testDataFile, firTestDataFile) FileUtil.copy(testDataFile, firTestDataFile)
testRunner.analyzeAndCheckUnhandled(firTestDataFile, files) testRunner.analyzeAndCheckUnhandled(firTestDataFile, files)
@@ -36,7 +36,9 @@ fun compareAndMergeFirFileAndOldFrontendFile(
oldFrontendTestDataFile.writeText("// FIR_IDENTICAL\n" + oldFrontendTestDataFile.readText()) oldFrontendTestDataFile.writeText("// FIR_IDENTICAL\n" + oldFrontendTestDataFile.readText())
} }
TestCase.assertFalse( TestCase.assertFalse(
"Dumps via FIR & via old FE are the same. Deleted .fir.txt dump, added // FIR_IDENTICAL to test source", "Dumps via FIR & via old FE are the same. " +
"\nDeleted .fir.txt dump, added // FIR_IDENTICAL to test source" +
"\nPlease re-run the test now",
sameDumps sameDumps
) )
} }