use std::process::Command;
#[test]
fn test_excluded_files_not_in_package() {
let output = Command::new("cargo")
.args(["package", "--list", "--allow-dirty"])
.output()
.expect("Failed to run cargo package --list");
let stdout = String::from_utf8_lossy(&output.stdout);
let files: Vec<&str> = stdout.lines().collect();
for file in &files {
assert!(
!file.ends_with(".gif"),
"GIF file should be excluded from package: {file}"
);
}
for file in &files {
assert!(
!file.starts_with(".github/") && !file.starts_with(".gitea/"),
"CI workflow files should be excluded from package: {file}"
);
}
for file in &files {
assert!(
!file.starts_with("scripts/"),
"Scripts should be excluded from package: {file}"
);
}
for file in &files {
assert!(
!file.starts_with("examples/vhs/"),
"VHS files should be excluded from package: {file}"
);
}
for file in &files {
assert!(
*file != "justfile" && *file != "cliff.toml" && *file != "results.json",
"Build tool config should be excluded from package: {file}"
);
}
}
#[test]
fn test_package_file_count_reasonable() {
let output = Command::new("cargo")
.args(["package", "--list", "--allow-dirty"])
.output()
.expect("Failed to run cargo package --list");
let stdout = String::from_utf8_lossy(&output.stdout);
let file_count = stdout.lines().count();
assert!(
file_count <= 50,
"Package contains {file_count} files — expected ≤ 50. \
Check if new directories need to be added to the exclude list in Cargo.toml."
);
}
#[test]
fn test_no_heavy_banned_direct_dependencies() {
let cargo_toml = std::fs::read_to_string("Cargo.toml").expect("Failed to read Cargo.toml");
assert!(
!cargo_toml.contains("sled"),
"Cargo.toml should not depend on sled — use redb instead"
);
}
#[test]
fn test_no_aws_lc_sys_in_dependency_tree() {
let output = Command::new("cargo")
.args(["tree", "--prefix", "none", "--no-dedupe"])
.output()
.expect("Failed to run cargo tree");
let stdout = String::from_utf8_lossy(&output.stdout);
assert!(
!stdout.contains("aws-lc-sys"),
"Dependency tree should not contain aws-lc-sys — \
ensure reqwest uses ring instead of aws-lc-rs as the crypto provider"
);
}
#[test]
fn test_cargo_toml_has_exclude_patterns() {
let cargo_toml = std::fs::read_to_string("Cargo.toml").expect("Failed to read Cargo.toml");
let expected_patterns = ["examples/vhs/", "scripts/", ".gitea/", ".github/", "*.gif"];
for pattern in &expected_patterns {
assert!(
cargo_toml.contains(pattern),
"Cargo.toml exclude list is missing pattern: {pattern}"
);
}
}
#[test]
fn test_release_profile_optimized() {
let cargo_toml = std::fs::read_to_string("Cargo.toml").expect("Failed to read Cargo.toml");
assert!(
cargo_toml.contains("[profile.release]"),
"Cargo.toml should have a [profile.release] section"
);
assert!(
cargo_toml.contains("strip = true"),
"Release profile should strip symbols"
);
assert!(
cargo_toml.contains("lto = true"),
"Release profile should enable LTO"
);
}