Skip to content
Snippets Groups Projects
Commit 56c2153b authored by Ian Jackson's avatar Ian Jackson :speech_balloon:
Browse files

Merge branch 'fix-expand-tilde-on-windows' into 'main'

Fix expand tilde and invalid path chars on windows

See merge request tpo/core/arti!274
parents 801d5c8d 206714f2
No related branches found
No related tags found
No related merge requests found
......@@ -194,7 +194,6 @@ mod test {
assert_eq!(p.path().unwrap().to_str(), Some("/usr/local/foo"));
}
// FIXME: Add test for windows
#[cfg(not(target_family = "windows"))]
#[test]
fn expand_home() {
......@@ -209,7 +208,20 @@ mod test {
assert_eq!(p.path().unwrap().to_str(), expected.to_str());
}
// FIXME: Add test for windows
#[cfg(target_family = "windows")]
#[test]
fn expand_home() {
let p = CfgPath::new("~\\.arti\\config".to_string());
assert_eq!(p.to_string(), "~\\.arti\\config".to_string());
let expected = dirs::home_dir().unwrap().join(".arti\\config");
assert_eq!(p.path().unwrap().to_str(), expected.to_str());
let p = CfgPath::new("${USER_HOME}\\.arti\\config".to_string());
assert_eq!(p.to_string(), "${USER_HOME}\\.arti\\config".to_string());
assert_eq!(p.path().unwrap().to_str(), expected.to_str());
}
#[cfg(not(target_family = "windows"))]
#[test]
fn expand_cache() {
......@@ -220,6 +232,16 @@ mod test {
assert_eq!(p.path().unwrap().to_str(), expected.to_str());
}
#[cfg(target_family = "windows")]
#[test]
fn expand_cache() {
let p = CfgPath::new("${ARTI_CACHE}\\example".to_string());
assert_eq!(p.to_string(), "${ARTI_CACHE}\\example".to_string());
let expected = project_dirs().unwrap().cache_dir().join("example");
assert_eq!(p.path().unwrap().to_str(), expected.to_str());
}
#[test]
fn expand_bogus() {
let p = CfgPath::new("${ARTI_WOMBAT}/example".to_string());
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment