test(git): compare repo roots in one spelling so Windows passes (#1013)

canonicalize answers \\?\C:\... on Windows while git prints C:/...; the
production path already folds the first into the local spelling in
probe_repo, only the test compared them raw.
This commit is contained in:
l0ng-ai
2026-09-29 17:34:48 +08:00
committed by GitHub
parent 12ec0c92a9
commit eec9350ff8
+8 -3
View File
@@ -92,7 +92,7 @@ fn branch_of(head: &str) -> Option<String> {
#[cfg(test)]
mod tests {
use super::*;
use crate::core::git::test_support::PINS;
use crate::core::git::test_support::{PINS, one_spelling};
fn git(cwd: &Path, args: &[&str]) -> Option<String> {
let mut full = PINS.to_vec();
@@ -155,9 +155,14 @@ mod tests {
assert_eq!(got.root, canon(root), "root of {}", cwd.display());
assert_eq!(got.home, canon(home), "home of {}", cwd.display());
assert_eq!(got.branch.as_deref(), Some(branch));
// In one spelling: `canonicalize` answers `\\?\C:\…` on Windows and
// git `C:/…`. `probe_repo` folds the first into the local spelling
// before anything keys on it.
assert_eq!(
got.root,
PathBuf::from(git(cwd, &["rev-parse", "--show-toplevel"]).unwrap()),
one_spelling(&got.root),
one_spelling(Path::new(
&git(cwd, &["rev-parse", "--show-toplevel"]).unwrap()
)),
"and git names the same root"
);
}