From de2d3dd1c30f957cc758cabeb973051a2911f707 Mon Sep 17 00:00:00 2001 From: Konstantin Hudyakov Date: Fri, 17 Jan 2025 18:00:17 +0200 Subject: [PATCH] [terminal] IJPL-173788 Wait for prompt before performing test logic GitOrigin-RevId: 12a9af54bf7974e74a0633899828272cf38d71c2 --- .../plugins/terminal/reworked/ShellIntegrationTest.kt | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/plugins/terminal/tests/org/jetbrains/plugins/terminal/reworked/ShellIntegrationTest.kt b/plugins/terminal/tests/org/jetbrains/plugins/terminal/reworked/ShellIntegrationTest.kt index acb03a18ce6c..96c99fbd07ca 100644 --- a/plugins/terminal/tests/org/jetbrains/plugins/terminal/reworked/ShellIntegrationTest.kt +++ b/plugins/terminal/tests/org/jetbrains/plugins/terminal/reworked/ShellIntegrationTest.kt @@ -9,6 +9,7 @@ import com.intellij.testFramework.RuleChain import com.intellij.testFramework.common.timeoutRunBlocking import com.jediterm.core.util.TermSize import com.jediterm.terminal.TerminalKeyEncoder +import kotlinx.coroutines.CompletableDeferred import kotlinx.coroutines.channels.SendChannel import kotlinx.coroutines.coroutineScope import kotlinx.coroutines.delay @@ -181,13 +182,19 @@ internal class ShellIntegrationTest(private val shellPath: Path) { val session = TerminalSessionTestUtil.startTestTerminalSession(shellPath.toString(), projectRule.project, childScope("TerminalSession"), size) val outputEvents = mutableListOf() + val promptFinishedEventDeferred = CompletableDeferred(false) launch { for (events in session.outputChannel) { outputEvents.addAll(events) + if (events.any { it is TerminalPromptFinishedEvent }) { + promptFinishedEventDeferred.complete(true) + } } } - delay(1000) // Wait for prompt initialization + // Wait for prompt initialization before going further + promptFinishedEventDeferred.await() + block(session.inputChannel) delay(1000) // Wait for the shell to handle input sent in `block`