Native, Gradle IT: Fix GeneralNativeIT.testNativeArgsWithSpaces()

This commit is contained in:
Dmitriy Dolovov
2020-11-11 14:15:53 +03:00
parent 0fe842c38f
commit bf0156f7c6
2 changed files with 7 additions and 2 deletions
@@ -818,7 +818,8 @@ class GeneralNativeIT : BaseGradleIT() {
build("compileKotlin${nativeHostTargetName.capitalize()}") {
assertSuccessful()
checkNativeCommandLineArguments(":compileKotlin${nativeHostTargetName.capitalize()}") { arguments ->
val escapedQuotedPath = "\"${fileWithSpacesInPath.absolutePath.replace("\"", "\\\"")}\""
val escapedQuotedPath =
"\"${fileWithSpacesInPath.absolutePath.replace("\\", "\\\\").replace("\"", "\\\"")}\""
assertTrue(
escapedQuotedPath in arguments,
"""
@@ -151,6 +151,10 @@ internal abstract class KotlinToolRunner(
}
private fun String.toPrettyString(): String =
if (isEmpty()) "\"\"" else escapeStringCharacters(this).let { if (any(Char::isWhitespace)) "\"$it\"" else it }
when {
isEmpty() -> "\"\""
any { it == '"' || it.isWhitespace() } -> '"' + escapeStringCharacters(this) + '"'
else -> this
}
}
}