Merge pull request #7262 from ThomasWaldmann/skip-safe-unlink-test-windows

support win32 for test_safe_unlink* tests
This commit is contained in:
TW 2023-01-13 22:41:54 +01:00 committed by GitHub
commit ca1f1281d5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 4 deletions

View File

@ -31,4 +31,4 @@ jobs:
run: |
./dist/borg.exe -V
pip install -e .
pytest --benchmark-skip -k "not remote"
pytest --benchmark-skip -vv -rs -k "not remote"

View File

@ -45,7 +45,7 @@ from ..helpers import safe_unlink
from ..helpers.passphrase import Passphrase, PasswordRetriesExceeded
from ..platform import is_cygwin
from . import BaseTestCase, FakeInputs
from . import BaseTestCase, FakeInputs, are_hardlinks_supported
def test_bin_to_hex():
@ -1100,24 +1100,26 @@ def test_eval_escapes():
assert eval_escapes("äç\\n") == "äç\n"
@pytest.mark.skipif(not are_hardlinks_supported(), reason="hardlinks not supported")
def test_safe_unlink_is_safe(tmpdir):
contents = b"Hello, world\n"
victim = tmpdir / "victim"
victim.write_binary(contents)
hard_link = tmpdir / "hardlink"
hard_link.mklinkto(victim)
os.link(str(victim), str(hard_link)) # hard_link.mklinkto is not implemented on win32
safe_unlink(hard_link)
assert victim.read_binary() == contents
@pytest.mark.skipif(not are_hardlinks_supported(), reason="hardlinks not supported")
def test_safe_unlink_is_safe_ENOSPC(tmpdir, monkeypatch):
contents = b"Hello, world\n"
victim = tmpdir / "victim"
victim.write_binary(contents)
hard_link = tmpdir / "hardlink"
hard_link.mklinkto(victim)
os.link(str(victim), str(hard_link)) # hard_link.mklinkto is not implemented on win32
def os_unlink(_):
raise OSError(errno.ENOSPC, "Pretend that we ran out of space")