Dan Rusu
01/13/2023, 11:25 PMline.separator
system property is anything other than \n
. This is because raw / triple-quoted strings are hard-coded to always be compiled with \n
line separators so they can't possibly match output that uses the line.separator
system property.
I didn't find any official documentation about this but found this:
https://stackoverflow.com/questions/48933641/kotlin-add-carriage-return-into-multiline-string#:~:text=Kotlin%20multiline%20strings%20are%20always,separator%22))%20.
and also found that the Kotlin standard library hardcoded \n
in the reindent
function (which is used by the trimIndent
& trimMargin
functions that are used throughout the tests):
https://github.com/JetBrains/kotlin/blob/master/libraries/stdlib/src/kotlin/text/Indent.kt#:~:text=.joinTo(StringBuild[…]eEstimate)%2C%20%22%5Cn%22)
So this brings up 2 issues:
1. The github action to run on windows doesn't seem to represent a regular windows environment. Perhaps something is overwriting the line.separator
system property.
2. Either the EOL
value in DefaultResultWriter
should be set to \n
(which makes the tests pass) or all the tests that assert against multi-line triple-quoted strings need to be fixed.Dan Rusu
01/14/2023, 1:21 AMchristophsturm
01/14/2023, 10:40 AMDan Rusu
01/14/2023, 5:48 PMwindows-latest
image is actually using Linux
.
I added this assertion in a test:
expectThat(System.getProperty("os.name")).startsWith("Windows")
and it failed on the windows-latest
image with this error:
▼ Expect that "Linux":
✗ starts with "Windows"
found "Linux"
Commit:
https://github.com/daniel-rusu/strikt/commit/7478142d725bf635ebe595b92655d8029b09c2da
Task failure on windows-latest
(on line 980):
https://github.com/daniel-rusu/strikt/actions/runs/3919581754/jobs/6700672392Dan Rusu
01/14/2023, 6:05 PMDan Rusu
01/14/2023, 6:30 PMDan Rusu
01/14/2023, 7:01 PMfun String.withSystemLineSeparartors(): String = when (EOL) {
"\n" -> this
else -> replace("\n", EOL)
}
and update all the failing tests to look something like this:
val expectedValue = """
expected first line
expected second line
""".trimIndent().withSystemLineSeparartors()
expectThat(something).isEqualTo(expectedValue)
I'm not sure where that extension function should live. Ideally in a common module that all the other modules depend on but without exposing this function to the end-users of the Strikt library.Dan Rusu
01/18/2023, 7:12 PM\n
line separators on Windows is the expected behavior with raw strings:
https://discuss.kotlinlang.org/t/raw-triple-quoted-strings-dont-preserve-the-line-separator-of-the-system/26213
Once this is merged:
https://github.com/robfletcher/strikt/pull/283
Then I can start fixing the broken tests by appending:
.replace("\n", System.lineSeparator())
on all the raw strings where this appliesrobfletcher
01/18/2023, 7:13 PMDan Rusu
01/20/2023, 6:36 AM