Skip to content

Add ctrl-c propagation e2e test with graceful SIGINT handling#299

Draft
branchseer wants to merge 7 commits intomainfrom
add-ctrl-c-e2e-test
Draft

Add ctrl-c propagation e2e test with graceful SIGINT handling#299
branchseer wants to merge 7 commits intomainfrom
add-ctrl-c-e2e-test

Conversation

@branchseer
Copy link
Copy Markdown
Member

@branchseer branchseer commented Mar 27, 2026

Summary

  • Add vtt exit-on-ctrlc subcommand that sets up a ctrl-c handler, emits a "ready" milestone, then prints "ctrl-c received" and exits when interrupted
  • Add ctrl-c as a new write-key interaction type in the e2e test runner
  • Add argv step spawn mode ({ argv = ["vt", "run", ...] }) that spawns directly without a shell wrapper, avoiding bash's CTRL_C exit code interference on Windows
  • Add e2e fixture with two packages running vt run -r dev to verify SIGINT propagates to concurrent tasks and they exit cleanly
  • Handle SIGINT gracefully in vt: register a no-op ctrlc handler before the tokio runtime so the runner survives Ctrl+C and reports actual task exit status
  • Clear Windows CTRL_C ignore flag in vtt exit-on-ctrlc (Rust runtime sets this and it persists to children)
  • Fix expect_milestone to preserve unmatched milestones instead of silently dropping them via take_unhandled_osc_sequences
  • Use staged temp dir for insta snapshot paths so cross-platform testing via cargo-xtest works on read-only WebDAV mounts
  • Strip ^C terminal echo and normalize ctrl-c received count in e2e redaction for cross-platform snapshot consistency

🤖 Generated with Claude Code

@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

Add a `vtt exit-on-ctrlc` subcommand and e2e fixture that verifies SIGINT
propagates to concurrent tasks when the user presses Ctrl+C. The test runs
two packages with `vt run -r dev`, synchronizes them via a filesystem barrier,
then sends ctrl-c and verifies both tasks receive and handle it.

Also adds `ctrl-c` as a new `write-key` interaction type for e2e snapshot tests.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@branchseer branchseer force-pushed the add-ctrl-c-e2e-test branch 7 times, most recently from 711e66e to b49617e Compare March 27, 2026 10:49
@branchseer branchseer changed the title Add e2e snapshot test for ctrl-c propagation Add ctrl-c propagation e2e test and graceful SIGINT handling Mar 27, 2026
@branchseer branchseer force-pushed the add-ctrl-c-e2e-test branch 9 times, most recently from 0aba31b to ad17ff1 Compare March 27, 2026 11:56
Add a `vtt exit-on-ctrlc` subcommand and e2e fixture that verifies SIGINT
propagates to concurrent tasks when the user presses Ctrl+C. The test runs
two packages with `vt run -r dev`, synchronizes via milestone protocol,
then sends ctrl-c and verifies both tasks receive and handle it.

Also adds `ctrl-c` as a new `write-key` interaction type, fixes
`expect_milestone` to preserve unmatched milestones, strips `^C`
terminal echo in redaction, and normalizes Windows CTRL_C exit code (512)
to match Unix (1) for cross-platform snapshot consistency.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@branchseer branchseer force-pushed the add-ctrl-c-e2e-test branch from ad17ff1 to 7646aec Compare March 27, 2026 12:02
branchseer and others added 2 commits March 27, 2026 21:24
Use parent().parent() instead of canonicalize() to find the repo root
from CARGO_MANIFEST_DIR. Avoids resolving symlinks which can cause
issues on some CI environments.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Use staged temp dir for insta snapshot paths so writes work on read-only
filesystems (e.g. WebDAV mount during cargo-xtest). Skip
INSTA_REQUIRE_FULL_MATCH when INSTA_UPDATE is set, allowing cross-platform
runs to accept metadata-only snapshot changes.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@branchseer branchseer marked this pull request as draft March 27, 2026 13:49
@branchseer branchseer changed the title Add ctrl-c propagation e2e test and graceful SIGINT handling feat: graceful ctrl-c handling Mar 27, 2026
branchseer and others added 2 commits March 27, 2026 22:10
- Register a ctrlc no-op handler in vt before the tokio runtime starts,
  so Ctrl+C doesn't kill the runner via the default signal handler. Child
  tasks receive SIGINT directly from the terminal driver.
- Use std::process::exit to avoid non-zero exit codes from Rust runtime
  cleanup on Windows when background ctrlc threads are active.
- Add argv spawn mode for e2e steps: `{ argv = ["vt", "run", ...] }`
  spawns directly without a shell wrapper, avoiding bash's CTRL_C exit
  code interference on Windows.
- Clear Windows CTRL_C ignore flag in vtt exit-on-ctrlc before registering
  the handler (Rust runtime sets this flag and it persists to children).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@branchseer branchseer changed the title feat: graceful ctrl-c handling Add ctrl-c propagation e2e test with graceful SIGINT handling Mar 27, 2026
Investigation confirmed Rust std, ctrlc crate, and portable-pty have
zero calls to SetConsoleCtrlHandler(NULL, TRUE). The inheritable ignore
flag is set by the Windows ConPTY subsystem for spawned processes.
The SetConsoleCtrlHandler(None, 0) workaround is still needed — without
it the test times out on Windows — but the comment was wrong about the
source.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@branchseer branchseer force-pushed the add-ctrl-c-e2e-test branch from bb29dc4 to 3a54fbc Compare March 27, 2026 15:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant