fix: publish new Windows outputs without requiring hard links
This commit is contained in:
@@ -44,15 +44,25 @@ def test_transactions_retain_external_save_at_commit(tmp_path, monkeypatch, oper
|
||||
|
||||
def test_creation_does_not_overwrite_file_created_at_commit(tmp_path, monkeypatch):
|
||||
path = tmp_path/'new.out'
|
||||
link = files.os.link
|
||||
operation = 'rename' if files.os.name == 'nt' else 'link'
|
||||
publish = getattr(files.os, operation)
|
||||
def race(src, dst):
|
||||
path.write_bytes(b'External creation')
|
||||
link(src, dst)
|
||||
monkeypatch.setattr(files.os, 'link', race)
|
||||
publish(src, dst)
|
||||
monkeypatch.setattr(files.os, operation, race)
|
||||
with pytest.raises(FileExistsError): files.atomic_write(path, b'Export', expected=None)
|
||||
assert path.read_bytes() == b'External creation'
|
||||
|
||||
|
||||
@pytest.mark.skipif(files.os.name != 'nt', reason='Windows exclusive rename')
|
||||
def test_new_output_does_not_require_hardlinks(tmp_path, monkeypatch):
|
||||
def unsupported(*args): raise OSError('Hard links are not supported on this volume')
|
||||
monkeypatch.setattr(files.os, 'link', unsupported)
|
||||
path=tmp_path/'new.out'
|
||||
files.atomic_write(path,b'Exported',expected=None)
|
||||
assert path.read_bytes()==b'Exported'
|
||||
|
||||
|
||||
def test_second_conflict_during_recovery_keeps_both_external_versions(tmp_path, monkeypatch):
|
||||
path = tmp_path/'existing.out'; path.write_bytes(b'Original')
|
||||
expected = files.fingerprint(path)
|
||||
|
||||
Reference in New Issue
Block a user