JetBrains-Research / reflekt

A plugin for Kotlin compiler for compile-time reflection
Apache License 2.0
363 stars 11 forks source link

Test failures due to mismatched line endings, `\r\n` vs `\n` #100

Closed aSemy closed 2 years ago

aSemy commented 2 years ago

I've checked out master and when I run the tests I get failures due to mismatched line endings.

image

"Contents have differences only in line separators".

I've tried implementing a function to normalize the line endings to \n

/**
 * Read all lines in a file, with line-endings normalized to `\n`. The result is [trim]-ed.
 *
 * This helps ensure consistent test results across Windows and Unix platforms.
 */
fun File.readTextNormalized(): String = useLines(Charsets.UTF_8) { it.joinToString("\n").trim() }

However this doesn't resolve the issue, and for some reason the 'actual' isn't loaded correctly

image


I see that in .editorconfig the line endings are specified as lf, but because there's no .gitattributes file, very few of the files are formatted as lf.

The fix is probably to add .gitattributes and reformat all files to have lf endings.

elena-lyulina commented 2 years ago

Yes, you're right, thanks for noticing it I'll check your PR and close the issue after merging we really appreciate your help :)