chore(cargo, justfile): Stop building empty test binaries - #1189
Merged
Merged
Conversation
`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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
just testbuilds 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-targetsoverrides thetestflag 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 = falsehad 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 movingjp-gui,jp-serve-web, andjp-ticketinto 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-cirejects a#[cfg(test)]inside a binary that excludes itself from testing, andcargo shear --check-test-targetscovers libraries in both directions, now thatshear-cidenies warnings. Denying them also turned up an optional dependencyschematicdeclared and never used, now removed.The
nextestprofile 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.