use std::process::Command;
fn cargo_tree(args: &[&str]) -> String {
let cargo = std::env::var("CARGO").unwrap_or_else(|_| "cargo".into());
let manifest = concat!(env!("CARGO_MANIFEST_DIR"), "/Cargo.toml");
let mut cmd = Command::new(cargo);
cmd.args([
"tree",
"--locked",
"--manifest-path",
manifest,
"-p",
"vcs-watch",
]);
cmd.args(args);
let out = cmd
.output()
.unwrap_or_else(|e| panic!("failed to run `cargo tree {}`: {e}", args.join(" ")));
assert!(
out.status.success(),
"`cargo tree {}` failed:\n{}",
args.join(" "),
String::from_utf8_lossy(&out.stderr)
);
String::from_utf8_lossy(&out.stdout).into_owned()
}
#[test]
#[ignore = "requires cargo on PATH; run with -- --ignored"]
fn minimal_build_has_no_direct_optional_deps() {
let direct = cargo_tree(&["--no-default-features", "-e", "normal", "--depth", "1"]);
assert!(
!direct.contains("tracing"),
"minimal build must not take `tracing` as a direct dep:\n{direct}"
);
assert!(
!direct.contains("futures-core"),
"minimal build must not take `futures-core` as a direct dep:\n{direct}"
);
}
#[test]
#[ignore = "requires cargo on PATH; run with -- --ignored"]
fn tracing_feature_forwards_to_vcs_core() {
let inverted = cargo_tree(&["--features", "tracing", "-e", "normal", "-i", "tracing"]);
assert!(
inverted.contains("vcs-core"),
"the `tracing` feature must forward to `vcs-core/tracing` (its reverse \
dependency tree should include vcs-core), got:\n{inverted}"
);
}
#[test]
#[ignore = "requires cargo on PATH; run with -- --ignored"]
fn stream_feature_adds_direct_futures_core() {
let direct = cargo_tree(&["--features", "stream", "-e", "normal", "--depth", "1"]);
assert!(
direct.contains("futures-core"),
"the `stream` feature must take `futures-core` as a direct dep:\n{direct}"
);
}