[Test] Don't generate new files in GeneratorsFileUtil in teamcity mode
This commit is contained in:
@@ -11,6 +11,8 @@ import java.io.IOException
|
||||
import kotlin.io.path.*
|
||||
|
||||
object GeneratorsFileUtil {
|
||||
private val isTeamCityBuild: Boolean = System.getProperty("TEAMCITY_VERSION") != null
|
||||
|
||||
@OptIn(ExperimentalPathApi::class)
|
||||
@JvmStatic
|
||||
@JvmOverloads
|
||||
@@ -18,6 +20,7 @@ object GeneratorsFileUtil {
|
||||
fun writeFileIfContentChanged(file: File, newText: String, logNotChanged: Boolean = true) {
|
||||
val parentFile = file.parentFile
|
||||
if (!parentFile.exists()) {
|
||||
if (isTeamCityBuild) assertTeamCityMode()
|
||||
if (parentFile.mkdirs()) {
|
||||
println("Directory created: " + parentFile.absolutePath)
|
||||
} else {
|
||||
@@ -30,6 +33,7 @@ object GeneratorsFileUtil {
|
||||
}
|
||||
return
|
||||
}
|
||||
if (isTeamCityBuild) assertTeamCityMode()
|
||||
val useTempFile = !SystemInfo.isWindows
|
||||
val targetFile = file.toPath()
|
||||
val tempFile =
|
||||
@@ -43,6 +47,10 @@ object GeneratorsFileUtil {
|
||||
println()
|
||||
}
|
||||
|
||||
private fun assertTeamCityMode(): Nothing {
|
||||
throw IllegalStateException("You should commit all newly generated files before pushing them to TeamCity")
|
||||
}
|
||||
|
||||
fun isFileContentChangedIgnoringLineSeparators(file: File, content: String): Boolean {
|
||||
val currentContent: String = try {
|
||||
StringUtil.convertLineSeparators(file.readText(Charsets.UTF_8))
|
||||
@@ -51,4 +59,4 @@ object GeneratorsFileUtil {
|
||||
}
|
||||
return StringUtil.convertLineSeparators(content) != currentContent
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user