From 7392728fc7888716b79c3356719e467a20e55f90 Mon Sep 17 00:00:00 2001 From: wcampbell Date: Sun, 25 Dec 2022 14:40:51 +0000 Subject: [PATCH] Add checking file permissions --- src/lib.rs | 1 + tests/permissions/bad/dir1/file | 0 tests/permissions/bad/dir2/file | 0 tests/permissions/good/dir1/file | 0 tests/permissions/good/dir2/file | 0 tests/smoke.rs | 6 ++++++ 6 files changed, 7 insertions(+) create mode 100644 tests/permissions/bad/dir1/file create mode 100644 tests/permissions/bad/dir2/file create mode 100644 tests/permissions/good/dir1/file create mode 100644 tests/permissions/good/dir2/file diff --git a/src/lib.rs b/src/lib.rs index f8895e3..46bc4aa 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -48,6 +48,7 @@ pub fn is_different, B: AsRef>(a_base: A, b_base: B) -> Res if a.depth() != b.depth() || a.file_type() != b.file_type() || a.file_name() != b.file_name() + || a.metadata()?.permissions() != b.metadata()?.permissions() || (a.file_type().is_file() && read_to_vec(a.path())? != read_to_vec(b.path())?) { return Ok(true); diff --git a/tests/permissions/bad/dir1/file b/tests/permissions/bad/dir1/file new file mode 100644 index 0000000..e69de29 diff --git a/tests/permissions/bad/dir2/file b/tests/permissions/bad/dir2/file new file mode 100644 index 0000000..e69de29 diff --git a/tests/permissions/good/dir1/file b/tests/permissions/good/dir1/file new file mode 100644 index 0000000..e69de29 diff --git a/tests/permissions/good/dir2/file b/tests/permissions/good/dir2/file new file mode 100644 index 0000000..e69de29 diff --git a/tests/smoke.rs b/tests/smoke.rs index 53072cd..07306fb 100644 --- a/tests/smoke.rs +++ b/tests/smoke.rs @@ -57,6 +57,12 @@ fn reflexive() { assert!(dir_diff::is_different("tests/reflexive/dir1", "tests/reflexive/dir2").unwrap()); } +#[test] +fn binary_permissions() { + assert!(!dir_diff::is_different("tests/permissions/good/dir1", "tests/permissions/good/dir2").unwrap()); + assert!(dir_diff::is_different("tests/permissions/bad/dir1", "tests/permissions/bad/dir2").unwrap()); +} + #[test] fn dirs_differ() { assert!(dir_diff::is_different("tests/dirs_differ/dir1", "tests/dirs_differ/dir2").unwrap());