Repository navigation
fix(cargo): keep nextest failed/skipped counts when a test is slow - #4467
Conversation
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
📊 Automated PR Analysis
SummaryFixes 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
Linked issues: #4420 Analyzed automatically by wshm · This is an automated analysis, not a human review. |
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
left a comment
There was a problem hiding this comment.
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
src/cmds/rust/cargo_cmd.rs:636— unpinned behaviour (combined annotation). Fixup 99626ec addstest_filter_cargo_nextest_combined_annotation_keeps_failed_and_skippedon 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 runprint 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 printscargo nextest: 3 passed, head prints theFAILblock with its panic and3 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.
Summary
nextest puts its in-place annotation right after
passed(2 passed (1 slow), 1 failed, 1 skipped). The summary regex expectedfailedandskippedto come straight afterpassed, so once a test went slow both counts parsed as 0. Withfailed == 0the filter took its green branch and also dropped the collected failure blocks, so a failing run showed up ascargo nextest: 2 passed (1 binary, 2.503s).The fix adds an optional non-capturing
(?:\s+\([^)]*\))?group right afterpassed. 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, afterskipped. 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 afterpassedthat this PR adds.Fixes #4420
Test plan
test_filter_cargo_nextest_slow_annotation_keeps_failed_and_skippeduses the real 0.9.143 lineSummary [ 2.503s] 3 tests run: 2 passed (1 slow), 1 failed, 1 skippedinside a realistic run with a FAIL block and a SLOW line. It asserts2 passed, 1 failed, 1 skippedand that the failure header and stderr are kept. It failed before the fix withcargo nextest: 2 passed (1 binary, 2.503s), which is the exact output from the issue.test_filter_cargo_nextest_slow_annotation_all_passcovers an all-green run with(1 slow), which still renders the compact line.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 --checkcargo clippy --all-targets(no warnings)cargo test