fix: bound slow CAD startup and retain blocked COM diagnostics

This commit is contained in:
阿白叔 committed 2026-10-15 18:14:29 +08:00
1 parent 29ea67c35e
commit 9b2372e389
2 files changed
+40 -1

No files matched your search

+25
View File
@@ -107,6 +107,31 @@ def test_success_quits_owned_cad_before_releasing_desktop(monkeypatch, tmp_path)
assert record['state'] == 'released' and record['clean']
@pytest.mark.parametrize('ready_after', [90, None])
def test_slow_startup_is_bounded_and_cleanup_remains_owned(monkeypatch, tmp_path, ready_after):
events, _ = fake_desktop(monkeypatch, tmp_path)
clock = [0.0]
monkeypatch.setattr(runtime.time, 'monotonic', lambda: clock[0])
monkeypatch.setattr(runtime.time, 'sleep', lambda seconds: clock.__setitem__(0, clock[0] + seconds))
original = runtime.PrivateDesktop.start_process
def start(self, command, **kwargs):
process = original(self, command, **kwargs)
if command[0] == 'probe':
process.poll = lambda: 0 if ready_after is not None and clock[0] >= ready_after else None
return process
monkeypatch.setattr(runtime.PrivateDesktop, 'start_process', start)
if ready_after is None:
with pytest.raises(runtime.PrivateCadStartupError, match='bootstrap timed out'):
with runtime.IsolatedCadSession(tmp_path):
pytest.fail('unresponsive startup entered project work')
assert 119 <= clock[0] <= 121
assert ('release', False) in events
else:
with runtime.IsolatedCadSession(tmp_path):
assert clock[0] >= ready_after
assert ('release', False) in events
def test_repeated_session_preserves_prior_release_evidence(monkeypatch, tmp_path):
fake_desktop(monkeypatch, tmp_path)
with runtime.IsolatedCadSession(tmp_path) as first: