mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-03-22 15:10:43 +07:00
timeoutRunBlocking: don't wait for completion of the test task to print the dump
GitOrigin-RevId: 5bb2452728cf71be25902ef793cc6a90538d7e84
This commit is contained in:
committed by
intellij-monorepo-bot
parent
6a3ec29602
commit
32c8164183
@@ -2,10 +2,8 @@
|
||||
package com.intellij.testFramework.common
|
||||
|
||||
import com.intellij.diagnostic.dumpCoroutines
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.TimeoutCancellationException
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import kotlinx.coroutines.withTimeout
|
||||
import com.intellij.util.io.blockingDispatcher
|
||||
import kotlinx.coroutines.*
|
||||
import org.jetbrains.annotations.TestOnly
|
||||
import kotlin.time.Duration
|
||||
import kotlin.time.Duration.Companion.seconds
|
||||
@@ -17,12 +15,19 @@ val DEFAULT_TEST_TIMEOUT: Duration = 10.seconds
|
||||
fun timeoutRunBlocking(timeout: Duration = DEFAULT_TEST_TIMEOUT, action: suspend CoroutineScope.() -> Unit) {
|
||||
@Suppress("RAW_RUN_BLOCKING")
|
||||
runBlocking {
|
||||
try {
|
||||
withTimeout(timeout, action)
|
||||
}
|
||||
catch (e: TimeoutCancellationException) {
|
||||
println(dumpCoroutines())
|
||||
throw e
|
||||
val job = launch(block = action)
|
||||
@OptIn(DelicateCoroutinesApi::class)
|
||||
launch(blockingDispatcher) {
|
||||
try {
|
||||
withTimeout(timeout) {
|
||||
job.join()
|
||||
}
|
||||
}
|
||||
catch (e: TimeoutCancellationException) {
|
||||
job.cancel(e)
|
||||
println(dumpCoroutines())
|
||||
throw e
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user