From 772ca2715c74fddeee95e5a9fddd10251c71bb7f Mon Sep 17 00:00:00 2001 From: Dmitriy Novozhilov Date: Fri, 29 Jan 2021 16:24:36 +0300 Subject: [PATCH] [Test] Don't change testdata in FirIdenticalChecker in teamcity mode --- .../test/utils/FirIdenticalCheckerHelper.kt | 26 ++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/utils/FirIdenticalCheckerHelper.kt b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/utils/FirIdenticalCheckerHelper.kt index 7767aa1390b..cc730bdf849 100644 --- a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/utils/FirIdenticalCheckerHelper.kt +++ b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/utils/FirIdenticalCheckerHelper.kt @@ -11,6 +11,10 @@ import org.jetbrains.kotlin.test.services.assertions import java.io.File abstract class FirIdenticalCheckerHelper(private val testServices: TestServices) { + companion object { + private val isTeamCityBuild: Boolean = System.getProperty("TEAMCITY_VERSION") != null + } + abstract fun getClassicFileToCompare(testDataFile: File): File? abstract fun getFirFileToCompare(testDataFile: File): File? @@ -35,21 +39,31 @@ abstract class FirIdenticalCheckerHelper(private val testServices: TestServices) } fun addDirectiveToClassicFileAndAssert(testDataFile: File) { - val classicFileContent = testDataFile.readText() - testDataFile.writer().use { - it.appendLine("// ${FirDiagnosticsDirectives.FIR_IDENTICAL.name}") - it.append(classicFileContent) + if (!isTeamCityBuild) { + val classicFileContent = testDataFile.readText() + testDataFile.writer().use { + it.appendLine("// ${FirDiagnosticsDirectives.FIR_IDENTICAL.name}") + it.append(classicFileContent) + } + } + + val message = if (isTeamCityBuild) { + "Please remove .fir.txt dump and add // FIR_IDENTICAL to test source" + } else { + "Deleted .fir.txt dump, added // FIR_IDENTICAL to test source" } testServices.assertions.fail { """ Dumps via FIR & via old FE are the same. - Deleted .fir.txt dump, added // FIR_IDENTICAL to test source + $message Please re-run the test now """.trimIndent() } } fun deleteFirFile(testDataFile: File) { - getFirFileToCompare(testDataFile)?.takeIf { it.exists() }?.delete() + if (!isTeamCityBuild) { + getFirFileToCompare(testDataFile)?.takeIf { it.exists() }?.delete() + } } }