pub fn binary() -> std::path::PathBuf {
for var in ["CARGO_BIN_EXE_rust-llm-tidy", "CARGO_BIN_EXE_rust_llm_tidy"] {
if let Some(path) = std::env::var_os(var) {
return std::path::PathBuf::from(path);
}
}
let mut dir = std::env::current_exe()
.expect("current_exe must resolve")
.parent()
.expect("current_exe must have a parent")
.to_path_buf();
loop {
for bin in ["rust-llm-tidy", "rust-llm-tidy.exe"] {
let candidate = dir.join(bin);
if candidate.is_file() {
return candidate;
}
}
if !dir.pop() {
break;
}
}
panic!("could not locate the rust-llm-tidy binary next to the test executable");
}