Skip to content

Commit de7c49f

Browse files
committed
Call fewer different things "suffixes"
+ Adjust wording of some related comments to further decrease confusion. + Put more details in the assert_from panic message when the list of paths has the wrong length, since we would want to know what's going on.
1 parent 4d98535 commit de7c49f

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

gix-path/src/env/git.rs

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -238,8 +238,10 @@ mod tests {
238238
}
239239

240240
#[cfg(windows)]
241-
fn ends_with_case_insensitive(text: &OsStr, suffix: &str) -> Option<bool> {
242-
Some(text.to_str()?.to_lowercase().ends_with(&suffix.to_lowercase()))
241+
fn ends_with_case_insensitive(full_text: &OsStr, literal_pattern: &str) -> Option<bool> {
242+
let folded_text = full_text.to_str()?.to_lowercase();
243+
let folded_pattern = literal_pattern.to_lowercase();
244+
Some(folded_text.ends_with(&folded_pattern))
243245
}
244246

245247
/// The common global program files paths on this system, by process and system architecture.
@@ -317,11 +319,11 @@ mod tests {
317319
self.x86.as_os_str(),
318320
"Our program files path is exactly identical to the 32-bit one.",
319321
);
320-
for arch_suffix in [" (x86)", " (Arm)"] {
321-
let has_arch_suffix = ends_with_case_insensitive(self.current.as_os_str(), arch_suffix)
322+
for trailing_arch in [" (x86)", " (Arm)"] {
323+
let is_adorned = ends_with_case_insensitive(self.current.as_os_str(), trailing_arch)
322324
.expect("Assume the test system's important directories are valid Unicode.");
323325
assert!(
324-
!has_arch_suffix,
326+
!is_adorned,
325327
"The 32-bit program files directory name on a 32-bit system mentions no architecture.",
326328
);
327329
}
@@ -369,14 +371,14 @@ mod tests {
369371
/// Paths relative to process architecture specific program files directories.
370372
#[cfg(windows)]
371373
#[derive(Clone, Debug)]
372-
struct GitBinSuffixes<'a> {
374+
struct RelativeGitBinPaths<'a> {
373375
x86: &'a Path,
374376
maybe_64bit: Option<&'a Path>,
375377
}
376378

377379
#[cfg(windows)]
378-
impl<'a> GitBinSuffixes<'a> {
379-
/// Assert that `locations` has the given prefixes, and extract the suffixes.
380+
impl<'a> RelativeGitBinPaths<'a> {
381+
/// Assert that `locations` has the given path prefixes, and extract the suffixes.
380382
fn assert_from(pf: &'a ProgramFilesPaths, locations: &'static [PathBuf]) -> Self {
381383
match locations {
382384
[primary, secondary] => {
@@ -402,11 +404,11 @@ mod tests {
402404
maybe_64bit: None,
403405
}
404406
}
405-
other => panic!("Got length {}, expected 1 or 2.", other.len()),
407+
other => panic!("{:?} has length {}, expected 1 or 2.", other, other.len()),
406408
}
407409
}
408410

409-
/// Assert that the suffixes are the common per-architecture Git install locations.
411+
/// Assert that the suffixes (relative subdirectories) are the common per-architecture Git install locations.
410412
fn assert_architectures(&self) {
411413
assert_eq!(self.x86, Path::new("Git/mingw32/bin"));
412414

@@ -428,7 +430,7 @@ mod tests {
428430

429431
// Check that `ALTERNATIVE_LOCATIONS` correspond to them, with the correct subdirectories.
430432
let locations = super::ALTERNATIVE_LOCATIONS.as_slice();
431-
GitBinSuffixes::assert_from(&pf, locations).assert_architectures();
433+
RelativeGitBinPaths::assert_from(&pf, locations).assert_architectures();
432434
}
433435

434436
#[test]

0 commit comments

Comments
 (0)