Bläddra i källkod

Merge pull request #9229 from ThomasWaldmann/haiku-fixes

Haiku fixes
TW 20 timmar sedan
förälder
incheckning
42e645e6a2

+ 1 - 1
src/borg/platform/__init__.py

@@ -6,7 +6,7 @@ Public APIs are documented in platform.base.
 
 from types import ModuleType
 
-from ..platformflags import is_win32, is_linux, is_freebsd, is_netbsd, is_darwin, is_cygwin
+from ..platformflags import is_win32, is_linux, is_freebsd, is_netbsd, is_darwin, is_cygwin, is_haiku
 
 from .base import ENOATTR, API_VERSION
 from .base import SaveFile, sync_dir, fdatasync, safe_fadvise

+ 1 - 0
src/borg/platformflags.py

@@ -14,3 +14,4 @@ is_freebsd = sys.platform.startswith("freebsd")
 is_netbsd = sys.platform.startswith("netbsd")
 is_openbsd = sys.platform.startswith("openbsd")
 is_darwin = sys.platform.startswith("darwin")
+is_haiku = sys.platform.startswith("haiku")

+ 9 - 6
src/borg/testsuite/archiver/create_cmd_test.py

@@ -73,17 +73,20 @@ def test_basic_functionality(archivers, request):
         "input/bdev",
         "input/cdev",
         "input/dir2",
-        "input/dir2/file2",
-        "input/empty",
-        "input/file1",
-        "input/flagfile",
+        "input/dir2/file2",  # 1
+        "input/empty",  # 2
+        "input/file1",  # 3
+        "input/flagfile",  # 4
+        "input/fusexattr",  # 5
     ]
+    item_count = 5  # we only count regular files
     if are_fifos_supported():
         expected.append("input/fifo1")
     if are_symlinks_supported():
         expected.append("input/link1")
     if are_hardlinks_supported():
         expected.append("input/hardlink")
+        item_count += 1
     if not have_root or not has_mknod:
         # We could not create these device files without (fake)root.
         expected.remove("input/bdev")
@@ -92,14 +95,14 @@ def test_basic_functionality(archivers, request):
         # remove the file we did not back up, so input and output become equal
         expected.remove("input/flagfile")  # this file is UF_NODUMP
         os.remove(os.path.join("input", "flagfile"))
-
+        item_count -= 1
     list_output = cmd(archiver, "list", "test", "--short")
     for name in expected:
         assert name in list_output
     assert_dirs_equal("input", "output/input")
 
     info_output = cmd(archiver, "info", "-a", "test")
-    item_count = 5 if has_lchflags else 6  # one file is UF_NODUMP
+    print("archive contents:\n%s" % list_output)
     assert "Number of files: %d" % item_count in info_output
     shutil.rmtree(archiver.cache_path)
     info_output2 = cmd(archiver, "info", "-a", "test")

+ 9 - 0
src/borg/testsuite/archiver/lock_cmds_test.py

@@ -1,10 +1,14 @@
 import os
 import subprocess
+import sys
 import time
 
+import pytest
+
 from ...constants import *  # NOQA
 from . import cmd, generate_archiver_tests, RK_ENCRYPTION
 from ...helpers import CommandError
+from ...platformflags import is_haiku
 
 pytest_generate_tests = lambda metafunc: generate_archiver_tests(metafunc, kinds="local,remote,binary")  # NOQA
 
@@ -15,10 +19,15 @@ def test_break_lock(archivers, request):
     cmd(archiver, "break-lock")
 
 
+@pytest.mark.skipif(is_haiku, reason="does not find borg python module on Haiku OS")
 def test_with_lock(tmp_path):
     repo_path = tmp_path / "repo"
     env = os.environ.copy()
     env["BORG_REPO"] = "file://" + str(repo_path)
+    # test debug output:
+    print("sys.path: %r" % sys.path)
+    print("PYTHONPATH: %s" % env.get("PYTHONPATH", ""))
+    print("PATH: %s" % env.get("PATH", ""))
     command0 = "python3", "-m", "borg", "repo-create", "--encryption=none"
     # Timings must be adjusted so that command1 keeps running while command2 tries to get the lock,
     # so that lock acquisition for command2 fails as the test expects it.

+ 5 - 3
src/borg/testsuite/helpers/fs_test.py

@@ -21,7 +21,7 @@ from ...helpers.fs import (
     remove_dotdot_prefixes,
     make_path_safe,
 )
-from ...platform import is_win32, is_darwin
+from ...platform import is_win32, is_darwin, is_haiku
 from .. import are_hardlinks_supported
 from .. import rejected_dotdot_paths
 
@@ -32,8 +32,10 @@ def test_get_base_dir(monkeypatch):
     monkeypatch.delenv("HOME", raising=False)
     monkeypatch.delenv("USER", raising=False)
     assert get_base_dir(legacy=True) == os.path.expanduser("~")
-    monkeypatch.setenv("USER", "root")
-    assert get_base_dir(legacy=True) == os.path.expanduser("~root")
+    # Haiku OS is a single-user OS, expanding "~root" is not supported.
+    if not is_haiku:
+        monkeypatch.setenv("USER", "root")
+        assert get_base_dir(legacy=True) == os.path.expanduser("~root")
     monkeypatch.setenv("HOME", "/var/tmp/home")
     assert get_base_dir(legacy=True) == "/var/tmp/home"
     monkeypatch.setenv("BORG_BASE_DIR", "/var/tmp/base")