Skip to content

Commit 6841fae

Browse files
committed
Better debuggability of kotlinx-coroutines-debug test
1 parent 68f187b commit 6841fae

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

kotlinx-coroutines-debug/test/StacktraceUtils.kt

+4-3
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,8 @@ private fun cleanBlockHoundTraces(frames: List<String>): List<String> {
9090
public fun verifyDump(vararg traces: String, ignoredCoroutine: String? = null) {
9191
val baos = ByteArrayOutputStream()
9292
DebugProbes.dumpCoroutines(PrintStream(baos))
93-
val trace = baos.toString().split("\n\n")
93+
val wholeDump = baos.toString()
94+
val trace = wholeDump.split("\n\n")
9495
if (traces.isEmpty()) {
9596
val filtered = trace.filter { ignoredCoroutine == null || !it.contains(ignoredCoroutine) }
9697
assertEquals(1, filtered.count())
@@ -105,15 +106,15 @@ public fun verifyDump(vararg traces: String, ignoredCoroutine: String? = null) {
105106

106107
val expected = traces[index - 1].applyBackspace().split("\n\t(Coroutine creation stacktrace)\n", limit = 2)
107108
val actual = value.applyBackspace().split("\n\t(Coroutine creation stacktrace)\n", limit = 2)
108-
assertEquals(expected.size, actual.size, "Creation stacktrace should be part of the expected input")
109+
assertEquals(expected.size, actual.size, "Creation stacktrace should be part of the expected input. Whole dump:\n$wholeDump")
109110

110111
expected.withIndex().forEach { (index, trace) ->
111112
val actualTrace = actual[index].trimStackTrace().sanitizeAddresses()
112113
val expectedTrace = trace.trimStackTrace().sanitizeAddresses()
113114
val actualLines = cleanBlockHoundTraces(actualTrace.split("\n"))
114115
val expectedLines = expectedTrace.split("\n")
115116
for (i in expectedLines.indices) {
116-
assertEquals(expectedLines[i], actualLines[i])
117+
assertEquals(expectedLines[i], actualLines[i], "Whole dump:\n$wholeDump")
117118
}
118119
}
119120
}

0 commit comments

Comments
 (0)