Build a feature you never test#
Scenario: a renderer crate has a heavy gpu feature. It should be compiled to catch build breakage, but its tests need a GPU that CI doesn’t have. You want cargo fc build to include gpu, but cargo fc test to skip it.
[package]
name = "renderer"
version = "0.1.0"
edition = "2024"
[lib]
doctest = false
[features]
gpu = []
simd = []
# gpu is part of the matrix by default (build, check, clippy).
[package.metadata.cargo-fc]
[package.metadata.cargo-fc.subcommands.test]
# ...but never test the gpu combinations.
exclude_features = { add = ["gpu"] }
[workspace]cargo fc build varies both features — four combinations, including the gpu ones:
$ cargo fc --summary-only build Building [1/4] renderer ( features = [] ) Building [2/4] renderer ( features = [gpu] ) Building [3/4] renderer ( features = [gpu, simd] ) Building [4/4] renderer ( features = [simd] ) Finished 4 feature combinations for 1 package in 0.00s PASS renderer ( 0 errors, 0 warnings, features = [] ) PASS renderer ( 0 errors, 0 warnings, features = [gpu] ) PASS renderer ( 0 errors, 0 warnings, features = [gpu, simd] ) PASS renderer ( 0 errors, 0 warnings, features = [simd] )
cargo fc test applies the subcommands.test override and drops every combination containing gpu — two combinations:
$ cargo fc --summary-only test Testing [1/2] renderer ( features = [] ) running 0 tests test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s Testing [2/2] renderer ( features = [simd] ) running 0 tests test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s Finished 2 feature combinations for 1 package in 0.00s PASS renderer ( 0 errors, 0 warnings, features = [] ) PASS renderer ( 0 errors, 0 warnings, features = [simd] )
The override applies to test only; build, check, and clippy keep the full matrix. Built-in short aliases (t → test) and .cargo/config.toml aliases that resolve to test inherit it automatically.
Restrict a single command instead#
To make cargo fc test focus on one set while other commands keep the full matrix:
[package.metadata.cargo-fc.subcommands.test]
only_features = ["simd"]Command-specific on a specific target#
Compose target and command — this applies only when both match:
[package.metadata.cargo-fc.target.'cfg(target_os = "linux")'.subcommands.test]
exclude_features = { add = ["cuda"] }