Skip to content

Make cancelled-JoinError test fixture deterministic - #140

Merged
leynos merged 3 commits into
mainfrom
fix-mutation-baseline
Jul 18, 2026
Merged

Make cancelled-JoinError test fixture deterministic#140
leynos merged 3 commits into
mainfrom
fix-mutation-baseline

Conversation

@leynos

@leynos leynos commented Jul 10, 2026

Copy link
Copy Markdown
Owner

Closes #139.

Summary

The cargo-mutants unmutated baseline intermittently failed on
supervisor::tests::logs_failures::case_3 (run 29074661946) while plain CI
stayed green. The defect is not the log-capture path — the test already uses a
scoped with_default subscriber — but a race in the test fixture that builds
the cancelled JoinError.

create_cancelled_join_error spawned a task that yields once and then
completes, on a multi-threaded runtime, and aborted it afterwards. The spawned
task runs concurrently on a worker thread, so under load it can finish before
abort() lands; handle.await then returns Ok(()) and unwrap_err()
panics (called Result::unwrap_err() on an Ok value). Machine load explains
the execution-shape dependence: cargo-mutants' baseline runs on a busier
machine profile than the plain make test job.

Fix

Abort a task awaiting std::future::pending::<()>() on a current-thread
runtime. The future can never complete, and on a current-thread runtime the
task cannot even be polled before block_on regains control, so the abort
always produces the cancelled JoinError. Test semantics are unchanged: the
fixture still hands log_task_failure a genuine cancelled JoinError.

Review walkthrough

Validation

  • Reproduced the failure locally before the fix: running the comenqd test
    binary's logs_failures filter repeatedly failed with the exact panic at
    tests.rs:36 (unwrap_err() on Ok) roughly once per 100 runs.
  • After the fix: 500 consecutive runs of the same filter pass.
  • cargo test --workspace --all-features (the cargo-mutants baseline shape,
    with the caller's extra-args) passed three consecutive full runs.
  • make check-fmt and make lint (Clippy; the Whitaker Dylint suite runs in
    CI) pass.

The logs_failures::case_3 fixture spawned a task that yields once and
completes, then aborted it on a multi-threaded runtime. The spawned
task ran concurrently on a worker thread, so under load it could
finish before abort() took effect, making handle.await return Ok(())
and the unwrap_err() call panic. This intermittently failed the
cargo-mutants unmutated baseline while plain CI stayed green.

Abort a task awaiting std::future::pending::<()>() instead, on a
current-thread runtime: the task can never complete and is not even
polled before the abort, so the JoinError is always the cancelled
variant. Reproduced at roughly 1 failure per 100 runs before the
change; 500 consecutive runs pass after it.

Closes #139.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Sorry @leynos, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@coderabbitai

coderabbitai Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You’ve reached a temporary PR review limit under our Fair Usage Limits Policy.

Your recent review volume is higher than typical usage, so adaptive limits are currently applied.

Next review available in: 33 minutes

Your organization has reached its usage spending cap. Adjust your spending cap in the billing tab.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 98780d23-c153-4d8c-a84f-f37c796a42c4

📥 Commits

Reviewing files that changed from the base of the PR and between 85ffd50 and fcd84d5.

📒 Files selected for processing (1)
  • crates/comenqd/src/supervisor/tests.rs
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-mutation-baseline

Comment @coderabbitai help to get the list of available commands.

@leynos
leynos marked this pull request as ready for review July 18, 2026 12:14

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Sorry @leynos, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@leynos
leynos enabled auto-merge (squash) July 18, 2026 14:23
@leynos
leynos merged commit 955ffbc into main Jul 18, 2026
11 checks passed
@leynos
leynos deleted the fix-mutation-baseline branch July 18, 2026 15:49
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.

Baseline log-capture test fails under cargo-mutants, blocking mutation runs

1 participant