fix: persist release outcomes and guard active native backup sessions

This commit is contained in:
阿白叔 committed 2026-11-06 12:08:54 +08:00
1 parent d40192ee58
commit 5eb4b2d7ed
10 files changed
+669 -69

No files matched your search

+2 -1
View File
@@ -147,7 +147,7 @@ def test_backup_intermediate_success_does_not_allow_cooperative_close(output):
def test_force_requires_separate_explicit_argument_and_rechecks_identity(tmp_path, monkeypatch):
from cbb_refresh_verify import residual_sessions as sessions
library = tmp_path/'lib.lmc'; library.touch()
process = row(10, tmp_path/'ReusableBlocksLP/A/Work/A.prj')
process = row(10, tmp_path/'ReusableBlocksLP/A/Work/A.prj', name='ExpeditionPCB.exe')
monkeypatch.setattr(sessions, 'query_process_snapshot', lambda: [process.copy()])
monkeypatch.setattr(sessions, '_process_identity', lambda r: {**OWNERSHIP, 'created_handle': 'old', 'image': r['executable']})
monkeypatch.setattr(sessions, '_process_windows', lambda _: {})
@@ -311,6 +311,7 @@ def test_supported_force_revalidates_exact_handle_before_termination(monkeypatch
monkeypatch.setattr(win32event, 'WaitForSingleObject', lambda handle, timeout:
win32con.WAIT_OBJECT_0 if timeout else win32con.WAIT_TIMEOUT)
monkeypatch.setattr(sessions, '_force_ownership', lambda *args: dict(OWNERSHIP))
monkeypatch.setattr(sessions, '_process_windows', lambda _: {10: []})
calls = []
monkeypatch.setattr(win32api, 'TerminateProcess', lambda handle, code: calls.append((handle, code)))
assert sessions._force_close({**process, 'created_handle': 'reused'})['release_status'] == 'IDENTITY_CHANGED'