mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-19 13:02:30 +07:00
IJPL-159930 Wait for initial block finalization in tests
After the rework of document update, we have to rely on the fact that command started event is handled on EDT (install content listener and so on) before the command finished event is arrived. Without this fix `command with empty output` test is failing for Zsh. The general problem of event sequence guarantees is important and will be addressed later. (cherry picked from commit 0bcbc6a7e7741be1cfc2443c76e5f58a6c393dda) IJ-MR-144634 GitOrigin-RevId: 1a723219b5f349a153506eae7e964c5da5faa3bd
This commit is contained in:
committed by
intellij-monorepo-bot
parent
a4f43db135
commit
e80b5437da
@@ -31,6 +31,7 @@ import org.junit.runner.RunWith
|
||||
import org.junit.runners.Parameterized
|
||||
import java.nio.file.Path
|
||||
import java.util.*
|
||||
import java.util.concurrent.CompletableFuture
|
||||
import java.util.concurrent.CountDownLatch
|
||||
import java.util.function.BiPredicate
|
||||
import kotlin.time.Duration
|
||||
@@ -174,9 +175,25 @@ internal class BlockTerminalCommandExecutionTest(private val shellPath: Path) {
|
||||
val view = BlockTerminalView(projectRule.project, session, JBTerminalSystemSettingsProvider(), TerminalTitle())
|
||||
Disposer.register(disposableRule.disposable, view)
|
||||
view.outputView.controller.finishCommandBlock(0) // emulate `initialized` event as it's consumed in `startBlockTerminalSession()`
|
||||
awaitFirstBlockFinalizedOrRemoved(view.outputView.controller.outputModel)
|
||||
return Pair(session, view)
|
||||
}
|
||||
|
||||
private fun awaitFirstBlockFinalizedOrRemoved(outputModel: TerminalOutputModel, duration: Duration = 5.seconds) {
|
||||
val future = CompletableFuture<Unit>()
|
||||
outputModel.addListener(object : TerminalOutputModelListener {
|
||||
override fun blockFinalized(block: CommandBlock) {
|
||||
future.complete(Unit)
|
||||
}
|
||||
|
||||
override fun blockRemoved(block: CommandBlock) {
|
||||
future.complete(Unit)
|
||||
}
|
||||
})
|
||||
val error = { "Timed out waiting for initial block finalized or removed" }
|
||||
PlatformTestUtil.waitWithEventsDispatching(error, { future.isDone }, duration.inWholeSeconds.toInt())
|
||||
}
|
||||
|
||||
private fun awaitBlocksFinalized(outputModel: TerminalOutputModel, commandBlocks: Int, duration: Duration = 20.seconds) {
|
||||
val latch = CountDownLatch(commandBlocks)
|
||||
outputModel.addListener(object : TerminalOutputModelListener {
|
||||
|
||||
Reference in New Issue
Block a user