aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMelody Horn <melody@boringcactus.com>2021-04-14 18:37:43 -0600
committerMelody Horn <melody@boringcactus.com>2021-04-14 18:37:43 -0600
commit30295f5a8d34e0101cf3e17d8c786c8fdd795072 (patch)
tree84ca824b93b7b3d8e02d3cb98079a07d7eec87aa
parent42098a0a02e7e1770b0bf07f93aa37159945edb2 (diff)
downloadmakers-30295f5a8d34e0101cf3e17d8c786c8fdd795072.tar.gz
makers-30295f5a8d34e0101cf3e17d8c786c8fdd795072.zip
ensure trailing / in dir output
-rw-r--r--src/makefile/functions.rs12
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");