[K/N] Support stacktrace using libbacktrace
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
import kotlin.text.Regex
|
||||
import kotlin.test.*
|
||||
|
||||
var inlinesCount = 0
|
||||
|
||||
fun exception() {
|
||||
error("FAIL!")
|
||||
}
|
||||
@@ -11,20 +13,23 @@ fun main() {
|
||||
}
|
||||
catch (e:Exception) {
|
||||
val stackTrace = e.getStackTrace()
|
||||
inlinesCount = stackTrace.count { it.contains("[inlined]")}
|
||||
stackTrace.take(6).forEach(::checkFrame)
|
||||
}
|
||||
println(inlinesCount)
|
||||
}
|
||||
internal val regex = Regex("^(\\d+)\\ +.*/(.*):(\\d+):.*$")
|
||||
internal val goldValues = arrayOf<Pair<String, Int>?>(
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
"stack_trace_inline.kt" to 5,
|
||||
"stack_trace_inline.kt" to 10)
|
||||
internal fun checkFrame(value:String) {
|
||||
val goldValues = arrayOf<Pair<String, Int>?>(
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
*(if (inlinesCount != 0) arrayOf(null) else emptyArray()),
|
||||
"stack_trace_inline.kt" to 7,
|
||||
"stack_trace_inline.kt" to 12)
|
||||
val (pos, file, line) = regex.find(value)!!.destructured
|
||||
goldValues[pos.toInt()]?.let{
|
||||
goldValues[pos.toInt()]?.let {
|
||||
assertEquals(it.first, file)
|
||||
assertEquals(it.second, line.toInt())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user