Skip to content

Commit

Permalink
cp: setting and checking permissions only on unix
Browse files Browse the repository at this point in the history
  • Loading branch information
shinhs0506 committed May 10, 2023
1 parent 8bd9272 commit f0c532d
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions tests/by-util/test_cp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1086,27 +1086,33 @@ fn test_cp_parents_with_permissions_copy_file() {
at.mkdir_all("p1/p2");
at.touch(file);

let pdir1_mode = 0o0777;
let pdir2_mode = 0o0711;
let p1_mode = 0o0777;
let p2_mode = 0o0711;
let file_mode = 0o0702;

at.set_mode("p1", pdir1_mode);
at.set_mode("p1/p2", pdir2_mode);
at.set_mode(file, file_mode);
#[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();

let pdir1_metadata = at.metadata("p1");
let pdir2_metadata = at.metadata("p1/p2");
let file_metadata = at.metadata(file);
#[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!(pdir1_metadata, at.metadata("dir/p1"));
assert_metadata_eq!(pdir2_metadata, at.metadata("dir/p1/p2"));
assert_metadata_eq!(file_metadata, at.metadata("dir/p1/p2/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]
Expand Down

0 comments on commit f0c532d

Please sign in to comment.