We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 7015ad2 commit 1e0ed74Copy full SHA for 1e0ed74
kotlinx-coroutines-core/src/test/kotlin/guide/test/TestUtil.kt
@@ -43,11 +43,17 @@ fun threadNames(): Set<String> {
43
}
44
val names = hashSetOf<String>()
45
for (i in 0 until n)
46
- names.add(arrayOfThreads[i]!!.name)
+ names.add(sanitizeThreadName(arrayOfThreads[i]!!.name))
47
return names
48
49
50
51
+// remove coroutine names from thread in case we have lost threads with coroutines running in them
52
+private fun sanitizeThreadName(name: String): String {
53
+ val i = name.indexOf(" @")
54
+ return if (i < 0) name else name.substring(0, i)
55
+}
56
+
57
fun checkTestThreads(threadNamesBefore: Set<String>) {
58
// give threads some time to shutdown
59
val waitTill = System.currentTimeMillis() + 1000L
0 commit comments