JetBrains-Research/reflekt

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

aSemy opened this issue · 1 comments

aSemy commented

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.

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