[test][stacktrace][mac] added two test for stack trace validation
This commit is contained in:
@@ -2325,6 +2325,18 @@ standaloneTest("check_stacktrace_format") {
|
|||||||
source = "runtime/exceptions/check_stacktrace_format.kt"
|
source = "runtime/exceptions/check_stacktrace_format.kt"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
standaloneTest("stack_trace_inline") {
|
||||||
|
disabled = !isAppleTarget(project) || project.globalTestArgs.contains('-opt') || (project.testTarget == 'ios_arm64')
|
||||||
|
flags = ['-g']
|
||||||
|
source = "runtime/exceptions/stack_trace_inline.kt"
|
||||||
|
}
|
||||||
|
|
||||||
|
standaloneTest("kt-37572") {
|
||||||
|
disabled = !isAppleTarget(project) || project.globalTestArgs.contains('-opt') || (project.testTarget == 'ios_arm64')
|
||||||
|
flags = ['-g']
|
||||||
|
source = "runtime/exceptions/kt-37572.kt"
|
||||||
|
}
|
||||||
|
|
||||||
standaloneTest("custom_hook") {
|
standaloneTest("custom_hook") {
|
||||||
enabled = (project.testTarget != 'wasm32') // Uses exceptions.
|
enabled = (project.testTarget != 'wasm32') // Uses exceptions.
|
||||||
goldValue = "value 42: Error\n"
|
goldValue = "value 42: Error\n"
|
||||||
|
|||||||
@@ -0,0 +1,42 @@
|
|||||||
|
import kotlin.text.Regex
|
||||||
|
import kotlin.test.*
|
||||||
|
|
||||||
|
fun main() {
|
||||||
|
try {
|
||||||
|
foo()
|
||||||
|
} catch (tw:Throwable) {
|
||||||
|
val stackTrace = tw.getStackTrace()
|
||||||
|
stackTrace.take(6).forEach(::checkFrame)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun foo() {
|
||||||
|
myRun {
|
||||||
|
//platform.darwin.NSObject()
|
||||||
|
throwException()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
inline fun myRun(block: () -> Unit) {
|
||||||
|
block()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun throwException() {
|
||||||
|
throw Error()
|
||||||
|
}
|
||||||
|
internal val regex = Regex("^(\\d+)\\ +.*/(.*):(\\d+):.*$")
|
||||||
|
internal val goldValues = arrayOf<Pair<String, Int>?>(
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
"kt-37572.kt" to 25,
|
||||||
|
"kt-37572.kt" to 16,
|
||||||
|
"kt-37572.kt" to 6,
|
||||||
|
"kt-37572.kt" to 4)
|
||||||
|
|
||||||
|
internal fun checkFrame(value:String) {
|
||||||
|
val (pos, file, line) = regex.find(value)!!.destructured
|
||||||
|
goldValues[pos.toInt()]?.let{
|
||||||
|
assertEquals(it.first, file)
|
||||||
|
assertEquals(it.second, line.toInt())
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
import kotlin.text.Regex
|
||||||
|
import kotlin.test.*
|
||||||
|
|
||||||
|
fun exception() {
|
||||||
|
error("FAIL!")
|
||||||
|
}
|
||||||
|
|
||||||
|
fun main() {
|
||||||
|
try {
|
||||||
|
exception()
|
||||||
|
}
|
||||||
|
catch (e:Exception) {
|
||||||
|
val stackTrace = e.getStackTrace()
|
||||||
|
stackTrace.take(6).forEach(::checkFrame)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
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 (pos, file, line) = regex.find(value)!!.destructured
|
||||||
|
goldValues[pos.toInt()]?.let{
|
||||||
|
assertEquals(it.first, file)
|
||||||
|
assertEquals(it.second, line.toInt())
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user