|
| 1 | +#[test] |
| 2 | +fn exe_invocation() { |
| 3 | + let actual = gix_path::env::exe_invocation(); |
| 4 | + assert!( |
| 5 | + !actual.as_os_str().is_empty(), |
| 6 | + "it finds something as long as git is installed somewhere on the system (or a default location)" |
| 7 | + ); |
| 8 | +} |
| 9 | + |
| 10 | +#[test] |
| 11 | +fn login_shell() { |
| 12 | + // On CI, the $SHELL variable isn't necessarily set. Maybe other ways to get the login shell should be used then. |
| 13 | + if !gix_testtools::is_ci::cached() { |
| 14 | + assert!(gix_path::env::login_shell() |
| 15 | + .expect("There should always be the notion of a shell used by git") |
| 16 | + .exists()); |
| 17 | + } |
| 18 | +} |
| 19 | + |
| 20 | +#[test] |
| 21 | +fn installation_config() { |
| 22 | + assert_ne!( |
| 23 | + gix_path::env::installation_config().map(|p| p.components().count()), |
| 24 | + gix_path::env::installation_config_prefix().map(|p| p.components().count()), |
| 25 | + "the prefix is a bit shorter than the installation config path itself" |
| 26 | + ); |
| 27 | +} |
| 28 | + |
| 29 | +#[test] |
| 30 | +fn system_prefix() { |
| 31 | + assert_ne!( |
| 32 | + gix_path::env::system_prefix(), |
| 33 | + None, |
| 34 | + "git should be present when running tests" |
| 35 | + ); |
| 36 | +} |
| 37 | + |
| 38 | +#[test] |
| 39 | +fn home_dir() { |
| 40 | + assert_ne!( |
| 41 | + gix_path::env::home_dir(), |
| 42 | + None, |
| 43 | + "we find a home on every system these tests execute" |
| 44 | + ); |
| 45 | +} |
| 46 | + |
| 47 | +mod xdg_config { |
| 48 | + use std::ffi::OsStr; |
| 49 | + |
| 50 | + #[test] |
| 51 | + fn prefers_xdg_config_bases() { |
| 52 | + let actual = gix_path::env::xdg_config("test", &mut |n| { |
| 53 | + (n == OsStr::new("XDG_CONFIG_HOME")).then(|| "marker".into()) |
| 54 | + }) |
| 55 | + .expect("set"); |
| 56 | + #[cfg(unix)] |
| 57 | + assert_eq!(actual.to_str(), Some("marker/git/test")); |
| 58 | + #[cfg(windows)] |
| 59 | + assert_eq!(actual.to_str(), Some("marker\\git\\test")); |
| 60 | + } |
| 61 | + |
| 62 | + #[test] |
| 63 | + fn falls_back_to_home() { |
| 64 | + let actual = gix_path::env::xdg_config("test", &mut |n| (n == OsStr::new("HOME")).then(|| "marker".into())) |
| 65 | + .expect("set"); |
| 66 | + #[cfg(unix)] |
| 67 | + assert_eq!(actual.to_str(), Some("marker/.config/git/test")); |
| 68 | + #[cfg(windows)] |
| 69 | + assert_eq!(actual.to_str(), Some("marker\\.config\\git\\test")); |
| 70 | + } |
| 71 | +} |
0 commit comments