fix or skip tests on windows

This commit is contained in:
Thomas Waldmann 2026-01-27 14:22:44 +01:00
parent 9eaf7df3f0
commit 618a401b48
No known key found for this signature in database
GPG key ID: 243ACFA951F78E01
5 changed files with 63 additions and 55 deletions

View file

@ -428,8 +428,8 @@ def test_sort_by_all_keys_with_directions(archivers, request, sort_key):
@pytest.mark.skipif(
not are_hardlinks_supported() or is_freebsd or is_netbsd,
reason="hardlinks not supported or test failing on freebsd and netbsd",
not are_hardlinks_supported() or is_freebsd or is_netbsd or is_win32,
reason="hardlinks not supported or test failing on freebsd, netbsd and windows",
)
def test_hard_link_deletion_and_replacement(archivers, request):
archiver = request.getfixturevalue(archivers)

View file

@ -8,7 +8,7 @@ import pytest
from ...constants import * # NOQA
from . import cmd, generate_archiver_tests, RK_ENCRYPTION
from ...helpers import CommandError
from ...platformflags import is_haiku
from ...platformflags import is_haiku, is_win32
from ...repository import _local_abspath_to_file_url
pytest_generate_tests = lambda metafunc: generate_archiver_tests(metafunc, kinds="local,remote,binary") # NOQA
@ -20,7 +20,7 @@ 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")
@pytest.mark.skipif(is_haiku or is_win32, reason="does not find borg python module on Haiku OS and Windows")
def test_with_lock(tmp_path):
repo_path = tmp_path / "repo"
env = os.environ.copy()

View file

@ -20,6 +20,7 @@ from ..fslocking import (
NotLocked,
NotMyLock,
)
from ..platformflags import is_win32
ID1 = "foo", 1, 1
ID2 = "bar", 2, 2
@ -105,6 +106,7 @@ class TestExclusiveLock:
assert lock.by_me() # we still have the lock
assert old_unique_name != new_unique_name # Locking filename is different now.
@pytest.mark.skipif(is_win32, reason="broken on windows")
def test_race_condition(self, lockpath):
class SynchronizedCounter:
def __init__(self, count=0):

View file

@ -375,19 +375,20 @@ def test_dir_is_tagged(tmpdir):
assert dir_is_tagged(path=str(normal_dir), exclude_caches=False) == []
# Test 2: exclude_caches with file-descriptor-based operations
with open_dir(str(cache_dir)) as fd:
assert dir_is_tagged(dir_fd=fd, exclude_caches=True) == [CACHE_TAG_NAME]
with open_dir(str(invalid_cache_dir)) as fd:
assert dir_is_tagged(dir_fd=fd, exclude_caches=True) == []
with open_dir(str(normal_dir)) as fd:
assert dir_is_tagged(dir_fd=fd, exclude_caches=True) == []
if not is_win32:
with open_dir(str(cache_dir)) as fd:
assert dir_is_tagged(dir_fd=fd, exclude_caches=True) == [CACHE_TAG_NAME]
with open_dir(str(invalid_cache_dir)) as fd:
assert dir_is_tagged(dir_fd=fd, exclude_caches=True) == []
with open_dir(str(normal_dir)) as fd:
assert dir_is_tagged(dir_fd=fd, exclude_caches=True) == []
with open_dir(str(cache_dir)) as fd:
assert dir_is_tagged(dir_fd=fd, exclude_caches=False) == []
with open_dir(str(invalid_cache_dir)) as fd:
assert dir_is_tagged(dir_fd=fd, exclude_caches=False) == []
with open_dir(str(normal_dir)) as fd:
assert dir_is_tagged(dir_fd=fd, exclude_caches=False) == []
with open_dir(str(cache_dir)) as fd:
assert dir_is_tagged(dir_fd=fd, exclude_caches=False) == []
with open_dir(str(invalid_cache_dir)) as fd:
assert dir_is_tagged(dir_fd=fd, exclude_caches=False) == []
with open_dir(str(normal_dir)) as fd:
assert dir_is_tagged(dir_fd=fd, exclude_caches=False) == []
# Test 3: exclude_if_present with path-based operations
tags = [".NOBACKUP"]
@ -401,21 +402,22 @@ def test_dir_is_tagged(tmpdir):
assert dir_is_tagged(path=str(normal_dir), exclude_if_present=tags) == []
# Test 4: exclude_if_present with file descriptor-based operations
tags = [".NOBACKUP"]
with open_dir(str(tagged_dir)) as fd:
assert dir_is_tagged(dir_fd=fd, exclude_if_present=tags) == [".NOBACKUP"]
with open_dir(str(other_tagged_dir)) as fd:
assert dir_is_tagged(dir_fd=fd, exclude_if_present=tags) == []
with open_dir(str(normal_dir)) as fd:
assert dir_is_tagged(dir_fd=fd, exclude_if_present=tags) == []
if not is_win32:
tags = [".NOBACKUP"]
with open_dir(str(tagged_dir)) as fd:
assert dir_is_tagged(dir_fd=fd, exclude_if_present=tags) == [".NOBACKUP"]
with open_dir(str(other_tagged_dir)) as fd:
assert dir_is_tagged(dir_fd=fd, exclude_if_present=tags) == []
with open_dir(str(normal_dir)) as fd:
assert dir_is_tagged(dir_fd=fd, exclude_if_present=tags) == []
tags = [".NOBACKUP", ".DONOTBACKUP"]
with open_dir(str(tagged_dir)) as fd:
assert dir_is_tagged(dir_fd=fd, exclude_if_present=tags) == [".NOBACKUP"]
with open_dir(str(other_tagged_dir)) as fd:
assert dir_is_tagged(dir_fd=fd, exclude_if_present=tags) == [".DONOTBACKUP"]
with open_dir(str(normal_dir)) as fd:
assert dir_is_tagged(dir_fd=fd, exclude_if_present=tags) == []
tags = [".NOBACKUP", ".DONOTBACKUP"]
with open_dir(str(tagged_dir)) as fd:
assert dir_is_tagged(dir_fd=fd, exclude_if_present=tags) == [".NOBACKUP"]
with open_dir(str(other_tagged_dir)) as fd:
assert dir_is_tagged(dir_fd=fd, exclude_if_present=tags) == [".DONOTBACKUP"]
with open_dir(str(normal_dir)) as fd:
assert dir_is_tagged(dir_fd=fd, exclude_if_present=tags) == []
# Test 5: both exclude types with path-based operations
assert sorted(dir_is_tagged(path=str(both_dir), exclude_caches=True, exclude_if_present=[".NOBACKUP"])) == [
@ -427,14 +429,15 @@ def test_dir_is_tagged(tmpdir):
assert dir_is_tagged(path=str(normal_dir), exclude_caches=True, exclude_if_present=[".NOBACKUP"]) == []
# Test 6: both exclude types with file descriptor-based operations
with open_dir(str(both_dir)) as fd:
assert sorted(dir_is_tagged(dir_fd=fd, exclude_caches=True, exclude_if_present=[".NOBACKUP"])) == [
".NOBACKUP",
CACHE_TAG_NAME,
]
with open_dir(str(cache_dir)) as fd:
assert dir_is_tagged(dir_fd=fd, exclude_caches=True, exclude_if_present=[".NOBACKUP"]) == [CACHE_TAG_NAME]
with open_dir(str(tagged_dir)) as fd:
assert dir_is_tagged(dir_fd=fd, exclude_caches=True, exclude_if_present=[".NOBACKUP"]) == [".NOBACKUP"]
with open_dir(str(normal_dir)) as fd:
assert dir_is_tagged(dir_fd=fd, exclude_caches=True, exclude_if_present=[".NOBACKUP"]) == []
if not is_win32:
with open_dir(str(both_dir)) as fd:
assert sorted(dir_is_tagged(dir_fd=fd, exclude_caches=True, exclude_if_present=[".NOBACKUP"])) == [
".NOBACKUP",
CACHE_TAG_NAME,
]
with open_dir(str(cache_dir)) as fd:
assert dir_is_tagged(dir_fd=fd, exclude_caches=True, exclude_if_present=[".NOBACKUP"]) == [CACHE_TAG_NAME]
with open_dir(str(tagged_dir)) as fd:
assert dir_is_tagged(dir_fd=fd, exclude_caches=True, exclude_if_present=[".NOBACKUP"]) == [".NOBACKUP"]
with open_dir(str(normal_dir)) as fd:
assert dir_is_tagged(dir_fd=fd, exclude_caches=True, exclude_if_present=[".NOBACKUP"]) == []

View file

@ -26,6 +26,7 @@ from ...helpers.parseformat import (
ChunkerParams,
)
from ...helpers.time import format_timedelta, parse_timestamp
from ...platformflags import is_win32
def test_bin_to_hex():
@ -194,31 +195,31 @@ class TestLocationWithoutEnv:
def test_socket(self, monkeypatch, keys_dir):
monkeypatch.delenv("BORG_REPO", raising=False)
url = "socket:///c:/repo/path" if is_win32 else "socket:///repo/path"
path = "c:/repo/path" if is_win32 else "/repo/path"
assert (
repr(Location("socket:///repo/path"))
== "Location(proto='socket', user=None, pass=None, host=None, port=None, path='/repo/path')"
repr(Location(url))
== f"Location(proto='socket', user=None, pass=None, host=None, port=None, path='{path}')"
)
assert Location("socket:///some/path").to_key_filename() == keys_dir + "_some_path"
assert Location(url).to_key_filename().endswith("_repo_path")
def test_file(self, monkeypatch, keys_dir):
monkeypatch.delenv("BORG_REPO", raising=False)
url = "file:///c:/repo/path" if is_win32 else "file:///repo/path"
path = "c:/repo/path" if is_win32 else "/repo/path"
assert (
repr(Location("file:///some/path"))
== "Location(proto='file', user=None, pass=None, host=None, port=None, path='/some/path')"
repr(Location(url)) == f"Location(proto='file', user=None, pass=None, host=None, port=None, path='{path}')"
)
assert (
repr(Location("file:///some/path"))
== "Location(proto='file', user=None, pass=None, host=None, port=None, path='/some/path')"
)
assert Location("file:///some/path").to_key_filename() == keys_dir + "_some_path"
assert Location(url).to_key_filename().endswith("_repo_path")
@pytest.mark.skipif(is_win32, reason="still broken")
def test_smb(self, monkeypatch, keys_dir):
monkeypatch.delenv("BORG_REPO", raising=False)
assert (
repr(Location("file:////server/share/path"))
== "Location(proto='file', user=None, pass=None, host=None, port=None, path='//server/share/path')"
)
assert Location("file:////server/share/path").to_key_filename() == keys_dir + "__server_share_path"
assert Location("file:////server/share/path").to_key_filename().endswith("__server_share_path")
def test_folder(self, monkeypatch, keys_dir):
monkeypatch.delenv("BORG_REPO", raising=False)
@ -230,6 +231,7 @@ class TestLocationWithoutEnv:
)
assert Location("path").to_key_filename().endswith(rel_path)
@pytest.mark.skipif(is_win32, reason="Windows has drive letters in abs paths")
def test_abspath(self, monkeypatch, keys_dir):
monkeypatch.delenv("BORG_REPO", raising=False)
assert (
@ -259,6 +261,7 @@ class TestLocationWithoutEnv:
)
assert Location("ssh://user@host/relative/path").to_key_filename() == keys_dir + "host__relative_path"
@pytest.mark.skipif(is_win32, reason="Windows does not support colons in paths")
def test_with_colons(self, monkeypatch, keys_dir):
monkeypatch.delenv("BORG_REPO", raising=False)
assert (
@ -281,9 +284,6 @@ class TestLocationWithoutEnv:
monkeypatch.delenv("BORG_REPO", raising=False)
locations = [
"relative/path",
"/absolute/path",
"file:///absolute/path",
"socket:///absolute/path",
"ssh://host/relative/path",
"ssh://host//absolute/path",
"ssh://user@host:1234/relative/path",
@ -292,6 +292,9 @@ class TestLocationWithoutEnv:
"sftp://user@host:1234/relative/path",
"rclone:remote:path",
]
locations.insert(1, "c:/absolute/path" if is_win32 else "/absolute/path")
locations.insert(2, "file:///c:/absolute/path" if is_win32 else "file:///absolute/path")
locations.insert(3, "socket:///c:/absolute/path" if is_win32 else "socket:///absolute/path")
for location in locations:
assert (
Location(location).canonical_path() == Location(Location(location).canonical_path()).canonical_path()