1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 19:47:45 +00:00

cp test: use compare_xattrs from tests/utils

This commit is contained in:
Sylvestre Ledru 2024-01-15 11:28:29 +01:00
parent 3872aca9c6
commit 69c8753f80

View file

@ -57,7 +57,7 @@ static TEST_MOUNT_OTHER_FILESYSTEM_FILE: &str = "mount/DO_NOT_copy_me.txt";
#[cfg(unix)] #[cfg(unix)]
static TEST_NONEXISTENT_FILE: &str = "nonexistent_file.txt"; static TEST_NONEXISTENT_FILE: &str = "nonexistent_file.txt";
#[cfg(all(unix, not(any(target_os = "android", target_os = "macos"))))] #[cfg(all(unix, not(any(target_os = "android", target_os = "macos"))))]
use xattr; use crate::common::util::compare_xattrs;
/// Assert that mode, ownership, and permissions of two metadata objects match. /// Assert that mode, ownership, and permissions of two metadata objects match.
#[cfg(all(not(windows), not(target_os = "freebsd")))] #[cfg(all(not(windows), not(target_os = "freebsd")))]
@ -3739,21 +3739,6 @@ fn test_cp_no_such() {
.stderr_is("cp: 'no-such/' is not a directory\n"); .stderr_is("cp: 'no-such/' is not a directory\n");
} }
#[cfg(all(unix, not(any(target_os = "android", target_os = "macos"))))]
fn compare_xattrs<P: AsRef<Path>>(path1: P, path2: P) -> bool {
let get_sorted_xattrs = |path: P| {
xattr::list(path)
.map(|attrs| {
let mut attrs = attrs.collect::<Vec<_>>();
attrs.sort();
attrs
})
.unwrap_or_else(|_| Vec::new())
};
get_sorted_xattrs(path1) == get_sorted_xattrs(path2)
}
#[cfg(all(unix, not(any(target_os = "android", target_os = "macos"))))] #[cfg(all(unix, not(any(target_os = "android", target_os = "macos"))))]
#[test] #[test]
fn test_acl_preserve() { fn test_acl_preserve() {