mirror of
https://github.com/ouch-org/ouch.git
synced 2025-06-06 11:35:45 +00:00
test: Add rename test with "allow_piped_choice" new feature
This commit is contained in:
parent
aae86d9e44
commit
0737ca76ec
@ -73,6 +73,7 @@ test-strategy = "0.4.0"
|
||||
default = ["use_zlib", "use_zstd_thin", "unrar"]
|
||||
use_zlib = ["flate2/zlib", "gzp/deflate_zlib", "zip/deflate-zlib"]
|
||||
use_zstd_thin = ["zstd/thin"]
|
||||
allow_piped_choice = []
|
||||
|
||||
# For generating binaries for releases
|
||||
[profile.release]
|
||||
|
@ -163,6 +163,7 @@ impl<'a, T: Default> ChoicePrompt<'a, T> {
|
||||
pub fn ask(mut self) -> crate::Result<T> {
|
||||
let message = self.prompt;
|
||||
|
||||
#[cfg(not(feature = "allow_piped_choice"))]
|
||||
if !stdin().is_terminal() {
|
||||
eprintln!("{}", message);
|
||||
eprintln!("Pass --yes to proceed");
|
||||
@ -259,6 +260,7 @@ impl<'a> Confirmation<'a> {
|
||||
(Some(placeholder), Some(subs)) => Cow::Owned(self.prompt.replace(placeholder, subs)),
|
||||
};
|
||||
|
||||
#[cfg(not(feature = "allow_piped_choice"))]
|
||||
if !stdin().is_terminal() {
|
||||
eprintln!("{}", message);
|
||||
eprintln!("Pass --yes to proceed");
|
||||
|
@ -270,6 +270,43 @@ fn multiple_files_with_conflict_and_choce_to_not_overwrite(
|
||||
assert_same_directory(after, after_backup, false);
|
||||
}
|
||||
|
||||
#[cfg(feature = "allow_piped_choice")]
|
||||
#[proptest(cases = 25)]
|
||||
fn multiple_files_with_conflict_and_choce_to_rename(
|
||||
ext: DirectoryExtension,
|
||||
#[any(size_range(0..1).lift())] extra_extensions: Vec<FileExtension>,
|
||||
#[strategy(0u8..3)] depth: u8,
|
||||
) {
|
||||
let dir = tempdir().unwrap();
|
||||
let dir = dir.path();
|
||||
|
||||
let before = &dir.join("before");
|
||||
let before_dir = &before.join("dir");
|
||||
fs::create_dir_all(before_dir).unwrap();
|
||||
create_random_files(before_dir, depth, &mut SmallRng::from_entropy());
|
||||
|
||||
let after = &dir.join("after");
|
||||
let after_dir = &after.join("dir");
|
||||
fs::create_dir_all(after_dir).unwrap();
|
||||
create_random_files(after_dir, depth, &mut SmallRng::from_entropy());
|
||||
|
||||
let archive = &dir.join(format!("archive.{}", merge_extensions(&ext, extra_extensions)));
|
||||
ouch!("-A", "c", before_dir, archive);
|
||||
|
||||
let after_renamed_dir = &after.join("dir_1");
|
||||
assert_eq!(false, after_renamed_dir.exists());
|
||||
|
||||
crate::utils::cargo_bin()
|
||||
.arg("decompress")
|
||||
.arg(archive)
|
||||
.arg("-d")
|
||||
.arg(after)
|
||||
.write_stdin("r")
|
||||
.assert()
|
||||
.success();
|
||||
|
||||
assert_same_directory(before_dir, after_renamed_dir, false);
|
||||
}
|
||||
|
||||
#[cfg(feature = "unrar")]
|
||||
#[test]
|
||||
|
Loading…
x
Reference in New Issue
Block a user