diff --git a/idea/testData/debugger/tinyApp/src/forTests/coroutines.kt b/idea/testData/debugger/tinyApp/src/forTests/coroutines.kt index db56ed1aa3d..ca0c44a1630 100644 --- a/idea/testData/debugger/tinyApp/src/forTests/coroutines.kt +++ b/idea/testData/debugger/tinyApp/src/forTests/coroutines.kt @@ -4,6 +4,8 @@ import kotlin.coroutines.experimental.Continuation import kotlin.coroutines.experimental.CoroutineContext import kotlin.coroutines.experimental.EmptyCoroutineContext import kotlin.coroutines.experimental.startCoroutine +import java.util.concurrent.CountDownLatch +import java.util.concurrent.TimeUnit open class EmptyContinuation(override val context: CoroutineContext = EmptyCoroutineContext) : Continuation { companion object : EmptyContinuation() @@ -14,3 +16,22 @@ open class EmptyContinuation(override val context: CoroutineContext = EmptyCorou fun builder(c: suspend () -> Unit) { 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) + } +} \ No newline at end of file diff --git a/idea/testData/debugger/tinyApp/src/stepping/stepOver/soSuspendableCallInEndOfFun.kt b/idea/testData/debugger/tinyApp/src/stepping/stepOver/soSuspendableCallInEndOfFun.kt index 0c823205adc..3f2ab9ddb83 100644 --- a/idea/testData/debugger/tinyApp/src/stepping/stepOver/soSuspendableCallInEndOfFun.kt +++ b/idea/testData/debugger/tinyApp/src/stepping/stepOver/soSuspendableCallInEndOfFun.kt @@ -1,18 +1,21 @@ package soSuspendableCallInEndOfFun import forTests.builder +import forTests.WaitFinish import kotlin.coroutines.experimental.Continuation import kotlin.coroutines.experimental.suspendCoroutine private fun foo(a: Any) {} +val waiter = WaitFinish() + fun main(args: Array) { builder { inFun() } foo("Main end") - Thread.sleep(100) + waiter.waitEnd() } suspend fun inFun() { @@ -24,8 +27,9 @@ suspend fun inFun() { suspend fun run() { suspendCoroutine { cont: Continuation -> Thread { - cont.resume(Unit) Thread.sleep(10) + cont.resume(Unit) + waiter.finish() }.start() } } diff --git a/idea/testData/debugger/tinyApp/src/stepping/stepOver/soSuspendableCallInEndOfFun.out b/idea/testData/debugger/tinyApp/src/stepping/stepOver/soSuspendableCallInEndOfFun.out index f4fb0909853..642cee3788d 100644 --- a/idea/testData/debugger/tinyApp/src/stepping/stepOver/soSuspendableCallInEndOfFun.out +++ b/idea/testData/debugger/tinyApp/src/stepping/stepOver/soSuspendableCallInEndOfFun.out @@ -1,11 +1,11 @@ -LineBreakpoint created at soSuspendableCallInEndOfFun.kt:21 +LineBreakpoint created at soSuspendableCallInEndOfFun.kt:24 Run Java Connected to the target VM +soSuspendableCallInEndOfFun.kt:24 soSuspendableCallInEndOfFun.kt:21 -soSuspendableCallInEndOfFun.kt:18 -soSuspendableCallInEndOfFun.kt:22 +soSuspendableCallInEndOfFun.kt:25 soSuspendableCallInEndOfFun.kt:-1 -soSuspendableCallInEndOfFun.kt:28 +soSuspendableCallInEndOfFun.kt:32 Disconnected from the target VM Process finished with exit code 0 diff --git a/idea/testData/debugger/tinyApp/src/stepping/stepOver/soSuspendableCallInEndOfLambda.kt b/idea/testData/debugger/tinyApp/src/stepping/stepOver/soSuspendableCallInEndOfLambda.kt index b88951c61e8..bd4b18bfacf 100644 --- a/idea/testData/debugger/tinyApp/src/stepping/stepOver/soSuspendableCallInEndOfLambda.kt +++ b/idea/testData/debugger/tinyApp/src/stepping/stepOver/soSuspendableCallInEndOfLambda.kt @@ -1,11 +1,14 @@ package soSuspendableCallInEndOfLambda import forTests.builder +import forTests.WaitFinish import kotlin.coroutines.experimental.Continuation import kotlin.coroutines.experimental.suspendCoroutine private fun foo(a: Any) {} +val waiter = WaitFinish() + fun main(args: Array) { builder { foo("Start") @@ -14,14 +17,15 @@ fun main(args: Array) { } foo("Main end") - Thread.sleep(100) + waiter.waitEnd() } suspend fun run() { suspendCoroutine { cont: Continuation -> Thread { - cont.resume(Unit) Thread.sleep(10) + cont.resume(Unit) + waiter.finish() }.start() } } diff --git a/idea/testData/debugger/tinyApp/src/stepping/stepOver/soSuspendableCallInEndOfLambda.out b/idea/testData/debugger/tinyApp/src/stepping/stepOver/soSuspendableCallInEndOfLambda.out index 21ee7834760..e99f6c5c0a6 100644 --- a/idea/testData/debugger/tinyApp/src/stepping/stepOver/soSuspendableCallInEndOfLambda.out +++ b/idea/testData/debugger/tinyApp/src/stepping/stepOver/soSuspendableCallInEndOfLambda.out @@ -1,9 +1,9 @@ -LineBreakpoint created at soSuspendableCallInEndOfLambda.kt:13 +LineBreakpoint created at soSuspendableCallInEndOfLambda.kt:16 Run Java Connected to the target VM +soSuspendableCallInEndOfLambda.kt:16 soSuspendableCallInEndOfLambda.kt:13 -soSuspendableCallInEndOfLambda.kt:10 -soSuspendableCallInEndOfLambda.kt:14 +soSuspendableCallInEndOfLambda.kt:17 Disconnected from the target VM Process finished with exit code 0 diff --git a/idea/testData/debugger/tinyApp/src/stepping/stepOver/soSuspendableCallInFun.kt b/idea/testData/debugger/tinyApp/src/stepping/stepOver/soSuspendableCallInFun.kt index bf01ada3fa9..2164797453e 100644 --- a/idea/testData/debugger/tinyApp/src/stepping/stepOver/soSuspendableCallInFun.kt +++ b/idea/testData/debugger/tinyApp/src/stepping/stepOver/soSuspendableCallInFun.kt @@ -1,18 +1,21 @@ package soSuspendableCallInFun import forTests.builder +import forTests.WaitFinish import kotlin.coroutines.experimental.Continuation import kotlin.coroutines.experimental.suspendCoroutine private fun foo(a: Any) {} +val waiter = WaitFinish() + fun main(args: Array) { builder { inFun() } foo("Main end") - Thread.sleep(100) + waiter.waitEnd() } suspend fun inFun() { @@ -24,8 +27,9 @@ suspend fun inFun() { suspend fun run() { suspendCoroutine { cont: Continuation -> Thread { - cont.resume(Unit) Thread.sleep(10) + cont.resume(Unit) + waiter.finish() }.start() } } diff --git a/idea/testData/debugger/tinyApp/src/stepping/stepOver/soSuspendableCallInFun.out b/idea/testData/debugger/tinyApp/src/stepping/stepOver/soSuspendableCallInFun.out index 172f32012cb..8565e6a5f51 100644 --- a/idea/testData/debugger/tinyApp/src/stepping/stepOver/soSuspendableCallInFun.out +++ b/idea/testData/debugger/tinyApp/src/stepping/stepOver/soSuspendableCallInFun.out @@ -1,9 +1,9 @@ -LineBreakpoint created at soSuspendableCallInFun.kt:20 +LineBreakpoint created at soSuspendableCallInFun.kt:23 Run Java Connected to the target VM -soSuspendableCallInFun.kt:20 -soSuspendableCallInFun.kt:18 +soSuspendableCallInFun.kt:23 soSuspendableCallInFun.kt:21 +soSuspendableCallInFun.kt:24 Disconnected from the target VM Process finished with exit code 0 diff --git a/idea/testData/debugger/tinyApp/src/stepping/stepOver/soSuspendableCallInFunFromOtherStepping.kt b/idea/testData/debugger/tinyApp/src/stepping/stepOver/soSuspendableCallInFunFromOtherStepping.kt index 934027ebc36..dbbab8c6447 100644 --- a/idea/testData/debugger/tinyApp/src/stepping/stepOver/soSuspendableCallInFunFromOtherStepping.kt +++ b/idea/testData/debugger/tinyApp/src/stepping/stepOver/soSuspendableCallInFunFromOtherStepping.kt @@ -1,18 +1,21 @@ package soSuspendableCallInFunFromOtherStepping import forTests.builder +import forTests.WaitFinish import kotlin.coroutines.experimental.Continuation import kotlin.coroutines.experimental.suspendCoroutine private fun foo(a: Any) {} +val waiter = WaitFinish() + fun main(args: Array) { builder { inFun() } foo("Main end") - Thread.sleep(120) + waiter.waitEnd() } suspend fun inFun() { @@ -25,8 +28,9 @@ suspend fun inFun() { suspend fun run() { return suspendCoroutine { cont: Continuation -> Thread { - cont.resume(Unit) Thread.sleep(10) + cont.resume(Unit) + waiter.finish() }.start() } } diff --git a/idea/testData/debugger/tinyApp/src/stepping/stepOver/soSuspendableCallInFunFromOtherStepping.out b/idea/testData/debugger/tinyApp/src/stepping/stepOver/soSuspendableCallInFunFromOtherStepping.out index 7e24da9f664..e875ff0d4fe 100644 --- a/idea/testData/debugger/tinyApp/src/stepping/stepOver/soSuspendableCallInFunFromOtherStepping.out +++ b/idea/testData/debugger/tinyApp/src/stepping/stepOver/soSuspendableCallInFunFromOtherStepping.out @@ -1,10 +1,10 @@ -LineBreakpoint created at soSuspendableCallInFunFromOtherStepping.kt:20 +LineBreakpoint created at soSuspendableCallInFunFromOtherStepping.kt:23 Run Java Connected to the target VM -soSuspendableCallInFunFromOtherStepping.kt:20 +soSuspendableCallInFunFromOtherStepping.kt:23 +soSuspendableCallInFunFromOtherStepping.kt:24 soSuspendableCallInFunFromOtherStepping.kt:21 -soSuspendableCallInFunFromOtherStepping.kt:18 -soSuspendableCallInFunFromOtherStepping.kt:22 +soSuspendableCallInFunFromOtherStepping.kt:25 Disconnected from the target VM Process finished with exit code 0 diff --git a/idea/testData/debugger/tinyApp/src/stepping/stepOver/soSuspendableCallInLambda.kt b/idea/testData/debugger/tinyApp/src/stepping/stepOver/soSuspendableCallInLambda.kt index b61a6798594..bae1840e49c 100644 --- a/idea/testData/debugger/tinyApp/src/stepping/stepOver/soSuspendableCallInLambda.kt +++ b/idea/testData/debugger/tinyApp/src/stepping/stepOver/soSuspendableCallInLambda.kt @@ -1,11 +1,14 @@ package soSuspendableCallInLambda import forTests.builder +import forTests.WaitFinish import kotlin.coroutines.experimental.Continuation import kotlin.coroutines.experimental.suspendCoroutine private fun foo(a: Any) {} +val waiter = WaitFinish() + fun main(args: Array) { builder { //Breakpoint! @@ -14,14 +17,15 @@ fun main(args: Array) { } foo("Main end") - Thread.sleep(100) + waiter.waitEnd() } suspend fun run() { suspendCoroutine { cont: Continuation -> Thread { - cont.resume(Unit) Thread.sleep(10) + cont.resume(Unit) + waiter.finish() }.start() } } diff --git a/idea/testData/debugger/tinyApp/src/stepping/stepOver/soSuspendableCallInLambda.out b/idea/testData/debugger/tinyApp/src/stepping/stepOver/soSuspendableCallInLambda.out index 7021513dbf6..2ff3fc28948 100644 --- a/idea/testData/debugger/tinyApp/src/stepping/stepOver/soSuspendableCallInLambda.out +++ b/idea/testData/debugger/tinyApp/src/stepping/stepOver/soSuspendableCallInLambda.out @@ -1,9 +1,9 @@ -LineBreakpoint created at soSuspendableCallInLambda.kt:12 +LineBreakpoint created at soSuspendableCallInLambda.kt:15 Run Java Connected to the target VM -soSuspendableCallInLambda.kt:12 -soSuspendableCallInLambda.kt:10 +soSuspendableCallInLambda.kt:15 soSuspendableCallInLambda.kt:13 +soSuspendableCallInLambda.kt:16 Disconnected from the target VM Process finished with exit code 0 diff --git a/idea/testData/debugger/tinyApp/src/stepping/stepOverForce/sofSuspendableCallInFun.kt b/idea/testData/debugger/tinyApp/src/stepping/stepOverForce/sofSuspendableCallInFun.kt index 55b5c6ba312..edc5ea1234d 100644 --- a/idea/testData/debugger/tinyApp/src/stepping/stepOverForce/sofSuspendableCallInFun.kt +++ b/idea/testData/debugger/tinyApp/src/stepping/stepOverForce/sofSuspendableCallInFun.kt @@ -1,18 +1,21 @@ package sofSuspendableCallInFun import forTests.builder +import forTests.WaitFinish import kotlin.coroutines.experimental.Continuation import kotlin.coroutines.experimental.suspendCoroutine private fun foo(a: Any) {} +val waiter = WaitFinish() + fun main(args: Array) { builder { inFun() } foo("Main end") - Thread.sleep(100) + waiter.waitEnd() } suspend fun inFun() { @@ -27,8 +30,9 @@ suspend fun run() { suspendCoroutine { cont: Continuation -> Thread { - cont.resume(Unit) Thread.sleep(10) + cont.resume(Unit) + waiter.finish() }.start() } } diff --git a/idea/testData/debugger/tinyApp/src/stepping/stepOverForce/sofSuspendableCallInFun.out b/idea/testData/debugger/tinyApp/src/stepping/stepOverForce/sofSuspendableCallInFun.out index 0c79ed31d31..4cbabbf962d 100644 --- a/idea/testData/debugger/tinyApp/src/stepping/stepOverForce/sofSuspendableCallInFun.out +++ b/idea/testData/debugger/tinyApp/src/stepping/stepOverForce/sofSuspendableCallInFun.out @@ -1,10 +1,10 @@ -LineBreakpoint created at sofSuspendableCallInFun.kt:20 -LineBreakpoint created at sofSuspendableCallInFun.kt:26 +LineBreakpoint created at sofSuspendableCallInFun.kt:23 +LineBreakpoint created at sofSuspendableCallInFun.kt:29 Run Java Connected to the target VM -sofSuspendableCallInFun.kt:20 -sofSuspendableCallInFun.kt:18 +sofSuspendableCallInFun.kt:23 sofSuspendableCallInFun.kt:21 +sofSuspendableCallInFun.kt:24 Disconnected from the target VM Process finished with exit code 0