use std::process::Command;
#[test]
fn cargo_package_includes_stubs_directory() {
let manifest_path = concat!(env!("CARGO_MANIFEST_DIR"), "/Cargo.toml");
let output = Command::new(env!("CARGO"))
.args([
"package",
"--list",
"--manifest-path",
manifest_path,
"--allow-dirty",
"--no-verify",
])
.output()
.expect("running `cargo package --list` failed");
assert!(
output.status.success(),
"`cargo package --list` exited non-zero.\nstdout:\n{}\nstderr:\n{}",
String::from_utf8_lossy(&output.stdout),
String::from_utf8_lossy(&output.stderr),
);
let listed = String::from_utf8_lossy(&output.stdout);
let canary = "stubs/Core/Core.php";
assert!(
listed.lines().any(|line| line.trim() == canary),
"`cargo package --list` did not include `{canary}` — \
the published crate would ship without built-in stubs, \
repeating the 0.17.1 regression.\n\nFull listing:\n{listed}",
);
let stub_php_count = listed
.lines()
.filter(|line| line.starts_with("stubs/") && line.ends_with(".php"))
.count();
assert!(
stub_php_count >= 100,
"expected >=100 `stubs/**/*.php` entries in the package manifest, \
got {stub_php_count}. The directory is present but largely empty — \
either the move is partial or build.rs filters too aggressively.\n\n\
Full listing:\n{listed}"
);
}