Skip to content

chore: keep test-env out of the default features - #443

Merged
otavio merged 1 commit into
masterfrom
default-without-test-env
Aug 19, 2026
Merged

chore: keep test-env out of the default features#443
otavio merged 1 commit into
masterfrom
default-without-test-env

Conversation

@otavio

@otavio otavio commented Aug 19, 2026

Copy link
Copy Markdown
Member

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.

The change

  1. default = ["test-env"] becomes default = [].
  2. crate::tests and crate::firmware::tests answer to cfg(test) as well, so the unit tests keep reaching them with no feature at all.
  3. 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; 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.

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. The Check build with the default features step now covers the feature set users really get.

Verification

Command Result
cargo check --locked --all --bins --examples --tests clean
cargo check --locked --all --bins --examples --tests --all-features clean
cargo clippy --locked --all-features --all --tests -- -D clippy::all clean
cargo test 145 pass, 0 fail
cargo test --all --all-features --no-fail-fast 168 pass, 0 fail

`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
otavio force-pushed the default-without-test-env branch from 07e84e7 to b6239f1 Compare August 19, 2026 20:00
@otavio
otavio merged commit 405cb3d into master Aug 19, 2026
4 checks passed
@otavio
otavio deleted the default-without-test-env branch August 19, 2026 20:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant