feat: complete native BOM and Harness execution acceptance
This commit is contained in:
1 parent
4f8fbd7806
commit
65438cb7e5
234 files changed
+24402
-865
No files matched your search
@@ -106,3 +106,40 @@ def test_batch_resource_record_retries_reader_denied_atomic_replace(tmp_path, mo
|
||||
for timer in timers:
|
||||
timer.join()
|
||||
reader.Close()
|
||||
|
||||
|
||||
def test_atomic_record_retries_a_delete_lock_released_before_the_error_is_observed(tmp_path, monkeypatch):
|
||||
import json
|
||||
import os
|
||||
if os.name != 'nt':
|
||||
pytest.skip('Windows delete-sharing race')
|
||||
import win32con
|
||||
import win32file
|
||||
from dx_productivity.trial_task_center import batch_resources
|
||||
|
||||
path = tmp_path / 'supervisor.json'
|
||||
path.write_text('{"state":"running"}', encoding='utf-8')
|
||||
real_replace = os.replace
|
||||
denials = []
|
||||
|
||||
def replace(source, target):
|
||||
if not denials:
|
||||
reader = win32file.CreateFile(str(path), win32con.GENERIC_READ,
|
||||
win32con.FILE_SHARE_READ | win32con.FILE_SHARE_WRITE, None,
|
||||
win32con.OPEN_EXISTING, 0, None)
|
||||
try:
|
||||
return real_replace(source, target)
|
||||
except PermissionError as error:
|
||||
denials.append(error.winerror)
|
||||
raise
|
||||
finally:
|
||||
# The native rename failed while locked; a later DELETE probe
|
||||
# cannot recover that fact after the reader has closed.
|
||||
reader.Close()
|
||||
return real_replace(source, target)
|
||||
|
||||
monkeypatch.setattr(batch_resources.os, 'replace', replace)
|
||||
batch_resources.write_record(path, {'state': 'released', 'business': 'saved'})
|
||||
assert denials == [5]
|
||||
assert json.loads(path.read_text(encoding='utf-8')) == {'state': 'released', 'business': 'saved'}
|
||||
assert not list(tmp_path.glob('*.tmp'))
|
||||
Reference in new issue
Block a user