fix windows test for short path
This commit is contained in:
parent
3366d26d65
commit
dc82fd6051
7174
src-tauri/Cargo.lock
generated
Normal file
7174
src-tauri/Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -998,26 +998,36 @@ Vulkan1: AMD Radeon Graphics (RADV GFX1151) (87722 MiB, 87722 MiB free)"#;
|
||||
const UNCOMMON_DIR_NAME: &str = "тест-你好-éàç-🚀";
|
||||
#[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);
|
||||
|
||||
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);
|
||||
|
||||
match short_path {
|
||||
Some(sp) => {
|
||||
// Ensure the path exists
|
||||
assert!(
|
||||
short_path.is_ascii(),
|
||||
"The resulting short path must be composed of only ASCII characters. Got: {}",
|
||||
short_path
|
||||
);
|
||||
assert!(
|
||||
PathBuf::from(&short_path).exists(),
|
||||
"The returned short path must exist on the filesystem"
|
||||
PathBuf::from(&sp).exists(),
|
||||
"Returned short path should exist on filesystem: {}",
|
||||
sp
|
||||
);
|
||||
|
||||
// It may or may not be ASCII; just ensure it differs
|
||||
let long_path_str = long_path.to_string_lossy();
|
||||
assert_ne!(
|
||||
short_path,
|
||||
long_path.to_str().unwrap(),
|
||||
"Short path should not be the same as the long path"
|
||||
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))]
|
||||
{
|
||||
// On Unix, paths are typically UTF-8 and there's no "short path" concept.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user