fix: require a durable boundary before native add submission

This commit is contained in:
阿白叔 committed 2026-11-06 16:41:36 +08:00
1 parent d9a79b6535
commit 051498ba57
4 files changed
+54 -7

No files matched your search

+9 -3
View File
@@ -53,7 +53,8 @@ def test_add_timeout_publishes_cancellation_without_killing_native_owner(tmp_pat
@pytest.mark.parametrize('cancel', [True, False])
def test_cancellation_and_phase_at_native_add_submit(tmp_path, monkeypatch, cancel):
@pytest.mark.parametrize('journal_error', [False, True])
def test_cancellation_and_phase_at_native_add_submit(tmp_path, monkeypatch, cancel, journal_error):
import os,sys
from types import SimpleNamespace
import win32gui,win32process
@@ -95,9 +96,14 @@ def test_cancellation_and_phase_at_native_add_submit(tmp_path, monkeypatch, canc
'operation_id':'test-add-phase','session_record_path':str(root/'session.json')}
from cbb_refresh_verify.session_record import write_session_record
write_session_record(root/'worker-state.json', {'operation_id': 'test-add-phase', 'phase':'POSTCALL', 'processes':[]})
with pytest.raises(RuntimeError,match='NATIVE_ADD_CANCELLED' if cancel else 'unsafe OK posted'):
if journal_error:
def fail(*a, **kw): raise OSError('phase journal unavailable')
monkeypatch.setattr('cbb_refresh_verify.session_record.write_session_record', fail)
expected = OSError if journal_error and not cancel else RuntimeError
message = 'NATIVE_ADD_CANCELLED' if cancel else 'phase journal unavailable' if journal_error else 'unsafe OK posted'
with pytest.raises(expected, match=message):
native._probe_add_dialog_impl(SimpleNamespace(OnReusableBlocksEditor=lambda:None),job,desktop,{99},root)
assert state['posted']==([110] if cancel else [110,210])
assert state['posted']==([110] if cancel or journal_error else [110,210])
def test_unknown_pending_add_does_not_send_cleanup_dialog_actions(tmp_path, monkeypatch):