mirror of
https://github.com/ouch-org/ouch.git
synced 2025-06-06 19:45:29 +00:00
cargo clippy
This commit is contained in:
parent
f6eeb7ae33
commit
733bf35222
@ -314,7 +314,7 @@ fn execute_decompression(
|
|||||||
output_file_path
|
output_file_path
|
||||||
};
|
};
|
||||||
|
|
||||||
return unpack(unpack_fn, target_output_dir, question_policy);
|
unpack(unpack_fn, target_output_dir, question_policy)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Unpacks an archive creating the output directory, this function will create the output_dir
|
/// Unpacks an archive creating the output directory, this function will create the output_dir
|
||||||
|
@ -146,7 +146,7 @@ pub fn run(
|
|||||||
}
|
}
|
||||||
Subcommand::Decompress {
|
Subcommand::Decompress {
|
||||||
files,
|
files,
|
||||||
mut output_dir,
|
output_dir,
|
||||||
remove,
|
remove,
|
||||||
no_smart_unpack,
|
no_smart_unpack,
|
||||||
} => {
|
} => {
|
||||||
|
@ -11,7 +11,6 @@ use fs_err as fs;
|
|||||||
use parse_display::Display;
|
use parse_display::Display;
|
||||||
use proptest::sample::size_range;
|
use proptest::sample::size_range;
|
||||||
use rand::{rngs::SmallRng, Rng, SeedableRng};
|
use rand::{rngs::SmallRng, Rng, SeedableRng};
|
||||||
use sevenz_rust::Archive;
|
|
||||||
use tempfile::tempdir;
|
use tempfile::tempdir;
|
||||||
use test_strategy::{proptest, Arbitrary};
|
use test_strategy::{proptest, Arbitrary};
|
||||||
|
|
||||||
@ -382,10 +381,9 @@ fn smart_unpack_with_single_file(
|
|||||||
let files_path = ["file1.txt"]
|
let files_path = ["file1.txt"]
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|f| src_files_path.join(f))
|
.map(|f| src_files_path.join(f))
|
||||||
.map(|path| {
|
.inspect(|path| {
|
||||||
let mut file = fs::File::create(&path).unwrap();
|
let mut file = fs::File::create(path).unwrap();
|
||||||
file.write_all("Some content".as_bytes()).unwrap();
|
file.write_all("Some content".as_bytes()).unwrap();
|
||||||
path
|
|
||||||
})
|
})
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
@ -399,17 +397,17 @@ fn smart_unpack_with_single_file(
|
|||||||
.success();
|
.success();
|
||||||
|
|
||||||
let output_file = root_path.join("file1.txt");
|
let output_file = root_path.join("file1.txt");
|
||||||
assert_eq!(false, output_file.exists());
|
assert!(!output_file.exists());
|
||||||
|
|
||||||
// Decompress the archive with Smart Unpack
|
// Decompress the archive with Smart Unpack
|
||||||
crate::utils::cargo_bin()
|
crate::utils::cargo_bin()
|
||||||
.current_dir(&root_path)
|
.current_dir(root_path)
|
||||||
.arg("decompress")
|
.arg("decompress")
|
||||||
.arg(archive)
|
.arg(archive)
|
||||||
.assert()
|
.assert()
|
||||||
.success();
|
.success();
|
||||||
|
|
||||||
assert_eq!(true, output_file.exists());
|
assert!(output_file.exists());
|
||||||
|
|
||||||
let output_content = fs::read_to_string(&output_file).unwrap();
|
let output_content = fs::read_to_string(&output_file).unwrap();
|
||||||
assert_eq!(output_content, "Some content");
|
assert_eq!(output_content, "Some content");
|
||||||
@ -443,7 +441,7 @@ fn smart_unpack_with_multiple_files(
|
|||||||
let archive = &root_path.join(format!("archive.{}", merge_extensions(&ext, extra_extensions)));
|
let archive = &root_path.join(format!("archive.{}", merge_extensions(&ext, extra_extensions)));
|
||||||
|
|
||||||
let output_path = root_path.join("archive");
|
let output_path = root_path.join("archive");
|
||||||
assert_eq!(false, output_path.exists());
|
assert!(!output_path.exists());
|
||||||
|
|
||||||
crate::utils::cargo_bin()
|
crate::utils::cargo_bin()
|
||||||
.arg("compress")
|
.arg("compress")
|
||||||
@ -453,13 +451,13 @@ fn smart_unpack_with_multiple_files(
|
|||||||
.success();
|
.success();
|
||||||
|
|
||||||
crate::utils::cargo_bin()
|
crate::utils::cargo_bin()
|
||||||
.current_dir(&root_path)
|
.current_dir(root_path)
|
||||||
.arg("decompress")
|
.arg("decompress")
|
||||||
.arg(archive)
|
.arg(archive)
|
||||||
.assert()
|
.assert()
|
||||||
.success();
|
.success();
|
||||||
|
|
||||||
assert_eq!(true, output_path.exists(), "Output directory does not exist");
|
assert!(output_path.exists(), "Output directory does not exist");
|
||||||
|
|
||||||
assert_same_directory(src_files_path, output_path, false);
|
assert_same_directory(src_files_path, output_path, false);
|
||||||
}
|
}
|
||||||
@ -492,7 +490,7 @@ fn no_smart_unpack_with_single_file(
|
|||||||
let archive = &root_path.join(format!("archive.{}", merge_extensions(&ext, extra_extensions)));
|
let archive = &root_path.join(format!("archive.{}", merge_extensions(&ext, extra_extensions)));
|
||||||
|
|
||||||
let output_path = root_path.join("archive");
|
let output_path = root_path.join("archive");
|
||||||
assert_eq!(false, output_path.exists());
|
assert!(!output_path.exists());
|
||||||
|
|
||||||
crate::utils::cargo_bin()
|
crate::utils::cargo_bin()
|
||||||
.arg("compress")
|
.arg("compress")
|
||||||
@ -502,14 +500,14 @@ fn no_smart_unpack_with_single_file(
|
|||||||
.success();
|
.success();
|
||||||
|
|
||||||
crate::utils::cargo_bin()
|
crate::utils::cargo_bin()
|
||||||
.current_dir(&root_path)
|
.current_dir(root_path)
|
||||||
.arg("decompress")
|
.arg("decompress")
|
||||||
.arg("--no-smart-unpack")
|
.arg("--no-smart-unpack")
|
||||||
.arg(archive)
|
.arg(archive)
|
||||||
.assert()
|
.assert()
|
||||||
.success();
|
.success();
|
||||||
|
|
||||||
assert_eq!(true, output_path.exists(), "Output directory does not exist");
|
assert!(output_path.exists(), "Output directory does not exist");
|
||||||
|
|
||||||
assert_same_directory(src_files_path, output_path, false);
|
assert_same_directory(src_files_path, output_path, false);
|
||||||
}
|
}
|
||||||
@ -542,7 +540,7 @@ fn no_smart_unpack_with_multiple_files(
|
|||||||
let archive = &root_path.join(format!("archive.{}", merge_extensions(&ext, extra_extensions)));
|
let archive = &root_path.join(format!("archive.{}", merge_extensions(&ext, extra_extensions)));
|
||||||
|
|
||||||
let output_path = root_path.join("archive");
|
let output_path = root_path.join("archive");
|
||||||
assert_eq!(false, output_path.exists());
|
assert!(!output_path.exists());
|
||||||
|
|
||||||
crate::utils::cargo_bin()
|
crate::utils::cargo_bin()
|
||||||
.arg("compress")
|
.arg("compress")
|
||||||
@ -552,14 +550,14 @@ fn no_smart_unpack_with_multiple_files(
|
|||||||
.success();
|
.success();
|
||||||
|
|
||||||
crate::utils::cargo_bin()
|
crate::utils::cargo_bin()
|
||||||
.current_dir(&root_path)
|
.current_dir(root_path)
|
||||||
.arg("decompress")
|
.arg("decompress")
|
||||||
.arg("--no-smart-unpack")
|
.arg("--no-smart-unpack")
|
||||||
.arg(archive)
|
.arg(archive)
|
||||||
.assert()
|
.assert()
|
||||||
.success();
|
.success();
|
||||||
|
|
||||||
assert_eq!(true, output_path.exists(), "Output directory does not exist");
|
assert!(output_path.exists(), "Output directory does not exist");
|
||||||
|
|
||||||
assert_same_directory(src_files_path, output_path, false);
|
assert_same_directory(src_files_path, output_path, false);
|
||||||
}
|
}
|
||||||
@ -578,10 +576,9 @@ fn multiple_files_with_disabled_smart_unpack_by_dir(
|
|||||||
let files_path = ["file1.txt", "file2.txt", "file3.txt", "file4.txt", "file5.txt"]
|
let files_path = ["file1.txt", "file2.txt", "file3.txt", "file4.txt", "file5.txt"]
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|f| src_files_path.join(f))
|
.map(|f| src_files_path.join(f))
|
||||||
.map(|path| {
|
.inspect(|path| {
|
||||||
let mut file = fs::File::create(&path).unwrap();
|
let mut file = fs::File::create(path).unwrap();
|
||||||
file.write_all("Some content".as_bytes()).unwrap();
|
file.write_all("Some content".as_bytes()).unwrap();
|
||||||
path
|
|
||||||
})
|
})
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
@ -688,10 +685,9 @@ fn symlink_pack_and_unpack(
|
|||||||
let mut files_path = ["file1.txt", "file2.txt", "file3.txt", "file4.txt", "file5.txt"]
|
let mut files_path = ["file1.txt", "file2.txt", "file3.txt", "file4.txt", "file5.txt"]
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|f| src_files_path.join(f))
|
.map(|f| src_files_path.join(f))
|
||||||
.map(|path| {
|
.inspect(|path| {
|
||||||
let mut file = fs::File::create(&path).unwrap();
|
let mut file = fs::File::create(path).unwrap();
|
||||||
file.write_all("Some content".as_bytes()).unwrap();
|
file.write_all("Some content".as_bytes()).unwrap();
|
||||||
path
|
|
||||||
})
|
})
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user