Loading tools/pdl/src/test_utils.rs +9 −4 Original line number Diff line number Diff line Loading @@ -8,18 +8,23 @@ use tempfile::NamedTempFile; /// Search for a binary in `$PATH` or as a sibling to the current /// executable (typically the test binary). fn find_binary(name: &str) -> Option<std::path::PathBuf> { fn find_binary(name: &str) -> Result<std::path::PathBuf, String> { let mut current_exe = std::env::current_exe().unwrap(); current_exe.pop(); let paths = std::env::var_os("PATH").unwrap(); for mut path in std::iter::once(current_exe).chain(std::env::split_paths(&paths)) { for mut path in std::iter::once(current_exe.clone()).chain(std::env::split_paths(&paths)) { path.push(name); if path.exists() { return Some(path); return Ok(path); } } None Err(format!( "could not find '{}' in the directory of the binary ({}) or in $PATH ({})", name, current_exe.to_string_lossy(), paths.to_string_lossy(), )) } /// Parse a string fragment as a PDL file. Loading Loading
tools/pdl/src/test_utils.rs +9 −4 Original line number Diff line number Diff line Loading @@ -8,18 +8,23 @@ use tempfile::NamedTempFile; /// Search for a binary in `$PATH` or as a sibling to the current /// executable (typically the test binary). fn find_binary(name: &str) -> Option<std::path::PathBuf> { fn find_binary(name: &str) -> Result<std::path::PathBuf, String> { let mut current_exe = std::env::current_exe().unwrap(); current_exe.pop(); let paths = std::env::var_os("PATH").unwrap(); for mut path in std::iter::once(current_exe).chain(std::env::split_paths(&paths)) { for mut path in std::iter::once(current_exe.clone()).chain(std::env::split_paths(&paths)) { path.push(name); if path.exists() { return Some(path); return Ok(path); } } None Err(format!( "could not find '{}' in the directory of the binary ({}) or in $PATH ({})", name, current_exe.to_string_lossy(), paths.to_string_lossy(), )) } /// Parse a string fragment as a PDL file. Loading