fix: allow same-window retry after early PCB cancellation

This commit is contained in:
阿白叔 committed 2026-11-25 10:02:11 +08:00
1 parent 806c1696ab
commit 6aed02d26b
4 files changed
+84 -12

No files matched your search

+33 -1
View File
@@ -283,10 +283,42 @@ def test_verify_registers_ordinary_pcb_before_any_write_phase(tmp_path, monkeypa
lambda job, phase, **options: bound_phases.append((phase, options['identities'])))
def execute(job, emit):
emit(stage='pcb_launch')
emit(stage='pcb_worker_started', pcb_pid=12)
emit(stage='integration_action', action='UpdateNets')
return {'status': 'PASS'}
monkeypatch.setattr(mentor_adapter, 'execute_job', execute)
assert mentor_adapter.worker_main(request) == 0
assert bound_phases == [('PRECALL', [('native', 12)]), ('NATIVE_CALL', [])]
assert bound_phases == [('UNCONFIRMED', []), ('PRECALL', [('native', 12)]), ('NATIVE_CALL', [])]
def test_cancel_after_launcher_still_registers_startup_for_cleanup(tmp_path, monkeypatch):
from types import SimpleNamespace
from test_verify_worker_stability import exercise_worker
from cbb_refresh_verify import failed_session, mentor_adapter, pcb_bridge
job, events, execute = exercise_worker(tmp_path, monkeypatch)
stop = tmp_path/'cancel.signal'
job.update(operation='verify', operation_id='ordinary', desktop='CbbVerify_test',
diagnostic_only=False, session_record_path=str(tmp_path/'session.json'),
cancel_signal=str(stop))
def launch(*_):
stop.touch()
return SimpleNamespace(pid=1)
worker = iter((None, (2, 'pcb', 'command', 1)))
monkeypatch.setattr(mentor_adapter, 'launch_pcb_process', launch)
monkeypatch.setattr(mentor_adapter, 'select_reusable_circuit_worker', lambda *a, **kw: next(worker))
monkeypatch.setattr(pcb_bridge, 'wait_for_target_document', lambda *a, **kw:
pytest.fail('cancelled startup must never attach to the PCB document'))
closed = []
monkeypatch.setattr(failed_session, 'close_failed_startup', lambda job, pid, **kw:
closed.append(pid) or {'status': 'CLOSED'})
with pytest.raises(RuntimeError, match='VERIFY_CANCELLED'):
execute()
assert closed == [2]
assert any(e['stage'] == 'pcb_worker_started' and e['pcb_pid'] == 2 for e in events)
assert any(e['stage'] == 'startup_cancelled_prewrite' and e['pcb_pid'] == 2 for e in events)
+20
View File
@@ -364,3 +364,23 @@ def test_batch_summary_exposes_failures_only_report(qtbot, tmp_path):
window._batch_done(([VerifyResult('FAIL',stderr='Mentor error')],report))
assert '仅失败日志' in window.summary.detailedText()
assert str(report.with_name('failures-20260929-test.log')) in window.summary.detailedText()
def test_cancelled_pending_item_can_be_submitted_for_fresh_admission(qtbot, tmp_path):
records = (CbbRecord('Pending', 'LP', status='PENDING'), CbbRecord('Unconfirmed', 'LP'))
window = MainWindow(reader=lambda _: LibraryReadResult(records), data_root=tmp_path)
qtbot.addWidget(window)
window.lmc_edit.setText('lib.lmc')
window.load_library()
qtbot.waitUntil(lambda: not window.busy)
window.catalog_reader = object()
window._batch_requests = (window._request('Pending'), window._request('Unconfirmed'))
window._batch_refreshed(([VerifyResult('CANCELLED', safe_to_continue=False),
VerifyResult('FAIL', safe_to_continue=False)], None,
['Pending', 'Unconfirmed'], None))
assert window._records_by_name['Pending'].status == 'UNKNOWN'
assert window._eligible_names(require_status=True) == ['Pending']
assert window.batch_button.isEnabled()
window._apply_refreshed_records((('Pending',), {'Pending': 'READY'}, {}, ''))
assert window._eligible_names(require_status=True) == []