History

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.

Eliah Kagan committed 2 years ago

Commit 5258f7a1 parent dd1e5c81 file · +21 −5Browse files

Unified · Split

gix-path/src/env/git.rs+21−5
@@ -323,15 +323,15 @@ mod tests { · 322 unmodified lines
323 .maybe_64bit323 .maybe_64bit
324 .as_ref()324 .as_ref()
325 .expect("It gives two paths only if one can be 64-bit.");325 .expect("It gives two paths only if one can be 64-bit.");
326 let got_64bit = primary326 let suffix_64bit = primary
327 .strip_prefix(prefix_64bit)327 .strip_prefix(prefix_64bit)
328 .expect("It gives the 64-bit path and lists it first.");328 .expect("It gives the 64-bit path and lists it first.");
329 let x86 = secondary329 let suffix_x86 = secondary
330 .strip_prefix(pf.x86.as_path())330 .strip_prefix(pf.x86.as_path())
331 .expect("It gives the 32-bit path and lists it second.");331 .expect("It gives the 32-bit path and lists it second.");
332 Self {332 Self {
333 x86,333 x86: suffix_x86,
334 maybe_64bit: Some(got_64bit),334 maybe_64bit: Some(suffix_64bit),
335 }335 }
336 }336 }
337 [only] => {337 [only] => {
@@ -344,13 +344,29 @@ mod tests { · 6 unmodified lines
344 other => panic!("Got length {}, expected 1 or 2.", other.len()),344 other => panic!("Got length {}, expected 1 or 2.", other.len()),
345 }345 }
346 }346 }
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 }
347 }360 }
348 361
349 #[test]362 #[test]
350 #[cfg(windows)]363 #[cfg(windows)]
351 fn alternative_locations() {364 fn alternative_locations() {
365 // Obtain program files directory paths by other means and check that they seem correct.
352 let pf = ProgramFilesPaths::obtain_envlessly().validate();366 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();
354 370
355 // FIXME: Assert the other relationships between pf values and ALTERNATIVE_LOCATIONS contents!371 // FIXME: Assert the other relationships between pf values and ALTERNATIVE_LOCATIONS contents!
356 }372 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t