From 30295f5a8d34e0101cf3e17d8c786c8fdd795072 Mon Sep 17 00:00:00 2001 From: Melody Horn Date: Wed, 14 Apr 2021 18:37:43 -0600 Subject: ensure trailing / in dir output --- src/makefile/functions.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/makefile/functions.rs b/src/makefile/functions.rs index 295e50f..a78d582 100644 --- a/src/makefile/functions.rs +++ b/src/makefile/functions.rs @@ -287,7 +287,7 @@ mod file_name { use std::env; use std::ffi::OsStr; use std::fs; - use std::path::Path; + use std::path::{Path, MAIN_SEPARATOR}; use eyre::WrapErr; @@ -302,8 +302,9 @@ mod file_name { .parent() .and_then(Path::to_str) .filter(|x| !x.is_empty()) - .unwrap_or("./") + .unwrap_or(".") }) + .map(|x| format!("{}{}", x, MAIN_SEPARATOR)) .collect::>(); Ok(words.join(" ")) } @@ -606,6 +607,13 @@ mod test { Ok(()) } + #[test] + fn dir() -> R { + let result = call!(dir "src/foo.c hacks"); + assert_eq!(result, format!("src{0} .{0}", std::path::MAIN_SEPARATOR)); + Ok(()) + } + #[test] fn notdir() -> R { let result = call!(notdir "src/foo.c hacks"); -- cgit v1.2.3