Repository navigation
fix(test): wait for the TUI to be idle before the next input and drain the pty before asserting (#877) - #881
Merged
Merged
Conversation
…pty EOF after exit The TUI pty e2e tests sent the next prompt, /quit or Esc as soon as the answer text appeared, but the answer lands before the turn is over. A prompt typed then steers the running turn instead of starting one (the Esc then cancels a finished turn and (turn cancelled) never renders), and /quit is ignored while a turn runs (wait_exit times out). wait_exit also returned before the pty reader thread had copied the child's last output, so the bracketed-paste restore assertion raced it. Wait for the idle hint before each next input and for the reader's EOF after the child exits. Waits stay event based with the shared 60 s bound; nothing an assertion checks is loosened. Refs #877
🔍 Cora AI Code Review✅ No issues found. Code looks good! Review powered by cora-code · BYOK · MIT |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Fixes the intermittent failures of the TUI pty e2e tests (
tui_streams_approves_cancels_and_leaves_an_ordinary_session,tui_steers_queues_and_returns_the_queue_on_cancel) and a third race intui_bracketed_paste_is_one_block_that_waits_for_enter. Test code only; no product change.Why
Root cause, reproduced under
taskset -c 0with busy loops and high--test-threads:STREAM-ANSWER) renders before the turn'sMsg::Doneis processed, sorunningis still true when the test sends its next input.slow\rsteered the finishing turn,expect("working")matched a stale frame, Esc cancelled an already-finished turn, the steered text ran as a fresh 20 s turn, and(turn cancelled)never rendered (60 s timeout)./quitis ignored while a turn runs, so in the steers test the quit was lost andwait_exit()timed out.wait_exitreturned as soon as the child exited, before the pty reader thread had copied the child's last output, so the bracketed-paste restore assertion (\x1b[?2004l) raced it.Changes
idle()(the idle hint, rendered only whenrunningis false) is awaited before the next prompt and before/quitat four points in the two cancel-family tests.Ptygets aneofflag set by the reader thread;wait_exitwaits for it after the child exits (same 60 s bound; expiry is not masked because the caller's assertion still checks the content).Testing
Stress runs of the whole
tui_e2ebinary undertaskset -c 0plus busy loops:--test-threads 16--test-threads 32--no-default-features, shell-tools),cargo check -p tole-core --no-default-features --tests, and fullcargo testin the default and the other two profiles withTOLE_REQUIRE_BWRAP=1 --no-fail-fast: green.Msg::Doneis sent after the answer text streams, the/quitand steer behaviour is intended; and it rantui_e2e4 times unloaded and 8 times undertaskset -c 0with busy loops, 15/15 each time). CI on the head after merging develop (feat(skills): pin a third-party skill with a source and a ledger that outranks the approvals file (#600) #880): all checks green, Cora Review "No issues found".Refs #877, #702, #712, #738