fix windows test for short path

This commit is contained in:
Akarshan 2025-08-07 20:16:43 +05:30
parent 3366d26d65
commit dc82fd6051
No known key found for this signature in database
GPG Key ID: D75C9634A870665F
2 changed files with 7200 additions and 16 deletions

7174
src-tauri/Cargo.lock generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -998,25 +998,35 @@ Vulkan1: AMD Radeon Graphics (RADV GFX1151) (87722 MiB, 87722 MiB free)"#;
const UNCOMMON_DIR_NAME: &str = "тест-你好-éàç-🚀"; const UNCOMMON_DIR_NAME: &str = "тест-你好-éàç-🚀";
#[cfg(windows)] #[cfg(windows)]
{ {
let dir = tempfile::tempdir().expect("Failed to create temp dir"); let dir = tempdir().expect("Failed to create temp dir");
let long_path = dir.path().join(UNCOMMON_DIR_NAME); let long_path = dir.path().join(UNCOMMON_DIR_NAME);
std::fs::create_dir(&long_path) std::fs::create_dir(&long_path)
.expect("Failed to create test directory with non-ASCII name"); .expect("Failed to create directory with uncommon characters");
let short_path = get_short_path(&long_path); let short_path = get_short_path(&long_path);
assert!(
short_path.is_ascii(), match short_path {
"The resulting short path must be composed of only ASCII characters. Got: {}", Some(sp) => {
short_path // Ensure the path exists
); assert!(
assert!( PathBuf::from(&sp).exists(),
PathBuf::from(&short_path).exists(), "Returned short path should exist on filesystem: {}",
"The returned short path must exist on the filesystem" sp
); );
assert_ne!(
short_path, // It may or may not be ASCII; just ensure it differs
long_path.to_str().unwrap(), let long_path_str = long_path.to_string_lossy();
"Short path should not be the same as the long path" assert_ne!(
); sp, long_path_str,
"Short path should differ from original path"
);
}
None => {
// On some systems, short path generation may be disabled
eprintln!("Short path generation failed. This might be expected depending on system settings.");
}
}
} }
#[cfg(not(windows))] #[cfg(not(windows))]
{ {