Skip to content

ci(affected): don't fail Windows job on empty test selection - #2839

Merged
max-sixty merged 1 commit into
mainfrom
cargo-affected-windows
May 20, 2026
Merged

max-sixty merged 1 commit into
mainfrom
cargo-affected-windows

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

Problem

The advisory affected tests (windows, advisory) job in ci failed on every recent PR — Linux and macOS passed on the same runs. Two distinct Windows-only failure modes.

Mode 1 — os error 206 (The filename or extension is too long). cargo-affected passed its cargo nextest test-filter list as inline -E arguments; with a large affected set the command line overflowed Windows' ~32 KB CreateProcess cap. Already fixed upstream in cargo-affected (#37 — selection now travels via a --config-file). This job installs cargo-affected unpinned from the default branch, so it self-healed once that landed — no change needed here.

Mode 2 — error: no tests to run → exit 1. This is what this PR fixes. The repo has tests attributed #[cfg_attr(windows, ignore)]. On Windows they compile into the test binary but are skipped at run time. cargo affected collect gathers coverage via cargo nextest run, which skips ignored tests — so those tests never earn coverage rows. cargo-affected's "new test" detection diffs cargo nextest list (lists ignored tests) against the coverage DB, so it re-flags them as new and selects them on every Windows run. cargo nextest run then skips them as ignored too — zero tests execute, and nextest's default --no-tests behavior (auto → fail) makes that exit 4. When a PR's diff overlaps no recorded coverage, the whole selection collapses to just these phantom tests and the job fails.

Fix

Set NEXTEST_NO_TESTS=warn on the 🎯 Run affected tests step. An empty affected selection is a legitimate outcome — a diff genuinely can touch nothing with recorded coverage — so it should pass, not fail. warn exits 0 while leaving a breadcrumb in the log, keeping the calibration signal honest. It governs only the zero-selection outcome: a real test failure still exits non-zero and still fails the job.

The env-var form (vs. a CLI passthrough) doesn't depend on cargo-affected forwarding trailing args, and cargo nextest list — which has no --no-tests arg — silently ignores it.

Follow-up (not in this PR)

Two cargo-affected bugs worth filing upstream: (1) tests that nextest run always skips can never earn coverage and are flagged new forever; (2) nextest list runs without the build features that nextest run uses, so new-test detection enumerates a different test set than the run.

The advisory `affected tests (windows)` job failed on every PR whose diff overlapped no recorded coverage. On Windows the cargo-affected selection always carries the `#[cfg_attr(windows, ignore)]` tests: `collect` runs the suite through `nextest run`, which skips ignored tests, so they never earn coverage rows and get re-flagged `new` on every run. `nextest run` then skips them as ignored too — zero tests execute, and nextest's default `--no-tests` behavior treats that as exit 4.

Set `NEXTEST_NO_TESTS=warn` so an empty selection exits 0 with a log breadcrumb. An empty affected selection is a legitimate outcome — a diff can touch nothing with recorded coverage.

The separate `os error 206` failure mode (a long nextest command line overflowing the Windows ~32 KB limit) was fixed upstream in cargo-affected and needs no change here.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@max-sixty
max-sixty merged commit af63c9c into main May 20, 2026
35 checks passed
@max-sixty
max-sixty deleted the cargo-affected-windows branch May 20, 2026 18:16
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.

2 participants