Skip to content

tests: run with cargo-nextest and in parallel - #3077

Merged
sylvestre merged 9 commits into
mozilla:mainfrom
loganrosen:loganrosen-switch-tests-to-nextest
Dec 2, 2026
Merged

sylvestre merged 9 commits into
mozilla:mainfrom
loganrosen:loganrosen-switch-tests-to-nextest

Conversation

@loganrosen

@loganrosen loganrosen commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Switch the CI test job from cargo test to cargo-nextest, and make the integration tests safe to run in parallel.

Why: nextest runs each test in its own process, so a test that leaks env vars, global state or a panic can't affect the next one. It also gives clearer failure output and flags slow tests, which makes intermittent CI failures easier to pin down.

The integration tests all used the default server port and shared tests/test-crate, so they could only run one at a time. Each test thread now gets its own server address (a Unix socket in a tempdir, or a reserved free port on Windows), and SccacheTest copies test-crate into its tempdir. That lets #[serial] come off system, sccache_args, sccache_cargo, cache_hit_rate and logging. The dist tests used fixed scheduler and server ports with host networking; each dist system now reserves its own ports, so those run in parallel too and the dist-tests job went from ~730s on main to ~365s. No nextest test groups are needed. The #[serial] tests in src/ only guard env vars, so they stay for plain cargo test and nextest's process isolation covers them. Locally the nextest run went from about 83s to 35s.

nextest is downloaded as a pinned prebuilt binary from get.nexte.st (a third-party install action isn't on the org allowlist). LLVM_PROFILE_FILE had %p, so every instrumented process (each sccache client and server the tests start, and now each test too) wrote its own profraw file, and with nextest grcov took about twice as long as on main. It now uses only %8m, so processes merge into a small pool of files. The coverage total is unchanged (80.7%), and each of the two grcov steps dropped from ~45s on main to ~10s.

CI never ran doctests (--lib --bins --tests), so there's no separate doctest step. AGENTS.md is updated to match.

I tested locally on macOS only, on stable and 1.91.0.

@codecov-commenter

codecov-commenter commented Nov 28, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.00000% with 12 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.71%. Comparing base (b49981f) to head (a0ed4e4).

Files with missing lines Patch % Lines
tests/helpers/mod.rs 71.42% 8 Missing ⚠️
tests/helpers/port_reservation.rs 84.21% 3 Missing ⚠️
tests/harness/mod.rs 95.45% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3077      +/-   ##
==========================================
+ Coverage   80.69%   80.71%   +0.01%     
==========================================
  Files          78       80       +2     
  Lines       48640    48756     +116     
==========================================
+ Hits        39252    39352     +100     
- Misses       9388     9404      +16     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@loganrosen loganrosen changed the title ci: run tests with cargo-nextest tests: run with cargo-nextest and in parallel Nov 28, 2026
@loganrosen
loganrosen force-pushed the loganrosen-switch-tests-to-nextest branch from b7cf91e to 05bd4a5 Compare November 29, 2026 01:50
@loganrosen
loganrosen marked this pull request as ready for review November 29, 2026 01:50
Comment thread .config/nextest.toml Resolved
Comment thread tests/helpers/mod.rs Resolved
Comment thread .github/workflows/ci.yml Resolved
Comment thread AGENTS.md Resolved
Comment thread tests/helpers/port_reservation.rs Resolved
loganrosen and others added 6 commits November 29, 2026 11:59
Integration tests that start or query a server used the default address
and built the shared tests/test-crate, so they were marked #[serial] and,
under nextest, put in a single-threaded test group. Point every test at a
server address private to its thread (a Unix socket in a tempdir, or a
reserved free port on Windows), copy test-crate into each SccacheTest's
tempdir, and stop any server left on that address when the test ends.
The tests now run in parallel; only the dist tests stay grouped.

Co-authored-by: Copilot App <[email protected]>
With nextest every test is its own process, so %p produced hundreds of
profraw files and doubled the grcov step. %8m alone merges online into a
small pool per binary.

Co-authored-by: Copilot App <[email protected]>
Each DistSystem now reserves its own scheduler and server ports instead of
using 10500 and 12345, so the dist tests no longer need a serial test group.
A port released after probing can be handed out again right away, so the
port is also claimed with a lock on a file in a shared temp directory,
held until the dist system is torn down. The Windows client address uses
the same helper.

Co-authored-by: Copilot App <[email protected]>
@loganrosen
loganrosen force-pushed the loganrosen-switch-tests-to-nextest branch from 150bd00 to 590a1ce Compare November 29, 2026 17:01
loganrosen and others added 2 commits November 29, 2026 12:19
Verify the nextest archive's sha256, share the test-crate copy between
SccacheTest and build_checkout, and shorten the nextest notes.

Co-authored-by: Copilot App <[email protected]>
@loganrosen
loganrosen force-pushed the loganrosen-switch-tests-to-nextest branch from 590a1ce to f7c7b5f Compare November 29, 2026 17:19
@loganrosen
loganrosen requested a review from sylvestre November 29, 2026 17:54
Comment thread tests/helpers/mod.rs Resolved
@loganrosen
loganrosen requested a review from sylvestre November 29, 2026 18:29
@sylvestre
sylvestre merged commit 75ef6fa into mozilla:main Dec 2, 2026
51 checks passed
@sylvestre

Copy link
Copy Markdown
Collaborator

Thanks for your PR

art-shen added a commit to art-shen/sccache that referenced this pull request Dec 2, 2026
…port

A fixed port can clash with another sccache on the machine. Each test already has its own server socket since mozilla#3077, but the server `SccacheTest` starts can still be shutting down when the first build runs; the build then reaches it instead of starting one, and the test passed without the fix. A socket no server has used avoids both. Without the fix the test fails with "Failed to create temp dir".
sylvestre pushed a commit that referenced this pull request Dec 3, 2026
cargo clippy --all-targets fails on main because tests/sccache_args.rs
no longer compiles: the server connection failure tests from 08f94c4
still used SCCACHE_BIN and #[serial], whose imports were removed by
#3077.

Use sccache_command() and drop #[serial] like the rest of the file;
these tests use their own tempdir and socket path, so they don't need to
run serially.
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.

3 participants