use std::process::Command;
fn packaged_files() -> Vec<String> {
let output = Command::new(env!("CARGO"))
.args([
"package",
"--list",
"--allow-dirty",
"--offline",
"-p",
env!("CARGO_PKG_NAME"),
])
.current_dir(env!("CARGO_MANIFEST_DIR"))
.output()
.expect("cargo runs");
assert!(
output.status.success(),
"cargo package --list fails: {}",
String::from_utf8_lossy(&output.stderr)
);
String::from_utf8(output.stdout)
.expect("cargo lists paths as UTF-8")
.lines()
.map(|line| line.replace('\\', "/"))
.collect()
}
#[test]
fn the_package_leaves_the_test_fixtures_out() {
let files = packaged_files();
for needed in [
"Cargo.toml",
"src/lib.rs",
"src/compose.rs",
"assets/LiberationMono-Regular.ttf",
] {
assert!(
files.iter().any(|file| file == needed),
"the package carries {needed}: {files:?}"
);
}
let fixtures: Vec<&String> = files
.iter()
.filter(|file| file.starts_with("tests/fixtures/"))
.collect();
assert!(
fixtures.is_empty(),
"the package carries {} test fixtures, the first {:?}",
fixtures.len(),
fixtures.first()
);
}