mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-03-10 08:31:29 +00:00
Allow ProtoBufCompareConsistencyTest to work on teamcity
This commit is contained in:
committed by
TeamCityServer
parent
14ead33db6
commit
7d78e610b1
@@ -17,10 +17,12 @@ object GeneratorsFileUtil {
|
||||
@JvmStatic
|
||||
@JvmOverloads
|
||||
@Throws(IOException::class)
|
||||
fun writeFileIfContentChanged(file: File, newText: String, logNotChanged: Boolean = true) {
|
||||
fun writeFileIfContentChanged(file: File, newText: String, logNotChanged: Boolean = true, forbidGenerationOnTeamcity: Boolean = true) {
|
||||
val parentFile = file.parentFile
|
||||
if (!parentFile.exists()) {
|
||||
if (failOnTeamCity("Create dir `${parentFile.path}`")) return
|
||||
if (forbidGenerationOnTeamcity) {
|
||||
if (failOnTeamCity("Create dir `${parentFile.path}`")) return
|
||||
}
|
||||
if (parentFile.mkdirs()) {
|
||||
println("Directory created: " + parentFile.absolutePath)
|
||||
} else {
|
||||
@@ -33,7 +35,9 @@ object GeneratorsFileUtil {
|
||||
}
|
||||
return
|
||||
}
|
||||
if (failOnTeamCity("Write file `${file.toPath()}`")) return
|
||||
if (forbidGenerationOnTeamcity) {
|
||||
if (failOnTeamCity("Write file `${file.toPath()}`")) return
|
||||
}
|
||||
val useTempFile = !SystemInfo.isWindows
|
||||
val targetFile = file.toPath()
|
||||
val tempFile =
|
||||
|
||||
@@ -38,8 +38,9 @@ class GenerateProtoBufCompare {
|
||||
generate(DEST_FILE)
|
||||
}
|
||||
|
||||
fun generate(destFile: File) {
|
||||
GeneratorsFileUtil.writeFileIfContentChanged(destFile, GenerateProtoBufCompare().generate())
|
||||
fun generate(destFile: File, forbidGenerationOnTeamcity: Boolean = true) {
|
||||
GeneratorsFileUtil.writeFileIfContentChanged(destFile, GenerateProtoBufCompare().generate(),
|
||||
forbidGenerationOnTeamcity = forbidGenerationOnTeamcity)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ class ProtoBufCompareConsistencyTest : TestCase() {
|
||||
fun testAlreadyGenerated() {
|
||||
val testDir = KtTestUtil.tmpDir("testDirectory")
|
||||
val newFile = File(testDir, "ProtoCompareGenerated.kt")
|
||||
GenerateProtoBufCompare.generate(newFile)
|
||||
GenerateProtoBufCompare.generate(newFile, forbidGenerationOnTeamcity = false)
|
||||
|
||||
KotlinTestUtils.assertEqualsToFile(newFile, FileUtil.loadFile(GenerateProtoBufCompare.DEST_FILE))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user