Skip to content

Commit f7c5249

Browse files
elizarovqwwdfsad
authored andcommitted
TestBase: Support -Dtest.verbose=true to print expected indices
1 parent 6b5318d commit f7c5249

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

core/kotlinx-coroutines-core/test/TestBase.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,13 @@
44

55
package kotlinx.coroutines.experimental
66

7+
import kotlinx.coroutines.experimental.internal.*
78
import org.junit.*
89
import kotlinx.coroutines.experimental.scheduling.*
910
import java.util.concurrent.atomic.*
1011

12+
private val VERBOSE = systemProp("test.verbose", false)
13+
1114
/**
1215
* Base class for tests, so that tests for predictable scheduling of actions in multiple coroutines sharing a single
1316
* thread can be written. Use it like this:
@@ -74,6 +77,7 @@ public actual open class TestBase actual constructor() {
7477
*/
7578
public actual fun expect(index: Int) {
7679
val wasIndex = actionIndex.incrementAndGet()
80+
if (VERBOSE) println("expect($index), wasIndex=$wasIndex")
7781
check(index == wasIndex) { "Expecting action index $index but it is actually $wasIndex" }
7882
}
7983

0 commit comments

Comments
 (0)