Your browser sucks, JavaScript disabled! Gunnar's console needs JavaScript and WebAssembly. Git over SSH on port 2222 does not.

nordisk/edda

crates/nornir-build-thing/tests/no_default_links_no_git.rs

//! **Without its default features this crate links no git.**
//!
//! Runtime crates take nornir-build-thing for its types alone — korp-boot-bios
//! for `bios_patch`, which korp-installer's install path writes to disk. Through
//! that edge holger's appliance row linked nornir-git, gix and russh (146 crates
//! its `full` row did not have) for provenance it never captures. Provenance is
//! the `provenance` feature, in `default`, so the forge and every xtask that
//! keeps the defaults read HEAD exactly as before.

use std::path::Path;
use std::process::Command;

fn tree(args: &[&str]) -> String {
    let root = Path::new(env!("CARGO_MANIFEST_DIR"));
    let out = Command::new(env!("CARGO"))
        .current_dir(root)
        .args(["tree", "-p", "nornir-build-thing", "-e", "normal", "--prefix", "none"])
        .args(args)
        .output()
        .expect("cargo tree runs");
    assert!(out.status.success(), "cargo tree {args:?} failed:\n{}", String::from_utf8_lossy(&out.stderr));
    String::from_utf8_lossy(&out.stdout).into_owned()
}

fn links(tree: &str, krate: &str) -> bool {
    tree.lines().any(|l| l.split_whitespace().next() == Some(krate))
}

#[test]
fn no_default_features_links_no_git() {
    let bare = tree(&["--no-default-features"]);
    for krate in ["nornir-git", "gix", "russh"] {
        assert!(!links(&bare, krate), "--no-default-features must not link {krate}:\n{bare}");
    }
    // Non-vacuous: the defaults DO read git, so the probe can see it.
    let full = tree(&[]);
    assert!(links(&full, "nornir-git") && links(&full, "gix"), "the default build must link nornir-git + gix:\n{full}");
}