mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-09-15 11:36:16 +00:00
cp: preserve permission on -p --parents (#4853)
This commit is contained in:
parent
452be5a220
commit
7a31d841ba
2 changed files with 66 additions and 0 deletions
|
@ -1075,6 +1075,46 @@ fn test_cp_parents_dest_not_directory() {
|
|||
.stderr_contains("with --parents, the destination must be a directory");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_cp_parents_with_permissions_copy_file() {
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
|
||||
let dir = "dir";
|
||||
let file = "p1/p2/file";
|
||||
|
||||
at.mkdir(dir);
|
||||
at.mkdir_all("p1/p2");
|
||||
at.touch(file);
|
||||
|
||||
let p1_mode = 0o0777;
|
||||
let p2_mode = 0o0711;
|
||||
let file_mode = 0o0702;
|
||||
|
||||
#[cfg(unix)]
|
||||
{
|
||||
at.set_mode("p1", p1_mode);
|
||||
at.set_mode("p1/p2", p2_mode);
|
||||
at.set_mode(file, file_mode);
|
||||
}
|
||||
|
||||
ucmd.arg("-p")
|
||||
.arg("--parents")
|
||||
.arg(file)
|
||||
.arg(dir)
|
||||
.succeeds();
|
||||
|
||||
#[cfg(all(unix, not(target_os = "freebsd")))]
|
||||
{
|
||||
let p1_metadata = at.metadata("p1");
|
||||
let p2_metadata = at.metadata("p1/p2");
|
||||
let file_metadata = at.metadata(file);
|
||||
|
||||
assert_metadata_eq!(p1_metadata, at.metadata("dir/p1"));
|
||||
assert_metadata_eq!(p2_metadata, at.metadata("dir/p1/p2"));
|
||||
assert_metadata_eq!(file_metadata, at.metadata("dir/p1/p2/file"));
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(unix)]
|
||||
fn test_cp_writable_special_file_permissions() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue