1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 11:37:44 +00:00

Merge pull request #3721 from niyaznigmatullin/add_test_for_issue_3332

tests/cp: add test for cp-parents.sh
This commit is contained in:
Sylvestre Ledru 2022-07-18 12:11:30 +02:00 committed by GitHub
commit 189a8af450
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -26,6 +26,7 @@ use std::fs as std_fs;
use std::thread::sleep; use std::thread::sleep;
#[cfg(any(target_os = "linux", target_os = "android"))] #[cfg(any(target_os = "linux", target_os = "android"))]
use std::time::Duration; use std::time::Duration;
use uucore::display::Quotable;
static TEST_EXISTING_FILE: &str = "existing_file.txt"; static TEST_EXISTING_FILE: &str = "existing_file.txt";
static TEST_HELLO_WORLD_SOURCE: &str = "hello_world.txt"; static TEST_HELLO_WORLD_SOURCE: &str = "hello_world.txt";
@ -1752,3 +1753,47 @@ fn test_copy_same_symlink_no_dereference_dangling() {
at.relative_symlink_file("t", "b"); at.relative_symlink_file("t", "b");
ucmd.args(&["-d", "a", "b"]).succeeds(); ucmd.args(&["-d", "a", "b"]).succeeds();
} }
#[test]
#[ignore = "issue #3332"]
fn test_cp_parents_2() {
let (at, mut ucmd) = at_and_ucmd!();
at.mkdir_all("a/b");
at.touch("a/b/c");
at.mkdir("d");
ucmd.args(&["--verbose", "-a", "--parents", "a/b/c", "d"])
.succeeds()
.stdout_is(format!(
"{} -> {}\n{} -> {}\n{} -> {}\n",
"a",
path_concat!("d", "a"),
path_concat!("a", "b"),
path_concat!("d", "a", "b"),
path_concat!("a", "b", "c").quote(),
path_concat!("d", "a", "b", "c").quote()
));
assert!(at.file_exists("d/a/b/c"));
}
#[test]
#[ignore = "issue #3332"]
fn test_cp_parents_2_link() {
let (at, mut ucmd) = at_and_ucmd!();
at.mkdir_all("a/b");
at.touch("a/b/c");
at.mkdir("d");
at.relative_symlink_file("b", "a/link");
ucmd.args(&["--verbose", "-a", "--parents", "a/link/c", "d"])
.succeeds()
.stdout_is(format!(
"{} -> {}\n{} -> {}\n{} -> {}\n",
"a",
path_concat!("d", "a"),
path_concat!("a", "link"),
path_concat!("d", "a", "link"),
path_concat!("a", "link", "c").quote(),
path_concat!("d", "a", "link", "c").quote()
));
assert!(at.dir_exists("d/a/link") && !at.symlink_exists("d/a/link"));
assert!(at.file_exists("d/a/link/c"));
}