chore: keep test-env out of the default features - #443
Merged
Conversation
`test-env` gates the `updatehub-setup-mock-env` binary and the `updatehub::tests` helpers the integration tests drive the agent with. It was on by default, so anyone who follows the README and runs `cargo build --release` compiles 18 crates they will never run, `mockito` and its HTTP mock server among them, and pays for them on every build. Nobody should have to remember `--no-default-features` to get the plain agent. Turn the default feature set off and let the test targets ask for what they need: `crate::tests` and `crate::firmware::tests` now answer to `cfg(test)` as well, so the unit tests keep reaching them with no feature at all. The three integration test targets gain `required-features = ["test-env"]`. They call `updatehub::tests::TestEnvironment` and `mockito`, and cargo builds the library without `cfg(test)` for an integration test, so the feature is the only way in. `cargo test` skips them and `cargo test --all-features` runs them. `async-ctrlc` and `mockito` stay optional rather than move to dev-dependencies, because `src/setup_mock_env.rs` is a binary and cargo gives dev-dependencies to tests, examples and benches only. CI needs no change; every step already passes `--all-features`. The `Check build with the default features` step now covers the feature set users really get. The stripped binary loses only 8 KiB, as the linker already dropped what the agent never called. The build graph is where this is paid.
otavio
force-pushed
the
default-without-test-env
branch
from
August 19, 2026 20:00
07e84e7 to
b6239f1
Compare
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.
test-envgates theupdatehub-setup-mock-envbinary and theupdatehub::testshelpers the integration tests drive the agent with. It was on by default, so anyone who follows the README and runscargo build --releasecompiles 18 crates they will never run —mockitoand its HTTP mock server among them — and pays for them on every build. Nobody should have to remember--no-default-featuresto get the plain agent.The change
default = ["test-env"]becomesdefault = [].crate::testsandcrate::firmware::testsanswer tocfg(test)as well, so the unit tests keep reaching them with no feature at all.required-features = ["test-env"]. They callupdatehub::tests::TestEnvironmentandmockito, and cargo builds the library withoutcfg(test)for an integration test, so the feature is the only way in.cargo testskips them;cargo test --all-featuresruns them.async-ctrlcandmockitostay optional rather than move todev-dependencies, becausesrc/setup_mock_env.rsis a binary and cargo givesdev-dependenciesto tests, examples and benches only.Crates the default build no longer pulls
assert-json-diff,async-ctrlc,colored,ctrlc,getrandom,lock_api,mockito,nix,parking_lot,parking_lot_core,ppv-lite86,rand,rand_chacha,rand_core,scopeguard,serde_urlencoded,similar,zerocopy.The stripped binary loses only 8 KiB (4855400 → 4847208 bytes), because the linker already dropped what the agent never called. The build graph is where this is paid, along with the supply-chain surface of a production build.
CI
No change needed. Every step already passes
--all-features, so nothing loses coverage. TheCheck build with the default featuresstep now covers the feature set users really get.Verification
cargo check --locked --all --bins --examples --testscargo check --locked --all --bins --examples --tests --all-featurescargo clippy --locked --all-features --all --tests -- -D clippy::allcargo testcargo test --all --all-features --no-fail-fast