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
|
@JvmStatic
|
||||||
@JvmOverloads
|
@JvmOverloads
|
||||||
@Throws(IOException::class)
|
@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
|
val parentFile = file.parentFile
|
||||||
if (!parentFile.exists()) {
|
if (!parentFile.exists()) {
|
||||||
if (failOnTeamCity("Create dir `${parentFile.path}`")) return
|
if (forbidGenerationOnTeamcity) {
|
||||||
|
if (failOnTeamCity("Create dir `${parentFile.path}`")) return
|
||||||
|
}
|
||||||
if (parentFile.mkdirs()) {
|
if (parentFile.mkdirs()) {
|
||||||
println("Directory created: " + parentFile.absolutePath)
|
println("Directory created: " + parentFile.absolutePath)
|
||||||
} else {
|
} else {
|
||||||
@@ -33,7 +35,9 @@ object GeneratorsFileUtil {
|
|||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (failOnTeamCity("Write file `${file.toPath()}`")) return
|
if (forbidGenerationOnTeamcity) {
|
||||||
|
if (failOnTeamCity("Write file `${file.toPath()}`")) return
|
||||||
|
}
|
||||||
val useTempFile = !SystemInfo.isWindows
|
val useTempFile = !SystemInfo.isWindows
|
||||||
val targetFile = file.toPath()
|
val targetFile = file.toPath()
|
||||||
val tempFile =
|
val tempFile =
|
||||||
|
|||||||
+3
-2
@@ -38,8 +38,9 @@ class GenerateProtoBufCompare {
|
|||||||
generate(DEST_FILE)
|
generate(DEST_FILE)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun generate(destFile: File) {
|
fun generate(destFile: File, forbidGenerationOnTeamcity: Boolean = true) {
|
||||||
GeneratorsFileUtil.writeFileIfContentChanged(destFile, GenerateProtoBufCompare().generate())
|
GeneratorsFileUtil.writeFileIfContentChanged(destFile, GenerateProtoBufCompare().generate(),
|
||||||
|
forbidGenerationOnTeamcity = forbidGenerationOnTeamcity)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -26,7 +26,7 @@ class ProtoBufCompareConsistencyTest : TestCase() {
|
|||||||
fun testAlreadyGenerated() {
|
fun testAlreadyGenerated() {
|
||||||
val testDir = KtTestUtil.tmpDir("testDirectory")
|
val testDir = KtTestUtil.tmpDir("testDirectory")
|
||||||
val newFile = File(testDir, "ProtoCompareGenerated.kt")
|
val newFile = File(testDir, "ProtoCompareGenerated.kt")
|
||||||
GenerateProtoBufCompare.generate(newFile)
|
GenerateProtoBufCompare.generate(newFile, forbidGenerationOnTeamcity = false)
|
||||||
|
|
||||||
KotlinTestUtils.assertEqualsToFile(newFile, FileUtil.loadFile(GenerateProtoBufCompare.DEST_FILE))
|
KotlinTestUtils.assertEqualsToFile(newFile, FileUtil.loadFile(GenerateProtoBufCompare.DEST_FILE))
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user