pub use crate::{
executable_file_name as file_name,
executable_sibling_of_current_image as sibling_of_current_image, EXECUTABLE_EXTENSION,
};
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn file_name_applies_the_host_executable_extension() {
let named = file_name("running-process-daemon");
match EXECUTABLE_EXTENSION {
Some(extension) => {
assert_eq!(named, format!("running-process-daemon.{extension}"));
assert!(std::path::Path::new(&named).extension().is_some());
}
None => assert_eq!(named, "running-process-daemon"),
}
}
#[test]
fn the_running_image_is_found_beside_itself() {
let current = std::env::current_exe().expect("current image");
let bare = current
.file_stem()
.expect("image stem")
.to_string_lossy()
.into_owned();
assert_eq!(sibling_of_current_image(&bare).as_deref(), Some(&*current));
}
#[test]
fn an_absent_sibling_is_none_not_a_missing_path() {
assert!(sibling_of_current_image("rp-no-such-sibling-program").is_none());
}
}