Skip to content

fix(cargo): keep nextest failed/skipped counts when a test is slow - #4467

Merged
KuSh merged 2 commits into
rtk-ai:developfrom
Cedric921:fix/nextest-slow-summary
Oct 20, 2026
Merged

KuSh merged 2 commits into
rtk-ai:developfrom
Cedric921:fix/nextest-slow-summary

Conversation

@Cedric921

Copy link
Copy Markdown
Contributor

Summary

nextest puts its in-place annotation right after passed (2 passed (1 slow), 1 failed, 1 skipped). The summary regex expected failed and skipped to come straight after passed, so once a test went slow both counts parsed as 0. With failed == 0 the filter took its green branch and also dropped the collected failure blocks, so a failing run showed up as cargo nextest: 2 passed (1 binary, 2.503s).

The fix adds an optional non-capturing (?:\s+\([^)]*\))? group right after passed. It matches (1 slow) and any other parenthesised annotation nextest puts there, such as a combined (1 slow, 1 flaky). Capture-group numbering doesn't change, so the rest of the parser is untouched.

Overlap with #3577: that PR adds (N slow) rendering by capturing \((\d+) slow\) at the end of the regex, after skipped. That position doesn't match what nextest actually prints, so its slow capture would still miss real output. This PR only fixes correctness and doesn't render slow counts. If #3577 lands afterwards, its slow capture should move into the group after passed that this PR adds.

Fixes #4420

Test plan

  • New test_filter_cargo_nextest_slow_annotation_keeps_failed_and_skipped uses the real 0.9.143 line Summary [ 2.503s] 3 tests run: 2 passed (1 slow), 1 failed, 1 skipped inside a realistic run with a FAIL block and a SLOW line. It asserts 2 passed, 1 failed, 1 skipped and that the failure header and stderr are kept. It failed before the fix with cargo nextest: 2 passed (1 binary, 2.503s), which is the exact output from the issue.
  • New test_filter_cargo_nextest_slow_annotation_all_pass covers an all-green run with (1 slow), which still renders the compact line.
  • Existing test_filter_cargo_nextest_with_failures (2 passed, 2 failed, 1 skipped, no annotation) still passes as the non-slow non-regression.
  • cargo fmt --all --check
  • cargo clippy --all-targets (no warnings)
  • cargo test

nextest annotates `passed` in place (`2 passed (1 slow), 1 failed, 1 skipped`).
The summary regex expected `failed` to follow `passed` directly, so a slow test
zeroed the failed/skipped counts and the green branch dropped failure blocks.
Allow an optional parenthesised annotation after `passed`.

Fixes rtk-ai#4420
@rtk-wshm-sync-bot rtk-wshm-sync-bot Bot added bug Something isn't working cargo rust testing labels Oct 6, 2026
@rtk-wshm-sync-bot

Copy link
Copy Markdown

wshm · Automated triage by AI

📊 Automated PR Analysis

🐛 Type bug-fix
🟢 Risk low

Summary

Fixes a regex in the cargo nextest output filter so that when a test is slow, nextest's inline '(N slow)' annotation after 'passed' no longer breaks parsing of the subsequent failed/skipped counts. Previously this caused failing/skipped runs with a slow test to be misreported as a clean all-passed summary. Adds two new tests covering the slow-annotation case with failures and an all-pass case.

Review Checklist

  • Tests present
  • Breaking change
  • Docs updated

Linked issues: #4420


Analyzed automatically by wshm · This is an automated analysis, not a human review.

@KuSh KuSh self-assigned this Oct 20, 2026
A run with retries prints `2 passed (1 slow, 1 flaky), 1 failed, 4 skipped`.
The annotation group accepts any parenthesised text, but the tests only
exercised `(1 slow)`, so narrowing it to `\(\d+ slow\)` passed the suite
while turning this run green. Pin it with a real cargo-nextest 0.9.143
capture.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@KuSh KuSh 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.

Round 1 — APPROVED, follow-ups filed

Claim: nextest's in-place annotation after passed ((1 slow), (1 slow, 1 flaky)) no longer zeroes the failed and skipped counts, so a failing run with a slow test stops reading as green.
Scope: accept. #3577 edits the same regex line (it captures \((\d+) slow\) after skipped, a position real nextest never prints it in); this lands first and #3577 moves its slow capture into the group added here.
Ran: real cargo-nextest 0.9.143 × 10 runs (all-pass slow, fail + slow pass, fail slow, slow + flaky, slow + flaky + fail under retries, timeout, retries-only fail, fail-fast cancel 1/3 tests run, plain fail, slow pass + slow fail) × develop merge-base / head / head merged on develop; exit codes identical on both sides; invariants: under the hook (cargo nextest run is not rewritten on either side, #2046), split streams (stderr empty on every row), every decision; savings 48% and 46% on the two failing slow runs vs 20% floor (CONTRIBUTING.md)
Pins: 1 decision (the annotation group after passed), 4 mutations, 1 survived the suite: narrowing \([^)]*\) to \(\d+ slow\) turns 2 passed (1 slow, 1 flaky), 1 failed, 4 skipped back into a green cargo nextest: 2 passed. Closed by the fixup below.
Matrix: executed this round; pin check: executed this round
CI @394b33731: all green; @99626ecdb: all green

Blocks merge (1, frozen at round 1) — closed by fixup

  1. src/cmds/rust/cargo_cmd.rs:636 — unpinned behaviour (combined annotation). Fixup 99626ec adds test_filter_cargo_nextest_combined_annotation_keeps_failed_and_skipped on a real 0.9.143 capture with retries; the \(\d+ slow\) mutation turns it red.

Filed as follow-ups

  • #4694 cargo nextest: timed-out and retried failures lose their details — pre-existing, outside this PR's claim; filed
  • Compile errors under rtk cargo nextest run print only the recall line — pre-existing; absorbed by #2317, comment added

Checked and correct — no need to re-verify

  • The issue's case (3 passed (1 slow), 1 failed, 3 skipped): develop prints cargo nextest: 3 passed, head prints the FAIL block with its panic and 3 passed, 1 failed, 3 skipped.
  • Slow pass + slow fail (1 passed (1 slow), 1 failed): same correction.
  • All-pass runs with (1 slow) and (1 slow, 1 flaky): still the one-line summary, now with the skipped count develop dropped.
  • Runs without an annotation, including a slow test that fails (nextest counts it under failed, no annotation): identical to develop apart from timings and test order.
  • Merged onto current develop: fmt, clippy (0 warnings) and the full suite pass.

Next

fixup 99626ec pushed, code-reviewed: adds one test and its real nextest capture, no code change — approving.
Rounds: 1. Threads: 0 open, 0 resolved this round.

@KuSh
KuSh merged commit 57fc55c into rtk-ai:develop Oct 20, 2026
14 checks passed
@rtk-release-bot rtk-release-bot Bot mentioned this pull request Oct 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working cargo rust testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cargo nextest: N failed / N skipped are dropped from the summary whenever a test is slow

2 participants