fix: detect owned CAD exit during startup without waiting for probe timeout
This commit is contained in:
1 parent
3b8a93e12c
commit
264fee5127
2 files changed
+23
No files matched your search
@@ -128,6 +128,9 @@ class IsolatedCadSession:
|
||||
deadline = time.monotonic() + 120
|
||||
while probe.poll() is None:
|
||||
self._check_abort()
|
||||
cad_exit = self.cad.poll()
|
||||
if cad_exit is not None:
|
||||
raise WorkerMonitorError(f'owned private CAD exited during startup: exit code {cad_exit}')
|
||||
if time.monotonic() >= deadline:
|
||||
raise WorkerMonitorError('private CAD bootstrap timed out')
|
||||
time.sleep(0.05)
|
||||
|
||||
@@ -236,6 +236,26 @@ def test_slow_startup_is_bounded_and_cleanup_remains_owned(monkeypatch, tmp_path
|
||||
assert ('release', False) in events
|
||||
|
||||
|
||||
def test_owned_cad_exit_does_not_wait_for_unresponsive_startup_probe(monkeypatch, tmp_path):
|
||||
events, cad = 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':
|
||||
cad.returncode = 73
|
||||
process.poll = lambda: None
|
||||
return process
|
||||
monkeypatch.setattr(runtime.PrivateDesktop, 'start_process', start)
|
||||
with pytest.raises(runtime.PrivateCadStartupError, match='exited during startup.*73'):
|
||||
with runtime.IsolatedCadSession(tmp_path):
|
||||
pytest.fail('exited CAD must never enter project work')
|
||||
assert clock[0] < 1
|
||||
assert events.index('close-helper') < events.index(('release', False))
|
||||
|
||||
|
||||
def test_repeated_session_preserves_prior_release_evidence(monkeypatch, tmp_path):
|
||||
fake_desktop(monkeypatch, tmp_path)
|
||||
with runtime.IsolatedCadSession(tmp_path) as first:
|
||||
|
||||
Reference in new issue
Block a user