fix: diagnose PCB startup before ICDB maintenance

This commit is contained in:
阿白叔 committed 2026-11-04 22:53:16 +08:00
1 parent 4ebe098ef0
commit beb2b06fdf
9 files changed
+338 -30

No files matched your search

+15 -2
View File
@@ -39,6 +39,8 @@ def case(tmp_path, monkeypatch):
(work/'PCB/pcb.prj').write_text('KEY CentralLibrary "old.lmc"\n')
monkeypatch.setattr(entry, 'assert_native_idle', lambda: None)
request = VerifyRequest(library, 'IP101GR', tmp_path/'evidence', maintenance=True)
monkeypatch.setattr('cbb_refresh_verify.verify_runner._run_verify_serialized',
lambda req, **kw: startup_failure(req))
yield request, project, address
import cbb_refresh_verify.library_lock as locks
key = locks.LibraryLock(library).key
@@ -47,6 +49,16 @@ def case(tmp_path, monkeypatch):
if owner: owner['handle'].Close()
def startup_failure(request):
"""Stub the PCB process boundary with a complete current native failure."""
from cbb_refresh_verify.verify_runner import VerifyResult
database = request.lmc_file.parent/'ReusableBlocksLP'/request.block_name/'Work/database'
return VerifyResult('FAIL', safe_to_continue=True, error_category='ICDB_REPAIR_REQUIRED',
stderr=("The last server session on different server machine lost the connection to the database. "
"Please use iCDB Project Backup 'Repair project' functionality to fix this issue. "
f"Machine:[fixture-server] Path:[{database}] session:[fixture-current-session]"))
def patch_verification_after_fault(monkeypatch, runner, verify):
"""Inject only native process boundaries; production interprets the Output."""
from cbb_refresh_verify import native_repair
@@ -60,12 +72,13 @@ def patch_verification_after_fault(monkeypatch, runner, verify):
'output': output(target.project, target.database, fault=True),
'status': 'NOT_IN_USE', 'repair_required': True, 'release': {'native_exited': True}}
monkeypatch.setattr(native_repair, 'run_native_repair', native)
monkeypatch.setattr(runner, '_run_verify_serialized', verify)
monkeypatch.setattr(runner, '_run_verify_serialized',
lambda req, **kw: startup_failure(req) if req.diagnostic_only else verify(req, **kw))
@pytest.mark.parametrize('pcb_config', ['standard', 'legacy_template'])
@pytest.mark.parametrize('advertisement', ['present', 'absent'])
def test_explicit_maintenance_enters_official_repair_once_without_lostsession_fabrication(case, monkeypatch, pcb_config, advertisement):
def test_diagnosed_maintenance_enters_official_repair_once(case, monkeypatch, pcb_config, advertisement):
from cbb_refresh_verify import verify_runner as runner, native_repair
from test_native_repair import complete_native_success
request, project, address = case