Skip to content

Commit

Permalink
cp: add test for --attributes-only
Browse files Browse the repository at this point in the history
  • Loading branch information
cakebaker committed Oct 27, 2023
1 parent 12cff46 commit aa51c8a
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions tests/by-util/test_cp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3499,3 +3499,33 @@ fn test_cp_dest_no_permissions() {
.stderr_contains("invalid_perms.txt")
.stderr_contains("denied");
}

#[test]
#[cfg(all(unix, not(target_os = "freebsd")))]
fn test_cp_attributes_only() {
let (at, mut ucmd) = at_and_ucmd!();
let a = "file_a";
let b = "file_b";
let mode_a = 0o0500;
let mode_b = 0o0777;

at.write(a, "a");
at.write(b, "b");
at.set_mode(a, mode_a);
at.set_mode(b, mode_b);
let mode_a = at.metadata(a).mode();
let mode_b = at.metadata(b).mode();

// --attributes-only doesn't do anything without other attribute preservation flags
ucmd.arg("--attributes-only")
.arg(a)
.arg(b)
.succeeds()
.no_output();

assert_eq!("a", at.read(a));
assert_eq!("b", at.read(b));

assert_eq!(mode_a, at.metadata(a).mode());
assert_eq!(mode_b, at.metadata(b).mode());
}

0 comments on commit aa51c8a

Please sign in to comment.