test: add comprehensive e2e tests for interrupt/cancellation#107
Merged
emal-avala merged 1 commit intomainfrom Apr 15, 2026
Merged
test: add comprehensive e2e tests for interrupt/cancellation#107emal-avala merged 1 commit intomainfrom
emal-avala merged 1 commit intomainfrom
Conversation
Follow-up to #106. The initial e2e test only verified cancellation during a single turn. This adds coverage for the specific regression scenarios the original fix was designed to prevent. New tests: - cancel_works_across_multiple_turns: the actual #103 regression. Cancels turn 1, then runs turn 2 and verifies it's still cancellable via the same shared handle. Pre-fix this would hang forever because the signal handler held a stale token clone. - cancel_does_not_poison_next_turn: pre-cancels the shared token, then runs a normal turn to verify run_turn_with_sink resets to a fresh un-cancelled token. - cancel_before_first_event_interrupts_cleanly: race condition edge case where cancel fires during or before the first rx.recv(). - cancelled_turn_emits_warning_to_sink: verifies the sink is notified via on_warning("Cancelled"), confirming the UI feedback path works. Refactors the existing test to share a build_engine/schedule_cancel helper so new scenarios stay concise.
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
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.
Summary
Follow-up to #106. The initial e2e test only verified cancellation during a single turn with a hanging provider. This PR adds coverage for the specific regression scenarios the original fix was designed to prevent — most importantly the back-to-back-turns test that directly exercises the stale-token-clone bug.
New tests
cancel_works_across_multiple_turns— the actual cannot interrupt it #103 regression. Cancels turn 1, then runs turn 2 and verifies it's still cancellable via the same shared handle. Pre-fix this would hang forever on turn 2 because the signal handler held a stale clone.cancel_does_not_poison_next_turn— pre-cancels the shared token, then runs a completing turn to verifyrun_turn_with_sinkresets to a fresh un-cancelled token at turn start.cancel_before_first_event_interrupts_cleanly— race-condition edge case where cancel fires during or before the firstrx.recv().cancelled_turn_emits_warning_to_sink— verifies the sink is notified viaon_warning(\"Cancelled\"), confirming the UI feedback path works.Refactoring
HangingProvidermock out of the test function so it can be sharedCompletingProviderthat emits text +Donenormallybuild_engineandschedule_cancelhelpers to keep new scenarios conciseWhat's still not covered (out of scope here)
spawn_escape_watcherthread reading real crossterm events (requires a pty-based test)install_signal_handlerSIGINT path (would require sending real OS signals)EscapeWatcherGuard::dropThese remain manual-test items in the README checklist for #106.
Test plan