From 67ab2121c578a59c076269597d1f2fcf71af2f57 Mon Sep 17 00:00:00 2001 From: Matan Kushner Date: Tue, 9 Apr 2019 00:04:50 -0400 Subject: [PATCH] Add note and test regarding paths being physical --- src/modules/directory.rs | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/modules/directory.rs b/src/modules/directory.rs index edbdc1f6..f7a95584 100644 --- a/src/modules/directory.rs +++ b/src/modules/directory.rs @@ -20,10 +20,9 @@ pub fn segment(_: &ArgMatches) -> Segment { const DIR_TRUNCATION_LENGTH: usize = 3; const HOME_SYMBOL: &str = "~"; + // TODO: Currently gets the physical directory. Get the logical directory. let current_path = env::current_dir() - .expect("Unable to identify current directory") - .canonicalize() - .expect("Unable to canonicalize current directory"); + .expect("Unable to identify current directory"); let dir_string; if let Ok(repo) = git2::Repository::discover(¤t_path) { @@ -138,4 +137,17 @@ mod tests { let segment = segment(&args); assert_eq!(segment.value, "/"); } + + #[test] + fn do_not_canonicalize_paths() { + let args = App::new("starship") + .arg(Arg::with_name("status_code")) + .get_matches_from(vec!["starship", "0"]); + + let root_dir = Path::new("/var"); + env::set_current_dir(&root_dir).unwrap(); + + let segment = segment(&args); + assert_eq!(segment.value, "/var"); + } }