From 75d57c7d3f102f348b04b7c731052025efd2eeec Mon Sep 17 00:00:00 2001 From: Pavel Kirpichenkov Date: Mon, 3 Feb 2020 20:29:28 +0300 Subject: [PATCH] Update pattern for finding diagnostics in diagnostic tests Also use updated diagnostic pattern in TreesCompareTest. In rare cases diagnostic was cut too early on !> characters, that were a part of diagnostic parameter: ")!> --- .../kotlin/fir/lightTree/compare/TreesCompareTest.kt | 3 ++- .../tests/inference/completion/definetlyNotNullType.kt | 8 ++++---- .../platformTypes/rawTypes/nonGenericRawMember.fir.kt | 2 +- .../org/jetbrains/kotlin/checkers/BaseDiagnosticsTest.kt | 4 ++-- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/compiler/fir/lightTree/tests/org/jetbrains/kotlin/fir/lightTree/compare/TreesCompareTest.kt b/compiler/fir/lightTree/tests/org/jetbrains/kotlin/fir/lightTree/compare/TreesCompareTest.kt index c23101bda4f..bd55d42030b 100644 --- a/compiler/fir/lightTree/tests/org/jetbrains/kotlin/fir/lightTree/compare/TreesCompareTest.kt +++ b/compiler/fir/lightTree/tests/org/jetbrains/kotlin/fir/lightTree/compare/TreesCompareTest.kt @@ -10,6 +10,7 @@ import com.intellij.openapi.vfs.CharsetToolkit import com.intellij.testFramework.TestDataPath import com.intellij.util.PathUtil import junit.framework.TestCase +import org.jetbrains.kotlin.checkers.BaseDiagnosticsTest.Companion.DIAGNOSTIC_IN_TESTDATA_PATTERN import org.jetbrains.kotlin.fir.FirRenderer import org.jetbrains.kotlin.fir.builder.AbstractRawFirBuilderTestCase import org.jetbrains.kotlin.fir.builder.StubFirScopeProvider @@ -77,7 +78,7 @@ class TreesCompareTest : AbstractRawFirBuilderTestCase() { return@compareBase true } val notEditedText = FileUtil.loadFile(file, CharsetToolkit.UTF8, true).trim() - val text = notEditedText.replace("()|()".toRegex(), "").replaceAfter(".java", "") + val text = notEditedText.replace(DIAGNOSTIC_IN_TESTDATA_PATTERN, "").replaceAfter(".java", "") //psi val ktFile = createPsiFile(FileUtil.getNameWithoutExtension(PathUtil.getFileName(file.path)), text) as KtFile diff --git a/compiler/testData/diagnostics/tests/inference/completion/definetlyNotNullType.kt b/compiler/testData/diagnostics/tests/inference/completion/definetlyNotNullType.kt index 589fcb9da92..57f61fb04bc 100644 --- a/compiler/testData/diagnostics/tests/inference/completion/definetlyNotNullType.kt +++ b/compiler/testData/diagnostics/tests/inference/completion/definetlyNotNullType.kt @@ -3,9 +3,9 @@ fun test(derived: T) { ")!>id>( - makeOut( + ")!>makeOut( makeDnn(derived) - ) + ) ) ")!>id>( ")!>makeIn( @@ -18,9 +18,9 @@ fun test(derived: T) { ) ) >")!>id>>( - makeInIn( + >")!>makeInIn( makeDnn(derived) - ) + ) ) } diff --git a/compiler/testData/diagnostics/tests/platformTypes/rawTypes/nonGenericRawMember.fir.kt b/compiler/testData/diagnostics/tests/platformTypes/rawTypes/nonGenericRawMember.fir.kt index 824d6553cd5..ef3a7846b4c 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/rawTypes/nonGenericRawMember.fir.kt +++ b/compiler/testData/diagnostics/tests/platformTypes/rawTypes/nonGenericRawMember.fir.kt @@ -30,5 +30,5 @@ val strList: List = null!! fun main() { val rawB = Test.rawAField.b; // Raw(A).b is not erased because it have no type parameters - var rawInner = rawB.bar(!", "List<String>")!>strList) + var rawInner = rawB.bar(strList) } diff --git a/compiler/tests-common/tests/org/jetbrains/kotlin/checkers/BaseDiagnosticsTest.kt b/compiler/tests-common/tests/org/jetbrains/kotlin/checkers/BaseDiagnosticsTest.kt index 9845d417626..a2d01dfcca2 100644 --- a/compiler/tests-common/tests/org/jetbrains/kotlin/checkers/BaseDiagnosticsTest.kt +++ b/compiler/tests-common/tests/org/jetbrains/kotlin/checkers/BaseDiagnosticsTest.kt @@ -406,6 +406,8 @@ abstract class BaseDiagnosticsTest : KotlinMultiFileTestWithJava|") + fun parseDiagnosticFilterDirective( directiveMap: Map, allowUnderscoreUsage: Boolean @@ -477,8 +479,6 @@ abstract class BaseDiagnosticsTest : KotlinMultiFileTestWithJava|())") - fun loadTestDataWithoutDiagnostics(file: File): String { val textWithoutDiagnostics = KotlinTestUtils.doLoadFile(file).replace(DIAGNOSTIC_IN_TESTDATA_PATTERN, "") return StringUtil.convertLineSeparators(textWithoutDiagnostics.trim()).trimTrailingWhitespacesAndAddNewlineAtEOF()