[Test] Don't change testdata in FirIdenticalChecker in teamcity mode
This commit is contained in:
+20
-6
@@ -11,6 +11,10 @@ import org.jetbrains.kotlin.test.services.assertions
|
|||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
abstract class FirIdenticalCheckerHelper(private val testServices: TestServices) {
|
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 getClassicFileToCompare(testDataFile: File): File?
|
||||||
abstract fun getFirFileToCompare(testDataFile: File): File?
|
abstract fun getFirFileToCompare(testDataFile: File): File?
|
||||||
|
|
||||||
@@ -35,21 +39,31 @@ abstract class FirIdenticalCheckerHelper(private val testServices: TestServices)
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun addDirectiveToClassicFileAndAssert(testDataFile: File) {
|
fun addDirectiveToClassicFileAndAssert(testDataFile: File) {
|
||||||
val classicFileContent = testDataFile.readText()
|
if (!isTeamCityBuild) {
|
||||||
testDataFile.writer().use {
|
val classicFileContent = testDataFile.readText()
|
||||||
it.appendLine("// ${FirDiagnosticsDirectives.FIR_IDENTICAL.name}")
|
testDataFile.writer().use {
|
||||||
it.append(classicFileContent)
|
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 {
|
testServices.assertions.fail {
|
||||||
"""
|
"""
|
||||||
Dumps via FIR & via old FE are the same.
|
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
|
Please re-run the test now
|
||||||
""".trimIndent()
|
""".trimIndent()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun deleteFirFile(testDataFile: File) {
|
fun deleteFirFile(testDataFile: File) {
|
||||||
getFirFileToCompare(testDataFile)?.takeIf { it.exists() }?.delete()
|
if (!isTeamCityBuild) {
|
||||||
|
getFirFileToCompare(testDataFile)?.takeIf { it.exists() }?.delete()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user