Skip to content

fix(tests): normalize cargo-affected target dir in PTY snapshots - #2565

Merged
max-sixty merged 1 commit into
mainfrom
fix/ci-25295115776
May 4, 2026
Merged

max-sixty merged 1 commit into
mainfrom
fix/ci-25295115776

Conversation

@worktrunk-bot

Copy link
Copy Markdown
Collaborator

Problem

The collect affected coverage job 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 step Install cargo-affected does 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_accept
  • approval_pty::test_approval_prompt_decline
  • approval_pty::test_approval_prompt_mixed_approved_unapproved_accept
  • approval_pty::test_approval_prompt_mixed_approved_unapproved_decline

The diff shape:

- Cannot change directory — ran [BIN]
+ Cannot change directory — ran [PROJECT_ROOT]/target/affected/build/debug/wt

The redactor at tests/common/mod.rs:1196 (add_pty_binary_path_filters) and the "Binary invoked as:" filter at line 984 only matched target/(?:llvm-cov-target/)?(?:debug|release)/wt, so cargo-affected's target/affected/build/debug/wt survived path normalization and tripped the snapshot assertion.

Solution

Mirror the existing llvm-cov-target handling for affected/build/. Two layers because two filter pipelines:

  1. Prelude normalization (add_snapshot_path_prelude_filters): add /target/affected/build/ → /target/ next to the existing /target/llvm-cov-target/ rule. Tests using setup_snapshot_settings (including the failing approval_pty tests, and any test relying on the "Binary invoked as:" filter) get the new path collapsed before downstream filters run.
  2. PTY-only filter (add_pty_binary_path_filters): extend the regex to accept affected/build/ alongside llvm-cov-target/. Tests like bare_repo_prompt_pty use setup_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.
  • End-to-end verification of the cargo-affected path lands once CI runs this PR (the affected tests (linux, advisory) job exercises cargo affected run on PRs).

Automated fix for failed run.

`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]>
@worktrunk-bot worktrunk-bot added the automated-fix Automated CI fix label May 4, 2026
@worktrunk-bot

Copy link
Copy Markdown
Collaborator Author

Same failure recurred on the next push to main: run 25295134736 on commit 275eaea. Identical diagnostic — collect affected coverage job, same four approval_pty snapshot tests failing with target/affected/build/debug/wt surviving path normalization. This PR's fix covers it.

@worktrunk-bot

Copy link
Copy Markdown
Collaborator Author

Same failure recurred on the next push to main: run 25296075638 on commit 6632057. Identical diagnostic — collect affected coverage job, same four approval_pty snapshot tests failing because target/affected/build/debug/wt survives path normalization. This PR's fix covers it; CI on main will keep failing until it merges.

@worktrunk-bot

Copy link
Copy Markdown
Collaborator Author

Same failure recurred again on main: run 25296233625 on commit 0e20e7b (PR #2567 merge). Identical diagnostic — collect affected coverage job, four approval_pty snapshot tests failing because target/affected/build/debug/wt survives path normalization. Every push to main fails CI until this PR lands.

@max-sixty
max-sixty merged commit ce66d9c into main May 4, 2026
25 checks passed
@max-sixty
max-sixty deleted the fix/ci-25295115776 branch May 4, 2026 04:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automated-fix Automated CI fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants