Skip to content

Commit

Permalink
Fix stack trace recovery tests on Kotlin/Native
Browse files Browse the repository at this point in the history
  • Loading branch information
schlaubi authored and schlaubi committed Jan 29, 2024
1 parent f66eb95 commit 2b9e588
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
2 changes: 0 additions & 2 deletions rest/src/commonTest/kotlin/request/StackTraceRecoveryTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package dev.kord.rest.request

import dev.kord.rest.json.response.GatewayResponse
import dev.kord.rest.route.Route
import dev.kord.test.IgnoreOnSimulatorPlatforms
import io.ktor.client.*
import io.ktor.client.engine.mock.*
import io.ktor.http.*
Expand All @@ -16,7 +15,6 @@ expect class StackTraceElement
expect fun currentThreadStackTrace(): StackTraceElement
internal expect fun RecoveredStackTrace.validate(expected: StackTraceElement)

@IgnoreOnSimulatorPlatforms
class StackTraceRecoveryTest {

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ actual typealias StackTraceElement = String
//-->at 5 ??? 7ff684fbdeca kfun:dev.kord.rest.request.StackTraceRecoveryTest.$test stack trace<--
actual fun currentThreadStackTrace(): StackTraceElement =
Exception().stackTraceToString().lineSequence().filterNot(String::isBlank).drop(5).first().trim()
.substringAfter("???")
.substringAfter("0x")

internal actual fun RecoveredStackTrace.validate(expected: StackTraceElement) {
// The first few lines are artifacts from coroutines which are not present in expected
val actual = stackTraceToString().lineSequence().drop(6).first().trim()
.substringAfter("???") // index is off at call site
.substringAfter("0x") // index is off at call site
assertEquals(expected, actual)
}

0 comments on commit 2b9e588

Please sign in to comment.