Fix Windows targets has bad addresses in stacktrace
^KT-49240 Fixed Merge-request: KT-MR-6883 Merged-by: Vladimir Sukharev <Vladimir.Sukharev@jetbrains.com>
This commit is contained in:
+41
@@ -0,0 +1,41 @@
|
||||
import kotlin.text.Regex
|
||||
import kotlin.test.*
|
||||
|
||||
var inlinesCount = 0
|
||||
|
||||
fun exception() {
|
||||
error("FAIL!")
|
||||
}
|
||||
|
||||
fun main() {
|
||||
try {
|
||||
exception()
|
||||
}
|
||||
catch (e:Exception) {
|
||||
val stackTrace = e.getStackTrace().filter { "kfun:" in it }
|
||||
println("Kotlin part of call stack is:")
|
||||
for (entry in stackTrace)
|
||||
println(entry)
|
||||
println("Verifying...")
|
||||
val goldValues = arrayOf(
|
||||
"kfun:kotlin.Throwable#<init>(kotlin.String?){}",
|
||||
"kfun:kotlin.Exception#<init>(kotlin.String?){}",
|
||||
"kfun:kotlin.RuntimeException#<init>(kotlin.String?){}",
|
||||
"kfun:kotlin.IllegalStateException#<init>(kotlin.String?){}",
|
||||
"kfun:#exception(){}",
|
||||
"kfun:#main(){}",
|
||||
)
|
||||
assertEquals(goldValues.size, stackTrace.size)
|
||||
goldValues.zip(stackTrace).forEach { checkFrame(it.first, it.second) }
|
||||
println("Passed")
|
||||
}
|
||||
}
|
||||
|
||||
internal val regex = Regex("(kfun.+) \\+ (\\d+)")
|
||||
internal fun checkFrame(goldFunName: String, actualLine: String) {
|
||||
val findResult = regex.find(actualLine)
|
||||
|
||||
val (funName, offset) = findResult?.destructured ?: throw Error("Cannot find '$goldFunName + <int>' in $actualLine")
|
||||
assertEquals(goldFunName, funName)
|
||||
assertTrue(offset.toInt() > 0)
|
||||
}
|
||||
Reference in New Issue
Block a user