use std::path::Path;#[test]fn exe_invocation() { let actual = gix_path::env::exe_invocation(); assert!( !actual.as_os_str().is_empty(), "it finds something as long as git is installed somewhere on the system (or a default location)" );}#[test]fn shell() { assert!( Path::new(gix_path::env::shell()).exists(), "On CI and on Unix we expect a usable path to the shell that exists on disk" );}#[test]fn shell_absolute() { assert!( Path::new(gix_path::env::shell()).is_absolute(), "On CI and on Unix we currently expect the path to the shell always to be absolute" );}#[test]fn shell_unix_path() { let shell = gix_path::env::shell() .to_str() .expect("This test depends on the shell path being valid Unicode"); assert!( !shell.contains('\\'), "The path to the shell should have no backslashes, barring strange `GIT_EXEC_PATH` values" );}#[test]fn installation_config() { assert_ne!( gix_path::env::installation_config().map(|p| p.components().count()), gix_path::env::installation_config_prefix().map(|p| p.components().count()), "the prefix is a bit shorter than the installation config path itself" );}#[test]fn core_dir() { assert!( gix_path::env::core_dir() .expect("Git is always in PATH when we run tests") .is_dir(), "The core directory is a valid directory" );}#[test]fn system_prefix() { assert_ne!( gix_path::env::system_prefix(), None, "git should be present when running tests" );}#[test]fn home_dir() { assert_ne!( gix_path::env::home_dir(), None, "we find a home on every system these tests execute" );}mod xdg_config { use std::ffi::OsStr; #[test] fn prefers_xdg_config_bases() { let actual = gix_path::env::xdg_config("test", &mut |n| { (n == OsStr::new("XDG_CONFIG_HOME")).then(|| "marker".into()) }) .expect("set"); #[cfg(unix)] assert_eq!(actual.to_str(), Some("marker/git/test")); #[cfg(windows)] assert_eq!(actual.to_str(), Some(r"marker\git\test")); } #[test] fn falls_back_to_home() { let actual = gix_path::env::xdg_config("test", &mut |n| (n == OsStr::new("HOME")).then(|| "marker".into())) .expect("set"); #[cfg(unix)] assert_eq!(actual.to_str(), Some("marker/.config/git/test")); #[cfg(windows)] assert_eq!(actual.to_str(), Some(r"marker\.config\git\test")); }}
use std::path::Path;
#[test]
fn exe_invocation() {
let actual = gix_path::env::exe_invocation();
assert!(
!actual.as_os_str().is_empty(),
"it finds something as long as git is installed somewhere on the system (or a default location)"
);
}
#[test]
fn shell() {
assert!(
Path::new(gix_path::env::shell()).exists(),
"On CI and on Unix we expect a usable path to the shell that exists on disk"
);
}
#[test]
fn shell_absolute() {
assert!(
Path::new(gix_path::env::shell()).is_absolute(),
"On CI and on Unix we currently expect the path to the shell always to be absolute"
);
}
#[test]
fn shell_unix_path() {
let shell = gix_path::env::shell()
.to_str()
.expect("This test depends on the shell path being valid Unicode");
assert!(
!shell.contains('\\'),
"The path to the shell should have no backslashes, barring strange `GIT_EXEC_PATH` values"
);
}
#[test]
fn installation_config() {
assert_ne!(
gix_path::env::installation_config().map(|p| p.components().count()),
gix_path::env::installation_config_prefix().map(|p| p.components().count()),
"the prefix is a bit shorter than the installation config path itself"
);
}
#[test]
fn core_dir() {
assert!(
gix_path::env::core_dir()
.expect("Git is always in PATH when we run tests")
.is_dir(),
"The core directory is a valid directory"
);
}
#[test]
fn system_prefix() {
assert_ne!(
gix_path::env::system_prefix(),
None,
"git should be present when running tests"
);
}
#[test]
fn home_dir() {
assert_ne!(
gix_path::env::home_dir(),
None,
"we find a home on every system these tests execute"
);
}
mod xdg_config {
use std::ffi::OsStr;
#[test]
fn prefers_xdg_config_bases() {
let actual = gix_path::env::xdg_config("test", &mut |n| {
(n == OsStr::new("XDG_CONFIG_HOME")).then(|| "marker".into())
})
.expect("set");
#[cfg(unix)]
assert_eq!(actual.to_str(), Some("marker/git/test"));
#[cfg(windows)]
assert_eq!(actual.to_str(), Some(r"marker\git\test"));
}
#[test]
fn falls_back_to_home() {
let actual = gix_path::env::xdg_config("test", &mut |n| (n == OsStr::new("HOME")).then(|| "marker".into()))
.expect("set");
#[cfg(unix)]
assert_eq!(actual.to_str(), Some("marker/.config/git/test"));
#[cfg(windows)]
assert_eq!(actual.to_str(), Some(r"marker\.config\git\test"));
}
}