#![cfg(feature = "nix")]
use std::path::PathBuf;
use std::process::Command;
#[test]
fn binary_is_statically_linked() {
let binary = nix_build_innisfree();
let output = Command::new("ldd")
.arg(&binary)
.output()
.expect("failed to run `ldd`; ensure glibc is on PATH");
let report = format!(
"{}{}",
String::from_utf8_lossy(&output.stdout),
String::from_utf8_lossy(&output.stderr),
);
assert!(
report.contains("statically linked"),
"expected `ldd {}` to report 'statically linked'; got:\n{report}",
binary.display(),
);
}
fn nix_build_innisfree() -> PathBuf {
let output = Command::new("nix")
.args(["build", ".#innisfree", "--no-link", "--print-out-paths"])
.output()
.expect("failed to invoke `nix build`; ensure nix is on PATH");
assert!(
output.status.success(),
"`nix build .#innisfree` failed:\n{}",
String::from_utf8_lossy(&output.stderr),
);
let store_path =
String::from_utf8(output.stdout).expect("`nix build` output is not valid UTF-8");
PathBuf::from(store_path.trim())
.join("bin")
.join("innisfree")
}