vdev/commands/check/
component_features.rs

1use anyhow::Result;
2
3use crate::{app, utils::cargo::CargoToml};
4
5/// Check that all component features are set up properly
6#[derive(clap::Args, Debug)]
7#[command()]
8pub struct Cli {}
9
10impl Cli {
11    pub fn exec(self) -> Result<()> {
12        app::set_repo_dir()?;
13
14        let features = extract_features()?;
15        let feature_list = features.join(",");
16
17        // cargo-hack will check each feature individually with --no-default-features.
18        app::exec(
19            "cargo",
20            [
21                "hack",
22                "check",
23                "--tests",
24                "--bin",
25                "vector",
26                "--each-feature",
27                "--include-features",
28                &feature_list,
29            ],
30            true,
31        )
32    }
33}
34
35// Exclude default feature - already tested separately and is a cargo convention
36const EXCLUDED_DEFAULTS: &[&str] = &["default"];
37
38// Exclude meta-features - aggregate features that enable multiple components together.
39// Testing these would check all features at once, not in isolation
40const EXCLUDED_META_FEATURES: &[&str] = &[
41    "all-integration-tests",
42    "all-e2e-tests",
43    "vector-api-tests",
44    "vector-unit-test-tests",
45];
46
47fn extract_features() -> Result<Vec<String>> {
48    Ok(CargoToml::load()?
49        .features
50        .into_keys()
51        .filter(|feature| {
52            // Exclude utility features - internal helpers not meant to be enabled standalone
53            !feature.contains("-utils")
54                && !EXCLUDED_DEFAULTS.contains(&feature.as_str())
55                && !EXCLUDED_META_FEATURES.contains(&feature.as_str())
56        })
57        .collect())
58}