[Test] Align lines in TestFile with lines in real testdata file

This commit is contained in:
Dmitriy Novozhilov
2021-01-26 09:28:58 +03:00
parent 60e0831c11
commit e3ab3d6be3
2 changed files with 28 additions and 12 deletions
@@ -60,16 +60,26 @@ class GlobalMetadataInfoHandler(
if (file.isAdditional) continue
processors.forEach { it.processMetaInfos(module, file) }
val codeMetaInfos = infosPerFile.getValue(file)
val fileBuilder = StringBuilder()
CodeMetaInfoRenderer.renderTagsToText(
builder,
fileBuilder,
codeMetaInfos,
testServices.sourceFileProvider.getContentOfSourceFile(file)
)
builder.append(fileBuilder.stripAdditionalEmptyLines(file))
}
}
val actualText = builder.toString()
testServices.assertions.assertEqualsToFile(moduleStructure.originalTestDataFiles.single(), actualText)
}
private fun StringBuilder.stripAdditionalEmptyLines(file: TestFile): CharSequence {
return if (file.startLineNumberInOriginalFile != 0) {
this.removePrefix((1..file.startLineNumberInOriginalFile).joinToString(separator = "") { "\n" })
} else {
this.toString()
}
}
}
val TestServices.globalMetadataInfoHandler: GlobalMetadataInfoHandler by TestServices.testServiceAccessor()