Attempt for fix flaky debugger tests - wait for the resume before exit
This commit is contained in:
@@ -4,6 +4,8 @@ import kotlin.coroutines.experimental.Continuation
|
|||||||
import kotlin.coroutines.experimental.CoroutineContext
|
import kotlin.coroutines.experimental.CoroutineContext
|
||||||
import kotlin.coroutines.experimental.EmptyCoroutineContext
|
import kotlin.coroutines.experimental.EmptyCoroutineContext
|
||||||
import kotlin.coroutines.experimental.startCoroutine
|
import kotlin.coroutines.experimental.startCoroutine
|
||||||
|
import java.util.concurrent.CountDownLatch
|
||||||
|
import java.util.concurrent.TimeUnit
|
||||||
|
|
||||||
open class EmptyContinuation(override val context: CoroutineContext = EmptyCoroutineContext) : Continuation<Any?> {
|
open class EmptyContinuation(override val context: CoroutineContext = EmptyCoroutineContext) : Continuation<Any?> {
|
||||||
companion object : EmptyContinuation()
|
companion object : EmptyContinuation()
|
||||||
@@ -14,3 +16,22 @@ open class EmptyContinuation(override val context: CoroutineContext = EmptyCorou
|
|||||||
fun builder(c: suspend () -> Unit) {
|
fun builder(c: suspend () -> Unit) {
|
||||||
c.startCoroutine(EmptyContinuation)
|
c.startCoroutine(EmptyContinuation)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class WaitFinish(
|
||||||
|
private val timeout: Long = 5,
|
||||||
|
private val unit: TimeUnit = TimeUnit.SECONDS
|
||||||
|
) {
|
||||||
|
private val cdl = CountDownLatch(1)
|
||||||
|
|
||||||
|
fun finish() {
|
||||||
|
cdl.countDown()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun waitEnd() {
|
||||||
|
if (!cdl.await(timeout, unit)) {
|
||||||
|
throw java.lang.IllegalStateException("Too long wait in debugger test!")
|
||||||
|
}
|
||||||
|
|
||||||
|
Thread.sleep(10)
|
||||||
|
}
|
||||||
|
}
|
||||||
+6
-2
@@ -1,18 +1,21 @@
|
|||||||
package soSuspendableCallInEndOfFun
|
package soSuspendableCallInEndOfFun
|
||||||
|
|
||||||
import forTests.builder
|
import forTests.builder
|
||||||
|
import forTests.WaitFinish
|
||||||
import kotlin.coroutines.experimental.Continuation
|
import kotlin.coroutines.experimental.Continuation
|
||||||
import kotlin.coroutines.experimental.suspendCoroutine
|
import kotlin.coroutines.experimental.suspendCoroutine
|
||||||
|
|
||||||
private fun foo(a: Any) {}
|
private fun foo(a: Any) {}
|
||||||
|
|
||||||
|
val waiter = WaitFinish()
|
||||||
|
|
||||||
fun main(args: Array<String>) {
|
fun main(args: Array<String>) {
|
||||||
builder {
|
builder {
|
||||||
inFun()
|
inFun()
|
||||||
}
|
}
|
||||||
|
|
||||||
foo("Main end")
|
foo("Main end")
|
||||||
Thread.sleep(100)
|
waiter.waitEnd()
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun inFun() {
|
suspend fun inFun() {
|
||||||
@@ -24,8 +27,9 @@ suspend fun inFun() {
|
|||||||
suspend fun run() {
|
suspend fun run() {
|
||||||
suspendCoroutine { cont: Continuation<Unit> ->
|
suspendCoroutine { cont: Continuation<Unit> ->
|
||||||
Thread {
|
Thread {
|
||||||
cont.resume(Unit)
|
|
||||||
Thread.sleep(10)
|
Thread.sleep(10)
|
||||||
|
cont.resume(Unit)
|
||||||
|
waiter.finish()
|
||||||
}.start()
|
}.start()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-4
@@ -1,11 +1,11 @@
|
|||||||
LineBreakpoint created at soSuspendableCallInEndOfFun.kt:21
|
LineBreakpoint created at soSuspendableCallInEndOfFun.kt:24
|
||||||
Run Java
|
Run Java
|
||||||
Connected to the target VM
|
Connected to the target VM
|
||||||
|
soSuspendableCallInEndOfFun.kt:24
|
||||||
soSuspendableCallInEndOfFun.kt:21
|
soSuspendableCallInEndOfFun.kt:21
|
||||||
soSuspendableCallInEndOfFun.kt:18
|
soSuspendableCallInEndOfFun.kt:25
|
||||||
soSuspendableCallInEndOfFun.kt:22
|
|
||||||
soSuspendableCallInEndOfFun.kt:-1
|
soSuspendableCallInEndOfFun.kt:-1
|
||||||
soSuspendableCallInEndOfFun.kt:28
|
soSuspendableCallInEndOfFun.kt:32
|
||||||
Disconnected from the target VM
|
Disconnected from the target VM
|
||||||
|
|
||||||
Process finished with exit code 0
|
Process finished with exit code 0
|
||||||
|
|||||||
+6
-2
@@ -1,11 +1,14 @@
|
|||||||
package soSuspendableCallInEndOfLambda
|
package soSuspendableCallInEndOfLambda
|
||||||
|
|
||||||
import forTests.builder
|
import forTests.builder
|
||||||
|
import forTests.WaitFinish
|
||||||
import kotlin.coroutines.experimental.Continuation
|
import kotlin.coroutines.experimental.Continuation
|
||||||
import kotlin.coroutines.experimental.suspendCoroutine
|
import kotlin.coroutines.experimental.suspendCoroutine
|
||||||
|
|
||||||
private fun foo(a: Any) {}
|
private fun foo(a: Any) {}
|
||||||
|
|
||||||
|
val waiter = WaitFinish()
|
||||||
|
|
||||||
fun main(args: Array<String>) {
|
fun main(args: Array<String>) {
|
||||||
builder {
|
builder {
|
||||||
foo("Start")
|
foo("Start")
|
||||||
@@ -14,14 +17,15 @@ fun main(args: Array<String>) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
foo("Main end")
|
foo("Main end")
|
||||||
Thread.sleep(100)
|
waiter.waitEnd()
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun run() {
|
suspend fun run() {
|
||||||
suspendCoroutine { cont: Continuation<Unit> ->
|
suspendCoroutine { cont: Continuation<Unit> ->
|
||||||
Thread {
|
Thread {
|
||||||
cont.resume(Unit)
|
|
||||||
Thread.sleep(10)
|
Thread.sleep(10)
|
||||||
|
cont.resume(Unit)
|
||||||
|
waiter.finish()
|
||||||
}.start()
|
}.start()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -1,9 +1,9 @@
|
|||||||
LineBreakpoint created at soSuspendableCallInEndOfLambda.kt:13
|
LineBreakpoint created at soSuspendableCallInEndOfLambda.kt:16
|
||||||
Run Java
|
Run Java
|
||||||
Connected to the target VM
|
Connected to the target VM
|
||||||
|
soSuspendableCallInEndOfLambda.kt:16
|
||||||
soSuspendableCallInEndOfLambda.kt:13
|
soSuspendableCallInEndOfLambda.kt:13
|
||||||
soSuspendableCallInEndOfLambda.kt:10
|
soSuspendableCallInEndOfLambda.kt:17
|
||||||
soSuspendableCallInEndOfLambda.kt:14
|
|
||||||
Disconnected from the target VM
|
Disconnected from the target VM
|
||||||
|
|
||||||
Process finished with exit code 0
|
Process finished with exit code 0
|
||||||
|
|||||||
+6
-2
@@ -1,18 +1,21 @@
|
|||||||
package soSuspendableCallInFun
|
package soSuspendableCallInFun
|
||||||
|
|
||||||
import forTests.builder
|
import forTests.builder
|
||||||
|
import forTests.WaitFinish
|
||||||
import kotlin.coroutines.experimental.Continuation
|
import kotlin.coroutines.experimental.Continuation
|
||||||
import kotlin.coroutines.experimental.suspendCoroutine
|
import kotlin.coroutines.experimental.suspendCoroutine
|
||||||
|
|
||||||
private fun foo(a: Any) {}
|
private fun foo(a: Any) {}
|
||||||
|
|
||||||
|
val waiter = WaitFinish()
|
||||||
|
|
||||||
fun main(args: Array<String>) {
|
fun main(args: Array<String>) {
|
||||||
builder {
|
builder {
|
||||||
inFun()
|
inFun()
|
||||||
}
|
}
|
||||||
|
|
||||||
foo("Main end")
|
foo("Main end")
|
||||||
Thread.sleep(100)
|
waiter.waitEnd()
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun inFun() {
|
suspend fun inFun() {
|
||||||
@@ -24,8 +27,9 @@ suspend fun inFun() {
|
|||||||
suspend fun run() {
|
suspend fun run() {
|
||||||
suspendCoroutine { cont: Continuation<Unit> ->
|
suspendCoroutine { cont: Continuation<Unit> ->
|
||||||
Thread {
|
Thread {
|
||||||
cont.resume(Unit)
|
|
||||||
Thread.sleep(10)
|
Thread.sleep(10)
|
||||||
|
cont.resume(Unit)
|
||||||
|
waiter.finish()
|
||||||
}.start()
|
}.start()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -1,9 +1,9 @@
|
|||||||
LineBreakpoint created at soSuspendableCallInFun.kt:20
|
LineBreakpoint created at soSuspendableCallInFun.kt:23
|
||||||
Run Java
|
Run Java
|
||||||
Connected to the target VM
|
Connected to the target VM
|
||||||
soSuspendableCallInFun.kt:20
|
soSuspendableCallInFun.kt:23
|
||||||
soSuspendableCallInFun.kt:18
|
|
||||||
soSuspendableCallInFun.kt:21
|
soSuspendableCallInFun.kt:21
|
||||||
|
soSuspendableCallInFun.kt:24
|
||||||
Disconnected from the target VM
|
Disconnected from the target VM
|
||||||
|
|
||||||
Process finished with exit code 0
|
Process finished with exit code 0
|
||||||
|
|||||||
Vendored
+6
-2
@@ -1,18 +1,21 @@
|
|||||||
package soSuspendableCallInFunFromOtherStepping
|
package soSuspendableCallInFunFromOtherStepping
|
||||||
|
|
||||||
import forTests.builder
|
import forTests.builder
|
||||||
|
import forTests.WaitFinish
|
||||||
import kotlin.coroutines.experimental.Continuation
|
import kotlin.coroutines.experimental.Continuation
|
||||||
import kotlin.coroutines.experimental.suspendCoroutine
|
import kotlin.coroutines.experimental.suspendCoroutine
|
||||||
|
|
||||||
private fun foo(a: Any) {}
|
private fun foo(a: Any) {}
|
||||||
|
|
||||||
|
val waiter = WaitFinish()
|
||||||
|
|
||||||
fun main(args: Array<String>) {
|
fun main(args: Array<String>) {
|
||||||
builder {
|
builder {
|
||||||
inFun()
|
inFun()
|
||||||
}
|
}
|
||||||
|
|
||||||
foo("Main end")
|
foo("Main end")
|
||||||
Thread.sleep(120)
|
waiter.waitEnd()
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun inFun() {
|
suspend fun inFun() {
|
||||||
@@ -25,8 +28,9 @@ suspend fun inFun() {
|
|||||||
suspend fun run() {
|
suspend fun run() {
|
||||||
return suspendCoroutine { cont: Continuation<Unit> ->
|
return suspendCoroutine { cont: Continuation<Unit> ->
|
||||||
Thread {
|
Thread {
|
||||||
cont.resume(Unit)
|
|
||||||
Thread.sleep(10)
|
Thread.sleep(10)
|
||||||
|
cont.resume(Unit)
|
||||||
|
waiter.finish()
|
||||||
}.start()
|
}.start()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
+4
-4
@@ -1,10 +1,10 @@
|
|||||||
LineBreakpoint created at soSuspendableCallInFunFromOtherStepping.kt:20
|
LineBreakpoint created at soSuspendableCallInFunFromOtherStepping.kt:23
|
||||||
Run Java
|
Run Java
|
||||||
Connected to the target VM
|
Connected to the target VM
|
||||||
soSuspendableCallInFunFromOtherStepping.kt:20
|
soSuspendableCallInFunFromOtherStepping.kt:23
|
||||||
|
soSuspendableCallInFunFromOtherStepping.kt:24
|
||||||
soSuspendableCallInFunFromOtherStepping.kt:21
|
soSuspendableCallInFunFromOtherStepping.kt:21
|
||||||
soSuspendableCallInFunFromOtherStepping.kt:18
|
soSuspendableCallInFunFromOtherStepping.kt:25
|
||||||
soSuspendableCallInFunFromOtherStepping.kt:22
|
|
||||||
Disconnected from the target VM
|
Disconnected from the target VM
|
||||||
|
|
||||||
Process finished with exit code 0
|
Process finished with exit code 0
|
||||||
|
|||||||
+6
-2
@@ -1,11 +1,14 @@
|
|||||||
package soSuspendableCallInLambda
|
package soSuspendableCallInLambda
|
||||||
|
|
||||||
import forTests.builder
|
import forTests.builder
|
||||||
|
import forTests.WaitFinish
|
||||||
import kotlin.coroutines.experimental.Continuation
|
import kotlin.coroutines.experimental.Continuation
|
||||||
import kotlin.coroutines.experimental.suspendCoroutine
|
import kotlin.coroutines.experimental.suspendCoroutine
|
||||||
|
|
||||||
private fun foo(a: Any) {}
|
private fun foo(a: Any) {}
|
||||||
|
|
||||||
|
val waiter = WaitFinish()
|
||||||
|
|
||||||
fun main(args: Array<String>) {
|
fun main(args: Array<String>) {
|
||||||
builder {
|
builder {
|
||||||
//Breakpoint!
|
//Breakpoint!
|
||||||
@@ -14,14 +17,15 @@ fun main(args: Array<String>) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
foo("Main end")
|
foo("Main end")
|
||||||
Thread.sleep(100)
|
waiter.waitEnd()
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun run() {
|
suspend fun run() {
|
||||||
suspendCoroutine { cont: Continuation<Unit> ->
|
suspendCoroutine { cont: Continuation<Unit> ->
|
||||||
Thread {
|
Thread {
|
||||||
cont.resume(Unit)
|
|
||||||
Thread.sleep(10)
|
Thread.sleep(10)
|
||||||
|
cont.resume(Unit)
|
||||||
|
waiter.finish()
|
||||||
}.start()
|
}.start()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -1,9 +1,9 @@
|
|||||||
LineBreakpoint created at soSuspendableCallInLambda.kt:12
|
LineBreakpoint created at soSuspendableCallInLambda.kt:15
|
||||||
Run Java
|
Run Java
|
||||||
Connected to the target VM
|
Connected to the target VM
|
||||||
soSuspendableCallInLambda.kt:12
|
soSuspendableCallInLambda.kt:15
|
||||||
soSuspendableCallInLambda.kt:10
|
|
||||||
soSuspendableCallInLambda.kt:13
|
soSuspendableCallInLambda.kt:13
|
||||||
|
soSuspendableCallInLambda.kt:16
|
||||||
Disconnected from the target VM
|
Disconnected from the target VM
|
||||||
|
|
||||||
Process finished with exit code 0
|
Process finished with exit code 0
|
||||||
|
|||||||
+6
-2
@@ -1,18 +1,21 @@
|
|||||||
package sofSuspendableCallInFun
|
package sofSuspendableCallInFun
|
||||||
|
|
||||||
import forTests.builder
|
import forTests.builder
|
||||||
|
import forTests.WaitFinish
|
||||||
import kotlin.coroutines.experimental.Continuation
|
import kotlin.coroutines.experimental.Continuation
|
||||||
import kotlin.coroutines.experimental.suspendCoroutine
|
import kotlin.coroutines.experimental.suspendCoroutine
|
||||||
|
|
||||||
private fun foo(a: Any) {}
|
private fun foo(a: Any) {}
|
||||||
|
|
||||||
|
val waiter = WaitFinish()
|
||||||
|
|
||||||
fun main(args: Array<String>) {
|
fun main(args: Array<String>) {
|
||||||
builder {
|
builder {
|
||||||
inFun()
|
inFun()
|
||||||
}
|
}
|
||||||
|
|
||||||
foo("Main end")
|
foo("Main end")
|
||||||
Thread.sleep(100)
|
waiter.waitEnd()
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun inFun() {
|
suspend fun inFun() {
|
||||||
@@ -27,8 +30,9 @@ suspend fun run() {
|
|||||||
|
|
||||||
suspendCoroutine { cont: Continuation<Unit> ->
|
suspendCoroutine { cont: Continuation<Unit> ->
|
||||||
Thread {
|
Thread {
|
||||||
cont.resume(Unit)
|
|
||||||
Thread.sleep(10)
|
Thread.sleep(10)
|
||||||
|
cont.resume(Unit)
|
||||||
|
waiter.finish()
|
||||||
}.start()
|
}.start()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-4
@@ -1,10 +1,10 @@
|
|||||||
LineBreakpoint created at sofSuspendableCallInFun.kt:20
|
LineBreakpoint created at sofSuspendableCallInFun.kt:23
|
||||||
LineBreakpoint created at sofSuspendableCallInFun.kt:26
|
LineBreakpoint created at sofSuspendableCallInFun.kt:29
|
||||||
Run Java
|
Run Java
|
||||||
Connected to the target VM
|
Connected to the target VM
|
||||||
sofSuspendableCallInFun.kt:20
|
sofSuspendableCallInFun.kt:23
|
||||||
sofSuspendableCallInFun.kt:18
|
|
||||||
sofSuspendableCallInFun.kt:21
|
sofSuspendableCallInFun.kt:21
|
||||||
|
sofSuspendableCallInFun.kt:24
|
||||||
Disconnected from the target VM
|
Disconnected from the target VM
|
||||||
|
|
||||||
Process finished with exit code 0
|
Process finished with exit code 0
|
||||||
|
|||||||
Reference in New Issue
Block a user