@@ -795,6 +795,25 @@ mod tests {
795795 . unwrap ( ) ;
796796 }
797797
798+ /// Canonicalize a temp path for test comparisons. On Windows, `TempDir`
799+ /// roots can come back as 8.3 short names (e.g. `C:\Users\RUNNER~1\...`)
800+ /// while paths surfaced via `fs::read_dir` or env-var expansion are in
801+ /// long form (`C:\Users\runneradmin\...`). Without this both sides of
802+ /// `PathBuf` equality checks would not match on CI runners. The
803+ /// `\\?\` verbatim prefix added by `fs::canonicalize` is stripped so the
804+ /// resulting path matches what production code produces.
805+ fn canonicalize_for_test ( p : & Path ) -> PathBuf {
806+ let canon = fs:: canonicalize ( p) . unwrap_or_else ( |_| p. to_path_buf ( ) ) ;
807+ #[ cfg( windows) ]
808+ {
809+ let s = canon. to_string_lossy ( ) . to_string ( ) ;
810+ if let Some ( stripped) = s. strip_prefix ( r"\\?\" ) {
811+ return PathBuf :: from ( stripped) ;
812+ }
813+ }
814+ canon
815+ }
816+
798817 fn write_python_exe ( prefix : & Path ) -> PathBuf {
799818 let bin = prefix. join ( if cfg ! ( windows) { "Scripts" } else { "bin" } ) ;
800819 fs:: create_dir_all ( & bin) . unwrap ( ) ;
@@ -1268,6 +1287,10 @@ mod tests {
12681287 let temp = TempDir :: new ( ) . unwrap ( ) ;
12691288 let fake_home = temp. path ( ) . join ( "home" ) ;
12701289 fs:: create_dir_all ( & fake_home) . unwrap ( ) ;
1290+ // Canonicalize so 8.3 short names on Windows CI runners don't
1291+ // cause spurious path mismatches when comparing against the
1292+ // value produced by `expand_path` + `norm_case`.
1293+ let fake_home = canonicalize_for_test ( & fake_home) ;
12711294
12721295 let prev_home = std:: env:: var_os ( "HOME" ) ;
12731296 let prev_user_profile = std:: env:: var_os ( "USERPROFILE" ) ;
@@ -1400,6 +1423,10 @@ mod tests {
14001423 let temp = TempDir :: new ( ) . unwrap ( ) ;
14011424 let shared = temp. path ( ) . join ( "shared" ) ;
14021425 fs:: create_dir_all ( & shared) . unwrap ( ) ;
1426+ // Canonicalize so 8.3 short names on Windows CI runners don't
1427+ // cause spurious path mismatches when comparing prefixes that
1428+ // were surfaced via `fs::read_dir`.
1429+ let shared = canonicalize_for_test ( & shared) ;
14031430
14041431 // Hatch-managed env.
14051432 let hatch_env = shared. join ( "default" ) ;
0 commit comments