From 8c51c3c5c38582951da2fd611d7c09f25145a5bb Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Tue, 10 Aug 2021 10:06:26 +0300 Subject: [PATCH] FirTestDataConsistencyHandler: fix behavior on Windows (partial revert) --- .../handlers/FirTestDataConsistencyHandler.kt | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/frontend/classic/handlers/FirTestDataConsistencyHandler.kt b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/frontend/classic/handlers/FirTestDataConsistencyHandler.kt index 08ddc3a2259..46fb76e935b 100644 --- a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/frontend/classic/handlers/FirTestDataConsistencyHandler.kt +++ b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/frontend/classic/handlers/FirTestDataConsistencyHandler.kt @@ -29,14 +29,22 @@ class FirTestDataConsistencyHandler(testServices: TestServices) : AfterAnalysisC testServices.assertions.assertTrue(firTestData.exists()) { "FIR test data does not exist; run the corresponding FIR test to generate it" } - testServices.assertions.assertEquals(firTestData.preprocessSource(), testData.preprocessSource()) { - "Original and fir test data aren't identical. " + + val firPreprocessedTextData = firTestData.preprocessSource() + val originalPreprocessedTextData = testData.preprocessSource() + testServices.assertions.assertEquals(firPreprocessedTextData, originalPreprocessedTextData) { + "Original and FIR test data aren't identical. " + "Please, add changes from ${testData.name} to ${firTestData.name}" } } - private fun File.preprocessSource(): String = - testServices.sourceFileProvider.getContentOfSourceFile( - TestFile(path, readText().trim().convertLineSeparators(), this, 0, isAdditional = false, RegisteredDirectives.Empty) + private fun File.preprocessSource(): String { + val content = testServices.sourceFileProvider.getContentOfSourceFile( + TestFile(path, readText().trim(), this, 0, isAdditional = false, RegisteredDirectives.Empty) ) + // Note: convertSeparators() does not work on Windows properly (\r\n are left intact for some reason) + if (System.lineSeparator() != "\n") { + return content.replace("\r\n", "\n") + } + return content + } }