Skip to content

chore(cargo, justfile): Stop building empty test binaries - #1189

Merged
JeanMertz merged 1 commit into
mainfrom
reduce-test-binaries
Sep 22, 2026
Merged

JeanMertz merged 1 commit into
mainfrom
reduce-test-binaries

Conversation

@JeanMertz

Copy link
Copy Markdown
Collaborator

just test builds and lists 52 test binaries instead of 74, running the same 6444 tests. Every binary that went away held no tests at all, and nextest runs each one it builds to enumerate its contents, so an empty binary cost a link and a process spawn for nothing.

They were there because --all-targets overrides the test flag a manifest sets (rust-lang/cargo#8338), so every executable was built as a test harness regardless, and the six libraries already carrying [lib] test = false had their opt-out ignored along with them. The test recipes pass no target selection now, which is the only mode that honours the flag and still picks up new crates, new integration tests, and examples as they appear.

All 13 binaries in the workspace now set test = false, which meant moving jp-gui, jp-serve-web, and jp-ticket into libraries with their executables reduced to a shell, so the 103 tests that lived in those binary crates keep running. Two checks catch a test that would otherwise silently not run: lint-ci rejects a #[cfg(test)] inside a binary that excludes itself from testing, and
cargo shear --check-test-targets covers libraries in both directions, now that shear-ci denies warnings. Denying them also turned up an optional dependency schematic declared and never used, now removed.

The nextest profile builds with line tables rather than full debug info. Backtraces keep their file and line numbers; a debugger attached to a test binary loses its locals. Override the profile when stepping through one.

`just test` builds and lists 52 test binaries instead of 74, running
the same 6444 tests. Every binary that went away held no tests at all,
and nextest runs each one it builds to enumerate its contents, so an
empty binary cost a link and a process spawn for nothing.

They were there because `--all-targets` overrides the `test` flag a
manifest sets (rust-lang/cargo#8338), so every executable was built as a
test harness regardless, and the six libraries already carrying
`[lib] test = false` had their opt-out ignored along with them. The test
recipes pass no target selection now, which is the only mode that
honours the flag and still picks up new crates, new integration tests,
and examples as they appear.

All 13 binaries in the workspace now set `test = false`, which meant
moving `jp-gui`, `jp-serve-web`, and `jp-ticket` into libraries with
their executables reduced to a shell, so the 103 tests that lived in
those binary crates keep running. Two checks catch a test that would
otherwise silently not run: `lint-ci` rejects a `#[cfg(test)]` inside a
binary that excludes itself from testing, and
`cargo shear --check-test-targets` covers libraries in both directions,
now that `shear-ci` denies warnings. Denying them also turned up an
optional dependency `schematic` declared and never used, now removed.

The `nextest` profile builds with line tables rather than full debug
info. Backtraces keep their file and line numbers; a debugger attached
to a test binary loses its locals. Override the profile when stepping
through one.

Signed-off-by: Jean Mertz <git@jeanmertz.com>
@JeanMertz
JeanMertz merged commit 2017653 into main Sep 22, 2026
21 checks passed
@JeanMertz
JeanMertz deleted the reduce-test-binaries branch September 22, 2026 13:27
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.

1 participant