update symlink test case to support zip case

Signed-off-by: tommady <tommady@users.noreply.github.com>
This commit is contained in:
tommady 2025-04-13 03:22:36 +00:00
parent fcf38ae6c9
commit 1e52f6c24d
No known key found for this signature in database
GPG Key ID: 175B664929DF2F2F
2 changed files with 14 additions and 5 deletions

View File

@ -95,9 +95,9 @@ where
file.read_to_string(&mut target)?;
#[cfg(unix)]
std::os::unix::fs::symlink(&target, &file_path)?;
std::os::unix::fs::symlink(&target, file_path)?;
#[cfg(windows)]
std::os::windows::fs::symlink_file(&target, &file_path)?;
std::os::windows::fs::symlink_file(&target, file_path)?;
} else {
let mut output_file = fs::File::create(file_path)?;
io::copy(&mut file, &mut output_file)?;

View File

@ -472,8 +472,16 @@ fn unpack_rar_stdin() -> Result<(), Box<dyn std::error::Error>> {
Ok(())
}
#[test]
fn tar_symlink_pack_and_unpack() {
#[proptest(cases = 25)]
fn symlink_pack_and_unpack(
ext: DirectoryExtension,
#[any(size_range(0..1).lift())] extra_extensions: Vec<FileExtension>,
) {
if matches!(ext, DirectoryExtension::SevenZ) {
// Skip 7z because the 7z format does not support symlinks
return Ok(());
}
let temp_dir = tempdir().unwrap();
let root_path = temp_dir.path();
@ -501,7 +509,7 @@ fn tar_symlink_pack_and_unpack() {
files_path.push(symlink_path);
let archive = &root_path.join("archive.tar");
let archive = &root_path.join(format!("archive.{}", merge_extensions(&ext, extra_extensions)));
crate::utils::cargo_bin()
.arg("compress")
@ -518,6 +526,7 @@ fn tar_symlink_pack_and_unpack() {
.assert()
.success();
println!("archive: {:?}", archive);
assert_same_directory(&src_files_path, &dest_files_path, false);
// check the symlink stand still
for f in dest_files_path.as_path().read_dir().unwrap() {