Skip to content

Commit 5258f7a

Browse files
committed
Assert that the corresponding suffixes are correct
+ Rename some variables for clarity. + Comment about the possibility of a future clangarm64/bin subdirectory to check under (the same) 64-bit program files.
1 parent dd1e5c8 commit 5258f7a

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

gix-path/src/env/git.rs

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -323,15 +323,15 @@ mod tests {
323323
.maybe_64bit
324324
.as_ref()
325325
.expect("It gives two paths only if one can be 64-bit.");
326-
let got_64bit = primary
326+
let suffix_64bit = primary
327327
.strip_prefix(prefix_64bit)
328328
.expect("It gives the 64-bit path and lists it first.");
329-
let x86 = secondary
329+
let suffix_x86 = secondary
330330
.strip_prefix(pf.x86.as_path())
331331
.expect("It gives the 32-bit path and lists it second.");
332332
Self {
333-
x86,
334-
maybe_64bit: Some(got_64bit),
333+
x86: suffix_x86,
334+
maybe_64bit: Some(suffix_64bit),
335335
}
336336
}
337337
[only] => {
@@ -344,13 +344,29 @@ mod tests {
344344
other => panic!("Got length {}, expected 1 or 2.", other.len()),
345345
}
346346
}
347+
348+
/// Assert that the suffixes are the common per-architecture Git install locations.
349+
fn validate(&self) {
350+
assert_eq!(self.x86, Path::new("Git/mingw32/bin"));
351+
352+
if let Some(suffix_64bit) = self.maybe_64bit {
353+
// When Git for Windows releases ARM64 builds, there will be another 64-bit suffix,
354+
// likely clangarm64. In that case, this and other assertions will need updating,
355+
// as there will be two separate paths to check under the same 64-bit program files
356+
// directory. (See the definition of ProgramFilesPaths::maybe_64bit for details.)
357+
assert_eq!(suffix_64bit, Path::new("Git/mingw64/bin"));
358+
}
359+
}
347360
}
348361

349362
#[test]
350363
#[cfg(windows)]
351364
fn alternative_locations() {
365+
// Obtain program files directory paths by other means and check that they seem correct.
352366
let pf = ProgramFilesPaths::obtain_envlessly().validate();
353-
let suffixes = GitBinSuffixes::assert_from(&pf);
367+
368+
// Check that `ALTERNATIVE_LOCATIONS` correspond to them, with the correct subdirectories.
369+
GitBinSuffixes::assert_from(&pf).validate();
354370

355371
// FIXME: Assert the other relationships between pf values and ALTERNATIVE_LOCATIONS contents!
356372
}

0 commit comments

Comments
 (0)