diff options
author | Melody Horn <melody@boringcactus.com> | 2021-04-14 18:37:43 -0600 |
---|---|---|
committer | Melody Horn <melody@boringcactus.com> | 2021-04-14 18:37:43 -0600 |
commit | 30295f5a8d34e0101cf3e17d8c786c8fdd795072 (patch) | |
tree | 84ca824b93b7b3d8e02d3cb98079a07d7eec87aa | |
parent | 42098a0a02e7e1770b0bf07f93aa37159945edb2 (diff) | |
download | makers-30295f5a8d34e0101cf3e17d8c786c8fdd795072.tar.gz makers-30295f5a8d34e0101cf3e17d8c786c8fdd795072.zip |
ensure trailing / in dir output
-rw-r--r-- | src/makefile/functions.rs | 12 |
1 files 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::<Vec<_>>(); Ok(words.join(" ")) } @@ -607,6 +608,13 @@ mod test { } #[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"); assert_eq!(result, "foo.c hacks"); |