Skip to content

Commit a2cdd9f

Browse files
committed
Add missing debug module tests
1 parent 38d3e51 commit a2cdd9f

File tree

3 files changed

+24
-3
lines changed

3 files changed

+24
-3
lines changed

buildSrc/src/main/kotlin/kover-conventions.gradle.kts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ val expectedCoverage = mutableMapOf(
1313
"kotlinx-coroutines-swing" to 70, // awaitFrame is not tested
1414
"kotlinx-coroutines-javafx" to 39, // JavaFx is not tested on TC because its graphic subsystem cannot be initialized in headless mode
1515

16-
// TODO figure it out, these probably should be fixed
17-
"kotlinx-coroutines-debug" to 84,
1816
// Re-evaluate this along with Kover update where deprecated with error+ functions are not considered as uncovered: IDEA-287459
1917
"kotlinx-coroutines-reactor" to 65,
2018
"kotlinx-coroutines-rx2" to 78
@@ -29,7 +27,7 @@ extensions.configure<KoverExtension> {
2927
* ./gradlew :p:check -Pkover.enabled=true -- verifies coverage
3028
* ./gradlew :p:koverReport -Pkover.enabled=true -- generates report
3129
*/
32-
isDisabled = false// !(properties["kover.enabled"]?.toString()?.toBoolean() ?: false)
30+
isDisabled = !(properties["kover.enabled"]?.toString()?.toBoolean() ?: false)
3331
}
3432

3533
subprojects {

kotlinx-coroutines-debug/build.gradle

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,15 @@ shadowJar {
5151
configurations = [project.configurations.shadowDeps]
5252
relocate('net.bytebuddy', 'kotlinx.coroutines.repackaged.net.bytebuddy')
5353
}
54+
55+
def commonKoverExcludes =
56+
// Never used, safety mechanism
57+
["kotlinx.coroutines.debug.internal.NoOpProbesKt"]
58+
59+
tasks.koverHtmlReport {
60+
excludes = commonKoverExcludes
61+
}
62+
63+
tasks.koverVerify {
64+
excludes = commonKoverExcludes
65+
}

kotlinx-coroutines-debug/test/ToStringTest.kt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import kotlinx.coroutines.*
88
import kotlinx.coroutines.channels.*
99
import org.junit.*
1010
import org.junit.Test
11+
import java.io.*
1112
import kotlin.coroutines.*
1213
import kotlin.test.*
1314

@@ -105,6 +106,8 @@ class ToStringTest : TestBase() {
105106
expect(6)
106107
assertEquals(expected, DebugProbes.jobToString(root).trimEnd().trimStackTrace().trimPackage())
107108
assertEquals(expected, DebugProbes.scopeToString(CoroutineScope(root)).trimEnd().trimStackTrace().trimPackage())
109+
assertEquals(expected, printToString { DebugProbes.printScope(CoroutineScope(root), it) }.trimEnd().trimStackTrace().trimPackage())
110+
assertEquals(expected, printToString { DebugProbes.printJob(root, it) }.trimEnd().trimStackTrace().trimPackage())
108111

109112
root.cancelAndJoin()
110113
finish(7)
@@ -145,4 +148,12 @@ class ToStringTest : TestBase() {
145148
}
146149
}
147150
}
151+
152+
private inline fun printToString(block: (PrintStream) -> Unit): String {
153+
val baos = ByteArrayOutputStream()
154+
val ps = PrintStream(baos)
155+
block(ps)
156+
ps.close()
157+
return baos.toString()
158+
}
148159
}

0 commit comments

Comments
 (0)