Repository: borgbackup/borg

Issue:
mode bug in tests (777 instead of 0o777)
testsuite.archiver:4531 (1.2-maint)


Discussion:
@Michael-Girma ^^ (please also check globally for same bug)
*bsd was so nice to tell that there is a problem: inappropriate file type or format (errno 79)
macOS:
- the ctime assertion in 4537 fails (even after fixing the mode)
- the mtime assertion in 4529 sometimes fails (guess hfs has 1s timestamp granularity)
macOS fixes needed:
```
$ git diff
diff --git a/src/borg/testsuite/archiver.py b/src/borg/testsuite/archiver.py
index 7eb5669b..6a05c1d2 100644
--- a/src/borg/testsuite/archiver.py
+++ b/src/borg/testsuite/archiver.py
@@ -4523,12 +4523,16 @@ def test_time_diffs(self):
         if is_win32:
             # Sleeping for 15s because Windows doesn't refresh ctime if file is deleted and recreated within 15 seconds.
             time.sleep(15)
+        elif is_darwin:
+            time.sleep(1)  # HFS has a 1s timestamp granularity
         self.create_regular_file("test_file", size=15)
         self.cmd('create', self.repository_location + '::archive2', 'input')
         output = self.cmd("diff", self.repository_location + "::archive1", "archive2")
         self.assert_in("mtime", output)
         self.assert_in("ctime", output)  # Should show up on windows as well since it is a new file.
-        os.chmod("input/test_file", 777)
+        if is_darwin:
+            time.sleep(1)  # HFS has a 1s timestamp granularity
+        os.chmod("input/test_file", 0o777)
         self.cmd('create', self.repository_location + '::archive3', 'input')
         output = self.cmd("diff", self.repository_location + "::archive2", "archive3")
         self.assert_not_in("mtime", output)
```
@Michael-Girma can you make a PR against 1.2-maint first?
@Michael-Girma can you work on that right now or shall I quickly fix it? Need it for 1.2.4...
Okay, I'll take a look right now.

Resolving patch:
diff --git a/src/borg/testsuite/archiver/diff_cmd.py b/src/borg/testsuite/archiver/diff_cmd.py
--- a/src/borg/testsuite/archiver/diff_cmd.py
+++ b/src/borg/testsuite/archiver/diff_cmd.py
@@ -6,7 +6,7 @@
 
 from ...constants import *  # NOQA
 from .. import are_symlinks_supported, are_hardlinks_supported
-from ..platform import is_win32
+from ..platform import is_win32, is_darwin
 from . import ArchiverTestCaseBase, RemoteArchiverTestCaseBase, ArchiverTestCaseBinaryBase, RK_ENCRYPTION, BORG_EXES
 
 
@@ -247,12 +247,16 @@ def test_time_diffs(self):
         if is_win32:
             # Sleeping for 15s because Windows doesn't refresh ctime if file is deleted and recreated within 15 seconds.
             time.sleep(15)
+        elif is_darwin:
+            time.sleep(1)  # HFS has a 1s timestamp granularity
         self.create_regular_file("test_file", size=15)
         self.cmd(f"--repo={self.repository_location}", "create", "archive2", "input")
         output = self.cmd(f"--repo={self.repository_location}", "diff", "archive1", "archive2")
         self.assert_in("mtime", output)
         self.assert_in("ctime", output)  # Should show up on windows as well since it is a new file.
-        os.chmod("input/test_file", 777)
+        if is_darwin:
+            time.sleep(1)  # HFS has a 1s timestamp granularity
+        os.chmod("input/test_file", 0o777)
         self.cmd(f"--repo={self.repository_location}", "create", "archive3", "input")
         output = self.cmd(f"--repo={self.repository_location}", "diff", "archive2", "archive3")
         self.assert_not_in("mtime", output)


Test patch: