Repository navigation
fix(tests): normalize cargo-affected target dir in PTY snapshots - #2565
Conversation
`cargo affected collect` builds the instrumented binary at `target/affected/build/debug/wt` (max-sixty/cargo-affected#12, merged 2026-05-03), but the snapshot redactors only normalized `target/debug/wt`. The CI `collect affected coverage` job started failing on every push to main as soon as the unpinned cargo-affected install picked up the new path: PTY snapshot tests like `approval_pty::test_approval_prompt_accept` saw `[PROJECT_ROOT]/target/affected/build/debug/wt` where the snapshot expected `[BIN]`. Two layers, mirroring the existing `llvm-cov-target` handling: - Add `/target/affected/build/` → `/target/` to the prelude path filter so all tests using `setup_snapshot_settings` (where the "Binary invoked as:" filter runs downstream of the normalization) match the pre-existing `target/debug/wt` patterns. - Extend the standalone `add_pty_binary_path_filters` regex to accept `affected/build/` for tests using `setup_temp_snapshot_settings`, which doesn't include the prelude filters. Co-Authored-By: Claude <[email protected]>
|
Same failure recurred on the next push to main: run 25295134736 on commit 275eaea. Identical diagnostic — |
|
Same failure recurred on the next push to main: run 25296075638 on commit 6632057. Identical diagnostic — |
|
Same failure recurred again on main: run 25296233625 on commit 0e20e7b (PR #2567 merge). Identical diagnostic — |
Problem
The
collect affected coveragejob has been failing on main since cargo-affected merged max-sixty/cargo-affected#12 ("collect: route instrumented builds to target/affected/build/", 2026-05-03 23:13Z). The CI stepInstall cargo-affecteddoes not pin a revision, so the very next push to main picked up the new layout.In run 25295115776, four PTY snapshot tests failed identically:
approval_pty::test_approval_prompt_acceptapproval_pty::test_approval_prompt_declineapproval_pty::test_approval_prompt_mixed_approved_unapproved_acceptapproval_pty::test_approval_prompt_mixed_approved_unapproved_declineThe diff shape:
The redactor at
tests/common/mod.rs:1196(add_pty_binary_path_filters) and the "Binary invoked as:" filter at line 984 only matchedtarget/(?:llvm-cov-target/)?(?:debug|release)/wt, so cargo-affected'starget/affected/build/debug/wtsurvived path normalization and tripped the snapshot assertion.Solution
Mirror the existing
llvm-cov-targethandling foraffected/build/. Two layers because two filter pipelines:add_snapshot_path_prelude_filters): add/target/affected/build/→/target/next to the existing/target/llvm-cov-target/rule. Tests usingsetup_snapshot_settings(including the failingapproval_ptytests, and any test relying on the "Binary invoked as:" filter) get the new path collapsed before downstream filters run.add_pty_binary_path_filters): extend the regex to acceptaffected/build/alongsidellvm-cov-target/. Tests likebare_repo_prompt_ptyusesetup_temp_snapshot_settings, which doesn't include the prelude filters, so they need the extension at the [BIN] regex itself.Testing
cargo test --test integration --features shell-integration-tests "approval_pty"→ 13 passed, 0 failed.cargo test --test integration --features shell-integration-tests "bare_repository::bare_repo_prompt_pty"→ 3 passed, 0 failed.affected tests (linux, advisory)job exercisescargo affected runon PRs).Automated fix for failed run.