#[macro_export]
macro_rules! get_test_bin {
($x:expr) => {
{
let path_str = env!(concat!("CARGO_BIN_EXE_", $x));
std::process::Command::new(path_str)
}
};
}
#[deprecated(since = "0.5.0", note = "please use `get_test_bin!` macro instead")]
pub fn get_test_bin(bin_name: &str) -> std::process::Command {
let mut path = get_test_bin_dir();
path.push(bin_name);
path.set_extension(std::env::consts::EXE_EXTENSION);
if !path.exists() {
for (key, value) in std::env::vars() {
println!("{key}: {value}");
}
let path: &'static str = env!("PATH");
println!("the $PATH variable at the time of compiling was: {path}");
let build_dir = std::env::var("CARGO_BIN_EXE_test_bin").unwrap();
panic!("Environment variable is {}", build_dir);
}
assert!(path.exists());
std::process::Command::new(path.into_os_string())
}
fn get_test_bin_dir() -> std::path::PathBuf {
let current_exe =
std::env::current_exe().expect("Failed to get the path of the integration test binary");
let current_dir = current_exe
.parent()
.expect("Failed to get the directory of the integration test binary");
let test_bin_dir = current_dir
.parent()
.expect("Failed to get the binary folder");
test_bin_dir.to_owned()
}