Repository navigation
Core: compile testkits in every debug build instead of behind a feature - #1960
Merged
Merged
Conversation
Tests turned on other crates' testkit features through their dev-dependencies, so every crate under a test compiled one way for cargo test and another for cargo build, and Cargo kept both copies. The first cargo test after a cargo build, and the second of the two after every edit to a shared crate, recompiled all 41 workspace crates under gemstone. Testkits are now declared #[cfg(any(test, debug_assertions))] and the testkit features are gone, so debug builds and tests compile every crate the same way and share one set of artifacts. Release builds leave the testkits out, so the apps and the backend images carry no mock. just lint runs clippy a second time in release, where testkits do not exist, so production code that calls a mock fails it. core/skills/tests.md, core/skills/development-commands.md and docs/ARCHITECTURE.md describe the new rule. Measured on gemstone in a fresh target dir: the first cargo test after cargo build went from 40.4 s (41 crates) to 24.4 s (1 crate), the second command after an edit to primitives from 9.2-11.5 s to 4.3-5.2 s, and target/debug from 7.1 GB to 5.6 GB. The test list of every one of the 87 test binaries is identical to main's, both for the workspace run CI uses (5,193 tests) and with all features (5,576); just test passes 5,190 with 3 ignored; just lint in debug and release and just build-integration-tests pass.
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.
Why
Tests turned on other crates'
testkitfeatures through their dev-dependencies (about 140 manifest lines across 57 crates). A feature changes how a crate compiles, so every crate under a test was compiled twice: once forcargo buildand once forcargo test. Cargo keeps both copies. The firstcargo testafter acargo build, and the second of the two after every edit to a shared crate such asprimitives, recompiled all 41 workspace crates under gemstone.What changes
#[cfg(any(test, debug_assertions))](29 gates) and the 27testkitfeatures are gone. Debug builds and tests compile every crate the same way and share one set of artifacts.just lintruns clippy a second time in release, where testkits do not exist, so production code that calls a mock fails lint and Core CI.core/skills/tests.md,core/skills/development-commands.mdanddocs/ARCHITECTURE.md§ 10 describe the rule.Measured
gemstone, fresh target dir,
RUSTC_WRAPPERoff, same machine, nothing else running:cargo test -p gemstone --libaftercargo build -p gemstone --libcargo buildaftercargo test, after an edit toprimitivescargo testaftercargo build, after an edit toprimitivesprimitives, then test and build (both steps)target/debugsize after the runcargo build -p gemstone --libWith nothing edited, switching between build and test was already instant on main (0.3 s), so the gain shows after edits and in fresh worktrees. CI jobs do not alternate build and test, so CI time does not change; the release clippy pass adds to the lint job, which runs alongside the longer unit-test job.
Checks
--all-features(5,576).just testpasses (5,190 passed, 3 ignored).just lint(debug and release) andjust build-integration-testspass.Notes
The companion PR for
just test <crate>edits the same manifests'[dev-dependencies]; whichever lands second needs a one-line rebase in those files.