mirror of
https://github.com/ouch-org/ouch.git
synced 2025-06-07 12:05:46 +00:00
update symlink test case to support zip case
Signed-off-by: tommady <tommady@users.noreply.github.com>
This commit is contained in:
parent
fcf38ae6c9
commit
1e52f6c24d
@ -95,9 +95,9 @@ where
|
|||||||
file.read_to_string(&mut target)?;
|
file.read_to_string(&mut target)?;
|
||||||
|
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
std::os::unix::fs::symlink(&target, &file_path)?;
|
std::os::unix::fs::symlink(&target, file_path)?;
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
std::os::windows::fs::symlink_file(&target, &file_path)?;
|
std::os::windows::fs::symlink_file(&target, file_path)?;
|
||||||
} else {
|
} else {
|
||||||
let mut output_file = fs::File::create(file_path)?;
|
let mut output_file = fs::File::create(file_path)?;
|
||||||
io::copy(&mut file, &mut output_file)?;
|
io::copy(&mut file, &mut output_file)?;
|
||||||
|
@ -472,8 +472,16 @@ fn unpack_rar_stdin() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[proptest(cases = 25)]
|
||||||
fn tar_symlink_pack_and_unpack() {
|
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 temp_dir = tempdir().unwrap();
|
||||||
let root_path = temp_dir.path();
|
let root_path = temp_dir.path();
|
||||||
|
|
||||||
@ -501,7 +509,7 @@ fn tar_symlink_pack_and_unpack() {
|
|||||||
|
|
||||||
files_path.push(symlink_path);
|
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()
|
crate::utils::cargo_bin()
|
||||||
.arg("compress")
|
.arg("compress")
|
||||||
@ -518,6 +526,7 @@ fn tar_symlink_pack_and_unpack() {
|
|||||||
.assert()
|
.assert()
|
||||||
.success();
|
.success();
|
||||||
|
|
||||||
|
println!("archive: {:?}", archive);
|
||||||
assert_same_directory(&src_files_path, &dest_files_path, false);
|
assert_same_directory(&src_files_path, &dest_files_path, false);
|
||||||
// check the symlink stand still
|
// check the symlink stand still
|
||||||
for f in dest_files_path.as_path().read_dir().unwrap() {
|
for f in dest_files_path.as_path().read_dir().unwrap() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user