Skip to content

Commit

Permalink
[Test] Don't change testdata in FirIdenticalChecker in teamcity mode
Browse files Browse the repository at this point in the history
  • Loading branch information
demiurg906 committed Feb 1, 2021
1 parent 6265ac8 commit 772ca27
Showing 1 changed file with 20 additions and 6 deletions.
Expand Up @@ -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?

Expand All @@ -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()
}
}
}

0 comments on commit 772ca27

Please sign in to comment.