Skip to content

Commit 12b8e4f

Browse files
Vassiliy-Kudryashovtamarinvs19
authored andcommitted
Stacktraces in comments should be escaped #609 (#638)
1 parent f76bf03 commit 12b8e4f

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

utbot-framework/src/main/kotlin/org/utbot/framework/codegen/model/constructor/tree/CgMethodConstructor.kt

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package org.utbot.framework.codegen.model.constructor.tree
22

33
import org.utbot.common.PathUtil
4-
import org.utbot.common.packageName
54
import org.utbot.framework.assemble.assemble
65
import org.utbot.framework.codegen.ForceStaticMocking
76
import org.utbot.framework.codegen.Junit4
@@ -379,7 +378,7 @@ internal class CgMethodConstructor(val context: CgContext) : CgContextOwner by c
379378
val executableName = "${currentExecutable!!.classId.name}.${currentExecutable!!.name}"
380379

381380
val warningLine = mutableListOf(
382-
"This test fails because method [$executableName] produces [$exception]"
381+
"This test fails because method [$executableName] produces [$exception]".escapeControlChars()
383382
)
384383

385384
val neededStackTraceLines = mutableListOf<String>()
@@ -397,6 +396,10 @@ internal class CgMethodConstructor(val context: CgContext) : CgContextOwner by c
397396
+CgMultilineComment(warningLine + neededStackTraceLines.reversed())
398397
}
399398

399+
private fun String.escapeControlChars() : String {
400+
return this.replace("\b", "\\b").replace("\n", "\\n").replace("\t", "\\t").replace("\r", "\\r")
401+
}
402+
400403
private fun writeWarningAboutCrash() {
401404
+CgSingleLineComment("This invocation possibly crashes JVM")
402405
}

0 commit comments

Comments
 (0)