Skip to content

fix(wt-perf): move timeline tests to lib + exclude bin from test compile - #2604

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

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

Conversation

@worktrunk-bot

Copy link
Copy Markdown
Collaborator

Problem

The collect affected coverage job has been failing on every push to main since #2558 merged, with the same error shape:

FAIL [   0.009s] (3487/3491) wt-perf::bin/wt-perf tests::cmd_failure_annotates_name
    cargo-affected runner-shim: failed to resolve binary_id for /home/runner/work/worktrunk/worktrunk/target/affected/build/debug/deps/wt_perf-01f04725fd165542: binary not found in map (path: /home/runner/work/worktrunk/worktrunk/target/affected/build/debug/deps/wt_perf-01f04725fd165542); target-name basename fallback ambiguous — 2 candidates share target name "wt_perf" ([wt-perf, wt-perf::bin/wt-perf]) and the marker probe matched 0 of them (none; candidates without markers: wt-perf::bin/wt-perf, wt-perf); re-run `cargo affected collect`

Root cause: the [lib] name = "wt_perf" and [[bin]] name = "wt-perf" artifacts both normalize to the same wt_perf basename. cargo-affected's runner shim disambiguates same-basename test binaries via a marker probe, but markers only fire for kind = "test" | "bench" | "example" — lib and bin get none. Once #2558 added inline tests under bin/wt-perf, both candidates appeared in cargo-affected's binary map without markers, so any hash drift between list and run aborted the shim with basename fallback ambiguous.

Issue #2571 previously diagnosed this as transient, but it has continued to fail every run since (25295115776, 25301191157, 25303363793, 25309058661, 25336005330) with the same error shape — it is durable, not transient.

Solution

Two changes together fix it:

  • Move render_timeline (and its describe/duration_of helpers) plus the inline tests from src/main.rs into src/lib.rs. The bin no longer carries any #[cfg(test)] items.
  • Set test = false on the [[bin]] in Cargo.toml so cargo doesn't emit a test binary for it. This removes the bin from cargo-affected's binary map entirely, so even with hash drift the basename fallback finds a single candidate (the lib). The bin still gets compiled at target/debug/wt-perf because tests/builds.rs triggers it.

Testing

  • cargo build -p wt-perf — produces the binary at target/debug/wt-perf and wt-perf --help works as before.
  • cargo test -p wt-perf — both timeline tests (renders_sorted_timeline_with_summary, cmd_failure_annotates_name) pass under the lib target; the bin target no longer ships a test binary.
  • cargo clippy -p wt-perf --tests — clean.

This commit is identical to f168bde on the orphaned fix/ci-25289365418 branch (cherry-picked here onto a current main).


Automated fix for failed run

The `[lib] name = "wt_perf"` and `[[bin]] name = "wt-perf"` artifacts
both normalize to the same `wt_perf` basename. cargo-affected's runner
shim disambiguates same-basename test binaries via a marker probe, but
markers only fire for `kind = "test" | "bench" | "example"` — `lib` and
`bin` get none. Once #2558 added inline tests under `bin/wt-perf`, both
candidates appeared in cargo-affected's binary map without markers, so
any hash drift between list and run aborted the shim with
`basename fallback ambiguous`. The collect-affected job on main has
been broken since #2558 merged.

Two changes together fix it:

- Move `render_timeline` (and its `describe`/`duration_of` helpers) plus
  the inline tests from `src/main.rs` into `src/lib.rs`. The bin no
  longer carries any `#[cfg(test)]` items.
- Set `test = false` on the `[[bin]]` in Cargo.toml so cargo doesn't
  emit a test binary for it. This removes the bin from cargo-affected's
  binary map entirely, so even with hash drift the basename fallback
  finds a single candidate (the lib). The bin still gets compiled at
  `target/debug/wt-perf` because `tests/builds.rs` triggers it.

Co-Authored-By: Claude <[email protected]>
@worktrunk-bot worktrunk-bot added the automated-fix Automated CI fix label May 4, 2026
@max-sixty

Copy link
Copy Markdown
Owner

is this a problem with cargo-affected? file an issue upstream if so

@max-sixty

Copy link
Copy Markdown
Owner

I'll merge to prevent failures, but we should fix upstream and then possibly revert

@max-sixty
max-sixty merged commit e261e50 into main May 4, 2026
25 checks passed
@max-sixty
max-sixty deleted the fix/ci-25336005330 branch May 4, 2026 20:19
@worktrunk-bot

Copy link
Copy Markdown
Collaborator Author

Yes — root cause is in cargo-affected's marker probe: it only emits source-path markers for kind = "test" | "bench" | "example" and skips lib/bin, so two same-basename non-test targets can't be disambiguated when cargo's hash drifts. Filed max-sixty/cargo-affected#13 with the diagnosis and a suggested fix direction (extend the marker emitter to lib/bin source paths). Once that lands we can revert this PR.

max-sixty added a commit that referenced this pull request May 5, 2026
PR #2604 moved timeline tests out of `tests/helpers/wt-perf/src/main.rs`
into `src/lib.rs` and set `test = false` on the `[[bin]]` to dodge
[cargo-affected#13](max-sixty/cargo-affected#13)
— the runner shim couldn't disambiguate `[lib]` and `[[bin]]` artifacts
that both normalize to `wt_perf` when neither kind carries a marker.


[cargo-affected#14](max-sixty/cargo-affected#14)
fixed that upstream by reading `NEXTEST_BINARY_ID` from the nextest env
directly, so the shim now handles lib+bin collisions natively. The
workaround is no longer needed.

This restores the three files in `tests/helpers/wt-perf/` to their
pre-#2604 state: tests live in `main.rs` again, the bin compiles its
`#[cfg(test)]` block under nextest, and the `test = false` line is gone.

CI installs `cargo-affected` from git without a pin (see
`.github/workflows/ci.yaml:287`, `:359`), so the upstream fix is picked
up automatically — no pin bump.

## Verification

- `cargo build -p wt-perf` ✓
- `cargo test -p wt-perf` ✓ — both inline tests run from `main.rs`
(`tests::cmd_failure_annotates_name`,
`tests::renders_sorted_timeline_with_summary`), plus the
`tests/builds.rs::builds` integration test.
- The `affected tests` and `collect affected coverage` jobs in this PR's
CI will exercise the actual fix end-to-end.

> _This was written by Claude Code on behalf of @max-sixty_

Co-authored-by: Claude <[email protected]>
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