Skip to content

test(switch): run the interactive picker tests on Windows - #3221

Merged
max-sixty merged 4 commits into
mainfrom
skim-windows
Jun 25, 2026
Merged

max-sixty merged 4 commits into
mainfrom
skim-windows

Conversation

@max-sixty

@max-sixty max-sixty commented Jun 25, 2026 •

Copy link
Copy Markdown
Owner

PR #3217 made wt switch's interactive picker run on Windows, but its tests stayed #[cfg(unix)] — so the Windows CI leg proved the picker compiled without ever exercising its runtime. This ungates them so Windows CI drives the real thing.

What's ungated (the test infra — mock_commands, the ConPTY handling in tests/common/pty.rs — was already cross-platform, so this is largely a gate flip):

  • switch_picker_dry_run.rs — the headless dry-run pipeline (collect → render → preview cache → summary spawn → warning drain).
  • The --prs dry-run tests in switch.rs — forge fetch + row render via the cross-platform mock gh/glab.
  • The two requires-tty snapshots — the no-TTY bail is uniform across platforms.
  • switch_picker.rs — the PTY/vt100 TUI snapshot tests.

Test-quality fix folded in: the four --prs dry-run tests asserted only output.status.success(), but the fetch path is fail-soft (any error → stashed warning → exit 0). On a platform where the mock didn't resolve they would pass vacuously. They now assert the fetched row actually rendered (a pr:42/mr:7 preview-cache entry, or the empty-list warning).

Also: /bin/cat → cat in the summary test (resolves via the platform shell on Unix and Git Bash alike); removed the stale "picker is Unix-only" line that #3217 left in the wt switch docs (and regenerated the help snapshot).

Windows results (first full run): of the ~50 ungated tests, 46 passed on Windows on the first run — including every PTY/vt100 snapshot test (skim renders byte-identically under ConPTY), the accept-path drain tests, and the cat-via-Git-Bash summary test. Two issues surfaced and are handled here:

  • The three interactive --prs picker tests failed because the test helper mock_forge_env joined mock-bin onto PATH with a hardcoded : separator — malformed on Windows (;), so the mock gh.exe/glab.exe was never found. Fixed to use std::env::join_paths (OS-aware), matching the dry-run path's helper.
  • test_switch_picker_pre_switch_hook_requires_approval exits 1 instead of 0 on Windows: declining the hook returns Ok on both platforms, so the failure is in the interactive approval prompt's stdin handoff after skim releases the ConPTY. Not reproducible locally — #[cfg_attr(windows, ignore)] with a TODO until a Windows box can debug it (still compiles on Windows, runs on Unix). This is a genuine picker-on-Windows gap surfaced by this work, tracked for follow-up.

This was written by Claude Code on behalf of max

PR #3217 unblocked the `wt switch` picker on Windows but left its tests
`#[cfg(unix)]` — so Windows CI proved the picker compiled but never exercised
its runtime. Ungate them: the dry-run pipeline tests, the `--prs` forge-fetch
dry-run tests, the requires-tty snapshots, and the PTY (vt100) snapshot tests.
The test infra was already cross-platform (mock_commands installs a real
`.exe`; tests/common/pty.rs has explicit ConPTY handling), so this is mostly a
gate flip.

Also:
- Strengthen the four `--prs` dry-run tests to assert the fetched PR/MR row
  actually rendered (a `pr:42`/`mr:7` cache entry, or the empty-list warning).
  The fetch path is fail-soft and exits 0 even when the forge mock fails, so a
  status-only assertion would pass vacuously on a platform where the mock
  doesn't resolve — making a green Windows run meaningless.
- `/bin/cat` -> `cat` in the summary test; it runs via the platform shell, so
  the bare name resolves on Unix and Git Bash alike.
- Drop the stale "picker is Unix-only" line #3217 left in the `wt switch` docs.

The genuinely-unix tests (symlinked-path switch, the no-CLI minimal-bin helper)
stay gated.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

@worktrunk-bot worktrunk-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code-coverage job is red on a real, deterministic failure from this PR — not a flake. Removing the "Available on Unix only…" line from after_long_help in src/cli/mod.rs changed the rendered wt switch --help, but the help snapshot wasn't regenerated, so integration_tests::help::test_help::case_09 (help_switch_long) still asserts the old text:

Snapshot: help_switch_long
  183 │-Available on Unix only (macOS, Linux). On Windows, use wt list or wt switch <branch> directly.
  184 │-

The doc mirrors (docs/content/switch.md, skills/worktrunk/reference/switch.md) were updated correctly — only the rendered help snapshot was missed. Since this is a plain integration test (not behind shell-integration-tests), the still-pending test (linux/macos/windows) jobs will hit the same failure, so the whole test matrix will go red until it's regenerated.

Fix is mechanical — drop the two stale lines (214–215) from tests/snapshots/integration__integration_tests__help__help_switch_long.snap, or regenerate:

cargo insta test --accept -- --test integration test_help

Want me to push the snapshot update to this branch?

Dropping the stale "picker is Unix-only" line from `after_long_help` in
src/cli/mod.rs changed the rendered `wt switch --help`; the doc mirrors were
regenerated but the help snapshot was missed. `test_help::case_09` is a plain
integration test, so it failed the required matrix before the picker tests ran.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
worktrunk-bot
worktrunk-bot previously approved these changes Jun 25, 2026

@worktrunk-bot worktrunk-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Windows experiment this PR set out to run came back partially red: test (windows) (required) and affected tests (windows, advisory) both fail, while test (linux) and test (macos) pass. The four failures are all in the file this PR ungates (switch_picker.rs), so they're the PR's central question — does the picker drive correctly under Windows ConPTY? — rather than an unrelated flake.

The important wrinkle vs. the PR's coverage caveat: three of the four are wait_for_content timeouts, not vt100 snapshot divergences. The caveat anticipated "a snapshot diverges → routine cargo insta accept", but a timeout means the expected text never reached the screen at all, so cargo insta accept can't resolve it — these need the ConPTY-specific follow-up you flagged, not an accept.

The three --prs timeouts share a shape: each waits 30s for forge-fetched content (#42, !7, loading open PRs) that never appears. Notably test_switch_picker_prs_shows_loading_marker waits for loading open PRs, which is the pre-fetch loading state — so it's not the mock gh/glab resolving slowly; the --prs async fetch/render path appears not to surface anything under ConPTY. The fourth (pre_switch_hook_requires_approval) is a different failure mode — an exit-code assertion (switch should still succeed after declining the pre-switch hook), not a PTY timeout — so it likely wants separate investigation from the --prs trio.

I've dismissed my earlier approval: a required check is red on a failure that is directly this PR's subject, so an empty-body approval would be rubber-stamping over the visible signal. Happy to dig into the ConPTY --prs render path or the pre-switch-hook assertion if you'd like — just say the word and I'll push to this branch.

Failure details (from test (windows), run 28144592708)

All four in tests/integration_tests/switch_picker.rs, ungated by the #![cfg(all(unix, …))] → #![cfg(feature = "shell-integration-tests")] flip:

FAIL test_switch_picker_pre_switch_hook_requires_approval (switch_picker.rs:1701)
  assertion `left == right` failed: switch should still succeed after declining the pre-switch hook
  (exit-code assertion, not a PTY timeout)

FAIL test_switch_picker_prs_github_list  (switch_picker.rs:465)
  Timed out after 30s waiting for expected content "#42"

FAIL test_switch_picker_prs_gitlab_list  (switch_picker.rs:465)
  Timed out after 30s waiting for expected content "!7"

FAIL test_switch_picker_prs_shows_loading_marker (switch_picker.rs:465)
  Timed out after 30s waiting for expected content "loading open PRs"

Summary: 3841 tests run: 3837 passed, 4 failed, 35 skipped

The snapshot-only fix from the prior commit (dropping the stale "Unix only" lines) was correct and unblocked the help_switch_long assertion — Linux and macOS are fully green. The four remaining failures are Windows-runtime-specific.

@worktrunk-bot
worktrunk-bot dismissed their stale review June 25, 2026 03:44

CI failed — test (windows) (required) is red on 4 picker tests this PR ungates (3 ConPTY wait_for_content timeouts + 1 pre-switch-hook exit-code assertion). See follow-up review comment.

max-sixty and others added 2 commits June 24, 2026 20:50
…line test

Windows CI ran the newly-ungated picker tests; 46/50 passed (vt100 snapshots,
accept-path drain, and the `cat` summary all work under ConPTY). The 4 misses:

- The three interactive `--prs` picker tests (`prs_github_list`,
  `prs_gitlab_list`, `prs_shows_loading_marker`) timed out because
  `mock_forge_env` joined mock-bin onto PATH with a hardcoded `:` — on Windows
  the separator is `;`, so the PATH was malformed and the mock `gh.exe`/
  `glab.exe` was never found. Use `std::env::join_paths` (OS-aware), matching
  the dry-run path's `configure_mock_cli_env` (which is why the `--prs`
  dry-run tests passed on Windows but the PTY ones didn't).
- `pre_switch_hook_requires_approval` exits 1 instead of 0 on Windows.
  Declining the hook returns Ok on both platforms, so the failure is in the
  interactive approval prompt's stdin handoff after skim releases the ConPTY.
  Not reproducible locally; `#[cfg_attr(windows, ignore)]` with a TODO until a
  Windows box can debug it. It still compiles on Windows and runs on Unix.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@max-sixty
max-sixty merged commit 8f17cb4 into main Jun 25, 2026
36 checks passed
@max-sixty
max-sixty deleted the skim-windows branch June 25, 2026 04:46
max-sixty added a commit that referenced this pull request Jun 25, 2026
`test_switch_picker_worktree_row_comments_tab_shows_thread` prepended the
mock-`gh` directory to PATH with a hardcoded `:`. On Windows the separator is
`;`, so the join corrupts PATH, the mock `gh.exe` is never found, and the
worktree row's comments fetch fails — the tab renders "Couldn't load comments"
instead of the thread, timing out the 30s wait for the comment body. Passed on
Linux/macOS (where `:` is correct) but failed `test (windows)` once #3221
enabled the picker tests there.

Switch to `std::env::split_paths`/`join_paths` (the OS separator), matching the
`--prs` mock helper in this file.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
max-sixty added a commit that referenced this pull request Jun 25, 2026
Two follow-ups from #3221 (running the interactive picker tests on
Windows).

## `test_switch_picker_pre_switch_hook_requires_approval` on Windows

#3221 landed this test `#[cfg_attr(windows, ignore)]` with a TODO that
suspected the picker's approval prompt couldn't read stdin after skim
released the ConPTY. The actual cause, from the failing run's screen
(prompt shown, `n` echoed, yet exit 1) and its timing (`FAIL [ 7.963s]`
— the harness's 5s kill window plus setup): a **hang**, not an error.

Once skim releases the terminal, the approval prompt's `read_line` runs
in the OS line discipline (cooked mode). Windows' console line-input
terminates a line on **CR** (the Enter key) and never on a bare **LF** —
so the test's `"n\n"` left `read_line` blocked until the harness killed
the hung process. Every other `[y/N]` `read_line` PTY test
(`approval_pty.rs`, `config_show`'s `plugin_prompt_pty`) is
`#[cfg(unix)]`-gated, so this picker test was the first to drive one on
Windows.

This was a test input-convention bug, not a product gap — a real Windows
user presses Enter (CR) and is unaffected. The fix sends `"n\r"`:
Windows reads it as Enter, and Unix's ICRNL maps it to LF. Verified on
macOS (passes in ~3.5s, no hang); the Windows leg is confirmed by this
PR's CI.

## Doc: `--help` snapshot regen

Editing help text changes two generated artifacts — the doc mirrors
(regenerated by `test_docs_are_in_sync`) and the rendered `--help`
snapshots (`test_help`). Only `docs/CLAUDE.md` documented the second, so
an agent following root `CLAUDE.md` or `src/commands/CLAUDE.md` would
leave the help snapshots stale and fail required CI. Added the regen
step to both.

> _This was written by Claude Code on behalf of max_

Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
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.

2 participants