Skip to content

Commit d31aca4

Browse files
committed
Fix coroutine dump tests
1 parent 1f32e90 commit d31aca4

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

kotlinx-coroutines-debug/test/StacktraceUtils.kt

+8-8
Original file line numberDiff line numberDiff line change
@@ -82,20 +82,20 @@ public fun verifyDump(vararg traces: String, ignoredCoroutine: String? = null) {
8282
return
8383
}
8484
// Drop "Coroutine dump" line
85-
trace.withIndex().drop(1).forEach { (index, value) ->
85+
trace.drop(1).withIndex().forEach { (index, value) ->
8686
if (ignoredCoroutine != null && value.contains(ignoredCoroutine)) {
8787
return@forEach
8888
}
8989

90-
val expected = traces[index - 1].split("\n\tat kotlinx.coroutines.debug.ArtificialStackFrames.coroutineCreation(ArtificialStackFrames.kt)\n", limit = 2)
91-
val actual = value.split("\n\tat kotlinx.coroutines.debug.ArtificialStackFrames.coroutineCreation(ArtificialStackFrames.kt)\n", limit = 2)
90+
val expected = traces[index].split(Regex("\n\tat kotlinx.coroutines.debug.ArtificialStackFrames.coroutineCreation[^\n]*\n"), limit = 2)
91+
val actual = value.split(Regex("\n\tat kotlinx.coroutines.debug.ArtificialStackFrames.coroutineCreation[^\n]*\n"), limit = 2)
9292
assertEquals(expected.size, actual.size, "Creation stacktrace should be part of the expected input")
9393

94-
expected.withIndex().forEach { (index, trace) ->
95-
val actualTrace = actual[index].trimStackTrace().sanitizeAddresses()
96-
val expectedTrace = trace.trimStackTrace().sanitizeAddresses()
97-
val actualLines = cleanBlockHoundTraces(actualTrace.split("\n"))
98-
val expectedLines = expectedTrace.split("\n")
94+
actual.zip(expected).forEach { (actualTrace, expectedTrace) ->
95+
val sanitizedActualTrace = actualTrace.trimStackTrace().sanitizeAddresses()
96+
val sanitizedExpectedTrace = expectedTrace.trimStackTrace().sanitizeAddresses()
97+
val actualLines = cleanBlockHoundTraces(sanitizedActualTrace.split("\n"))
98+
val expectedLines = sanitizedExpectedTrace.split("\n")
9999
for (i in expectedLines.indices) {
100100
assertEquals(expectedLines[i], actualLines[i])
101101
}

0 commit comments

Comments
 (0)