From 1721d1b080abc9408dee90029589c7b49f783901 Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Wed, 17 Dec 2025 17:26:14 +0100 Subject: [PATCH 1/6] fs_test: exclude Haiku OS from "~root" expansion check --- src/borg/testsuite/helpers/fs_test.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/borg/testsuite/helpers/fs_test.py b/src/borg/testsuite/helpers/fs_test.py index 70acc42a0..acfb2e789 100644 --- a/src/borg/testsuite/helpers/fs_test.py +++ b/src/borg/testsuite/helpers/fs_test.py @@ -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 sys.platform.startswith("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") From 87ff42ee27d8253d953626434ad364a318b02990 Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Wed, 17 Dec 2025 17:32:01 +0100 Subject: [PATCH 2/6] add debug print to display archive contents --- src/borg/testsuite/archiver/create_cmd_test.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/borg/testsuite/archiver/create_cmd_test.py b/src/borg/testsuite/archiver/create_cmd_test.py index d4b0d1caf..4378085b2 100644 --- a/src/borg/testsuite/archiver/create_cmd_test.py +++ b/src/borg/testsuite/archiver/create_cmd_test.py @@ -100,6 +100,7 @@ def test_basic_functionality(archivers, request): 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") From 4a701b65ea5ec42631b67d4daeccf99025dfb935 Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Wed, 17 Dec 2025 17:34:55 +0100 Subject: [PATCH 3/6] add debug prints for sys.path and PATH --- src/borg/testsuite/archiver/lock_cmds_test.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/borg/testsuite/archiver/lock_cmds_test.py b/src/borg/testsuite/archiver/lock_cmds_test.py index 139fb0770..275c81de5 100644 --- a/src/borg/testsuite/archiver/lock_cmds_test.py +++ b/src/borg/testsuite/archiver/lock_cmds_test.py @@ -28,6 +28,11 @@ def test_with_lock(tmp_path): command2 = "python3", "-c", 'print("second command - should never get executed")' borgwl = "python3", "-m", "borg", "with-lock", f"--lock-wait={lock_wait}" popen_options = dict(stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True, env=env) + import sys + + print("sys.path: %r" % sys.path) + print("PYTHONPATH: %s" % env.get("PYTHONPATH", "")) + print("PATH: %s" % env.get("PATH", "")) subprocess.run(command0, env=env, check=True, text=True, capture_output=True) assert repo_path.exists() with subprocess.Popen([*borgwl, *command1], **popen_options) as p1: From 4df1a534de967ad3399549de28da3db06b1bb4a7 Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Wed, 17 Dec 2025 18:44:42 +0100 Subject: [PATCH 4/6] tests: refactor expected item_count --- src/borg/testsuite/archiver/create_cmd_test.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/borg/testsuite/archiver/create_cmd_test.py b/src/borg/testsuite/archiver/create_cmd_test.py index 4378085b2..f02beeb13 100644 --- a/src/borg/testsuite/archiver/create_cmd_test.py +++ b/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,13 @@ 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) From 6be6b1d9422e863d0d8ea2ce7093250b10243aa4 Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Wed, 17 Dec 2025 18:55:43 +0100 Subject: [PATCH 5/6] test_with_lock: skip on Haiku OS --- src/borg/platformflags.py | 1 + src/borg/testsuite/archiver/lock_cmds_test.py | 14 +++++++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/borg/platformflags.py b/src/borg/platformflags.py index f13361fad..9abf7d065 100644 --- a/src/borg/platformflags.py +++ b/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") diff --git a/src/borg/testsuite/archiver/lock_cmds_test.py b/src/borg/testsuite/archiver/lock_cmds_test.py index 275c81de5..295fa1d5e 100644 --- a/src/borg/testsuite/archiver/lock_cmds_test.py +++ b/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. @@ -28,11 +37,6 @@ def test_with_lock(tmp_path): command2 = "python3", "-c", 'print("second command - should never get executed")' borgwl = "python3", "-m", "borg", "with-lock", f"--lock-wait={lock_wait}" popen_options = dict(stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True, env=env) - import sys - - print("sys.path: %r" % sys.path) - print("PYTHONPATH: %s" % env.get("PYTHONPATH", "")) - print("PATH: %s" % env.get("PATH", "")) subprocess.run(command0, env=env, check=True, text=True, capture_output=True) assert repo_path.exists() with subprocess.Popen([*borgwl, *command1], **popen_options) as p1: From dcdc91c1cc11bbd6595427cc25b7b0d53fc13fca Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Wed, 17 Dec 2025 18:59:36 +0100 Subject: [PATCH 6/6] improve fs_test --- src/borg/platform/__init__.py | 2 +- src/borg/testsuite/helpers/fs_test.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/borg/platform/__init__.py b/src/borg/platform/__init__.py index d436b67dc..e0491101b 100644 --- a/src/borg/platform/__init__.py +++ b/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 diff --git a/src/borg/testsuite/helpers/fs_test.py b/src/borg/testsuite/helpers/fs_test.py index acfb2e789..cb045dce6 100644 --- a/src/borg/testsuite/helpers/fs_test.py +++ b/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 @@ -33,7 +33,7 @@ def test_get_base_dir(monkeypatch): monkeypatch.delenv("USER", raising=False) assert get_base_dir(legacy=True) == os.path.expanduser("~") # Haiku OS is a single-user OS, expanding "~root" is not supported. - if not sys.platform.startswith("haiku"): + if not is_haiku: monkeypatch.setenv("USER", "root") assert get_base_dir(legacy=True) == os.path.expanduser("~root") monkeypatch.setenv("HOME", "/var/tmp/home")