feat: replace automatic ICDB maintenance with batch inspection
This commit is contained in:
1 parent
beb2b06fdf
commit
53118bae19
15 files changed
+397
-67
No files matched your search
@@ -0,0 +1,40 @@
|
||||
# ICDB 批量检查
|
||||
|
||||
## 当前行为
|
||||
|
||||
应用原“非 READY ICDB 检查与修复”入口改为“ICDB 批量检查”。检查可见非 READY 工程,有勾选时仅处理可见勾选项,READY 即使被勾选也排除。普通 CBB 校验、中心库管理和手动“版本历史与备份…”继续使用各自入口。
|
||||
|
||||
检查通过原生 Project Backup 加载所选工程,收集本次 Output 和占用结论,不启动 PCB,不调用 Repair、Restore 或版本选择。检查入口即使收到旧请求的 `auto_repair=True` 也只执行检查;其原生请求始终携带 `inspection_only=True`。内部显式恢复辅助 API 及其既有测试保留,应用批量检查不再调用它们。
|
||||
|
||||
结果分为:
|
||||
|
||||
- 未发现异常:返回 CHECKED,仅表示本次原生检查未发现已识别的 ICDB 异常,不推定 CBB READY。
|
||||
- 发现 ICDB 问题:保留 FAIL 和明确的 ICDB 故障分类,不执行修复。
|
||||
- 工程占用:记录占用,不把它解释成数据库损坏。
|
||||
- 无法确认:缺少有效工程、输出不完整、目标不符、未知错误等均保留原始证据,不显示健康。
|
||||
|
||||
本项检查的原生进程确认退出后,发现问题、占用或未知结果可继续下一项;本次检查尚未退出或缺少退出证据时停止剩余批次,不强制终止原生进程。用户取消也停止队列。需要修复或回退时,由用户通过原生备份窗口选择操作。
|
||||
|
||||
## 去除检查路径的修复限制
|
||||
|
||||
目标绑定复用手动原生入口的唯一主 PRJ 和明确的工程内 `iCDBDir`。检查不要求 PCB、Layout 或 `icdb.dat` 预先存在,也不借用 Repair 的地址记录唯一性和多个数据库候选排除规则。缺失或损坏由原生加载检查给出结论;无法识别的结果保留为未知。
|
||||
|
||||
原生 worker 的检查模式不再因本机存在其他 PCB/Library Manager 而直接拒绝,也不执行 Repair 专用的数据库独占准入;它仍在启动前检查所选工程的文件链接,目标是否占用由原生 Output 判定。
|
||||
|
||||
检查使用实际库协调锁,忽略历史协调检查点,不自动归档旧记录或删除地址文件。释放必须有明确的原生退出证据,或 worker 明确报告“尚未启动原生进程”;结果字段/PID 缺失不推定释放。该调整只覆盖新检查路径,不能据此宣称维护/管理/释放检查中的所有过宽条件均已解决。
|
||||
|
||||
## 界面及报告
|
||||
|
||||
批量检查不再显示手动备份要求、自动修复承诺或“修复并校验通过”计数。确认清单、进度、备注、汇总及完整/异常/JSON 报告均按检查目标和检查分类输出。占用和未知备注不加“ICDB 问题”标签。默认副本恢复仍排除缺少 PCB 的工程,检查候选可以包含它们。
|
||||
|
||||
## 验证边界
|
||||
|
||||
本轮先以失败测试确认旧入口会打开 PCB、可进入 Repair、使用修复准入及误标未知结果,再修改入口。测试覆盖健康、明确故障、占用、未知、异常修复返回、缺少退出证据、明确未启动、取消、队列继续、缺 PCB/Layout/icdb、多数据库、READY 排除、仅检查汇总和报告。
|
||||
|
||||
全量测试、冻结模块一致性、启动冒烟及隔离库实际按钮记录保存在 `diagnostics/icdb-batch-check-20261104/`;最终包的 `BUILD.json` 记录实际结果。隔离验证只执行新批量检查,不在原库运行 Repair/Restore。
|
||||
|
||||
最终全量 **1304 passed**,270.79 秒,退出码 0,1 条既有 pywinauto STA 警告;编译和差异检查通过。冻结的 14 个关键 Python 模块及两个 VBS 与源码一致,启动/退出、Unicode/UNC 协议及包内 x86 运行库加载通过。独立审查发现的修复准入误用和缺字段推定释放均以先失败后通过的回归修正,复审无剩余必要 P1/P2。
|
||||
|
||||
最终冻结包通过真实按钮在自有隔离库的 PENDING `IP101GR` 上检查,原生返回数据库不一致且未占用,应用记录 `ICDB_REPAIR_REQUIRED`、`safe_to_continue=true`,汇总“发现问题 1”。原生请求为 `inspection_only=true`,返回 `repair_requested=false`,没有 PCB 请求或恢复尝试。原生及应用均正常退出,中心库 LMC 和工程 PRJ、DXP、icdb.dat、PCB、LayoutDB 六个文件的 SHA-256 前后一致。
|
||||
|
||||
原生加载检查不能保证 PCB 实际打开一定正常,也不能替代普通 CBB 校验。现场自动修复问题不作成功结论;工单和 WIP PR 保持开放。
|
||||
@@ -19,6 +19,11 @@ def maintenance_counts(results):
|
||||
and attempt.get('native_status') == 'REPAIRED' for attempt in attempts)
|
||||
return {'total': len(results), 'passed': sum(r.status == 'PASS' for r in results),
|
||||
'checked_without_repair': sum(r.status == 'CHECKED' for r in results),
|
||||
'issues_found': sum(r.error_category == 'ICDB_REPAIR_REQUIRED' for r in results),
|
||||
'in_use': sum(r.error_category == 'ICDB_DATABASE_IN_USE' for r in results),
|
||||
'unconfirmed': sum(r.status not in ('CHECKED', 'SKIPPED', 'CANCELLED')
|
||||
and r.error_category not in ('ICDB_REPAIR_REQUIRED', 'ICDB_DATABASE_IN_USE') for r in results),
|
||||
'cancelled': sum(r.status == 'CANCELLED' for r in results),
|
||||
'skipped': sum(r.status == 'SKIPPED' for r in results),
|
||||
'repaired': repaired, 'review_required': review,
|
||||
'version_choice_required': version_choice,
|
||||
@@ -28,7 +33,7 @@ def maintenance_counts(results):
|
||||
|
||||
def write_maintenance_report(requests, results, batch_report, skipped_names):
|
||||
path = batch_report.with_name(batch_report.name.replace('batch-', 'icdb-', 1)).with_suffix('.json')
|
||||
record = {'operation': 'visible_non_ready_icdb_check_and_repair',
|
||||
record = {'operation': 'visible_non_ready_icdb_batch_check', 'automatic_repair': False,
|
||||
'library': str(requests[0].lmc_file), 'includes_ready': False,
|
||||
'target_names': [request.block_name for request in requests],
|
||||
'shared_database_repair_supported': False,
|
||||
|
||||
@@ -195,6 +195,85 @@ def maintenance_target_guard(request, expected=None, *, stop=None):
|
||||
yield {'target': target, 'context': context, 'project': project, 'pcb': pcb}
|
||||
|
||||
|
||||
def run_icdb_check(request, *, progress=None, stop=None):
|
||||
"""Inspect through Project Backup; never launch PCB, Repair or Restore."""
|
||||
from .verify_runner import VerifyResult
|
||||
from .library_lock import LibraryLock, LibraryBusy
|
||||
from .native_repair import run_native_repair, RepairTarget
|
||||
from .native_backup import native_backup_project
|
||||
from .backup_recovery import _project_text
|
||||
from .native_occupancy import confirmed_inspection
|
||||
root = Path(request.evidence_dir).resolve()/('icdb-check-'+uuid4().hex[:12])
|
||||
library_root = Path(request.lmc_file).resolve().parent
|
||||
if root.is_relative_to(library_root) or library_root.is_relative_to(root):
|
||||
return VerifyResult('FAIL', error_category='ICDB_INSPECTION_UNCONFIRMED',
|
||||
stderr='检查记录目录需位于中心库之外。')
|
||||
record = {'operation': 'icdb_batch_check', 'automatic_repair': False,
|
||||
'library': str(request.lmc_file), 'block': request.block_name}
|
||||
released = True
|
||||
def check():
|
||||
if stop is not None and stop.is_set():
|
||||
raise InterruptedError('已取消检查。')
|
||||
def save(result):
|
||||
report = root/'result.json'
|
||||
recorded = replace(result, evidence_path=report)
|
||||
try:
|
||||
report.write_text(json.dumps({**record, 'result': asdict(recorded)},
|
||||
ensure_ascii=False, default=str, indent=2), encoding='utf-8')
|
||||
except OSError as error:
|
||||
import logging
|
||||
logging.getLogger(__name__).warning('icdb_check_report_unavailable path=%s error=%s', report, error)
|
||||
return result
|
||||
return recorded
|
||||
try:
|
||||
check()
|
||||
root.mkdir(parents=True, exist_ok=False)
|
||||
with LibraryLock(request.lmc_file, checkpoint=False, safe_to_release=lambda: released):
|
||||
project = native_backup_project(request.lmc_file, request.block_name)
|
||||
values = re.findall(r'^KEY iCDBDir "([^"\r\n]*)"', _project_text(project), re.M)
|
||||
if (len(values) != 1 or not values[0] or PureWindowsPath(values[0]).drive
|
||||
or PureWindowsPath(values[0]).root
|
||||
or (project.parent/values[0]).resolve() != (project.parent/'database').resolve()):
|
||||
raise ValueError('无法确认工程的 ICDB 数据库路径。')
|
||||
target = RepairTarget(project, project.parent/'database')
|
||||
record['target'] = asdict(target)
|
||||
check()
|
||||
if progress:
|
||||
progress({'stage': 'icdb_ownership_check', 'block': request.block_name,
|
||||
'detail': '正在检查 ICDB 状态'})
|
||||
released = False
|
||||
inspection = run_native_repair(target, root/'native-inspection',
|
||||
mentor_bin=request.mentor_bin, timeout_seconds=min(30, request.timeout_seconds),
|
||||
progress=progress, inspection_only=True, stop=stop)
|
||||
record['native_inspection'] = inspection
|
||||
released = (inspection.get('release', {}).get('native_exited') is True
|
||||
or inspection.get('native_started') is False
|
||||
and inspection.get('native_pid') is None and inspection.get('worker_pid') is None)
|
||||
if ((stop is not None and stop.is_set())
|
||||
or inspection.get('status') in ('CANCELLED', 'CANCELLED_UNRELEASED')):
|
||||
return save(VerifyResult('CANCELLED', safe_to_continue=released, stderr='已取消 ICDB 检查。'))
|
||||
if not confirmed_inspection(target, inspection):
|
||||
return save(VerifyResult('FAIL', safe_to_continue=released,
|
||||
error_category='ICDB_INSPECTION_UNCONFIRMED',
|
||||
stderr='无法确认 ICDB 状态。' + str(inspection.get('detail', ''))))
|
||||
if inspection['status'] == 'IN_USE':
|
||||
return save(VerifyResult('BLOCKED', safe_to_continue=released,
|
||||
error_category='ICDB_DATABASE_IN_USE', stderr='工程正在使用,暂未完成 ICDB 检查。'))
|
||||
if inspection['repair_required']:
|
||||
return save(VerifyResult('FAIL', safe_to_continue=released,
|
||||
error_category='ICDB_REPAIR_REQUIRED', stderr='发现 ICDB 问题,未执行修复。'))
|
||||
return save(VerifyResult('CHECKED', safe_to_continue=released,
|
||||
stdout='ICDB 检查未发现异常,无需修复。'))
|
||||
except InterruptedError:
|
||||
return save(VerifyResult('CANCELLED', safe_to_continue=released, stderr='已取消 ICDB 检查。'))
|
||||
except LibraryBusy as error:
|
||||
return save(VerifyResult('BLOCKED', safe_to_continue=False,
|
||||
error_category='LIBRARY_IN_USE', stderr=str(error)))
|
||||
except Exception as error:
|
||||
return save(VerifyResult('FAIL', safe_to_continue=released,
|
||||
error_category='ICDB_INSPECTION_UNCONFIRMED', stderr=f'无法确认 ICDB 状态:{error}'))
|
||||
|
||||
|
||||
def run_diagnosed_maintenance(request, *, diagnose, progress=None, stop=None):
|
||||
"""Open PCB once; only a current matching native fault admits maintenance."""
|
||||
from .verify_runner import VerifyResult
|
||||
|
||||
@@ -256,7 +256,8 @@ def run_native_repair(target, root, *, mentor_bin='', timeout_seconds=300, progr
|
||||
maintenance_context=None, inspection_only=False, stop=None):
|
||||
"""Supervise the GUI on its own desktop; a repair timeout never kills it."""
|
||||
if stop is not None and stop.is_set():
|
||||
return {'status': 'CANCELLED', 'detail': '原生操作启动前已取消', 'release': {'safe_to_continue': True}}
|
||||
return {'status': 'CANCELLED', 'native_started': False,
|
||||
'detail': '原生操作启动前已取消', 'release': {'safe_to_continue': True}}
|
||||
from .desktop_worker import DesktopWorker
|
||||
root = Path(root)
|
||||
root.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
@@ -271,7 +271,7 @@ def repair_worker_main(job_path):
|
||||
stop = _CancellationFile(job['cancel_signal'])
|
||||
root = Path(job['root'])
|
||||
project, database = Path(job['project']), Path(job['database'])
|
||||
result = {'status': 'BLOCKED', 'project': str(project), 'database': str(database),
|
||||
result = {'status': 'BLOCKED', 'native_started': False, 'project': str(project), 'database': str(database),
|
||||
'release': {'safe_to_continue': False}}
|
||||
process = None
|
||||
def emit(**event):
|
||||
@@ -293,7 +293,7 @@ def repair_worker_main(job_path):
|
||||
executable = home/'iCDB/win32/bin/iCDBProjectBackup.exe'
|
||||
command_id = None if job.get('inspection_only') else _repair_command(executable)
|
||||
from .mentor_adapter import pcb_processes, _process_details
|
||||
if pcb_processes() or _process_details('LibraryManager.exe'):
|
||||
if not job.get('inspection_only') and (pcb_processes() or _process_details('LibraryManager.exe')):
|
||||
raise ValueError('REPAIR_DATABASE_IN_USE')
|
||||
maintenance_context = job.get('maintenance_context')
|
||||
if maintenance_context is not None:
|
||||
@@ -302,9 +302,16 @@ def repair_worker_main(job_path):
|
||||
maintenance_request = VerifyRequest(Path(maintenance_context['library']),
|
||||
maintenance_context['block'], root, maintenance=True)
|
||||
emit(stage='native_preflight', detail='正在核对本次原生工具的目标及占用')
|
||||
check_repair_access(RepairTarget(project, database))
|
||||
emit(stage='backup_skipped', reason='manual_backup_policy',
|
||||
detail='应用不自动备份;Mentor 原生修复仍可能生成自身备份。')
|
||||
if job.get('inspection_only'):
|
||||
from .scoped_manifest import scan_tree
|
||||
def check_cancelled():
|
||||
if stop.is_set():
|
||||
raise InterruptedError('检查已取消')
|
||||
scan_tree(project.parent, check=check_cancelled)
|
||||
else:
|
||||
check_repair_access(RepairTarget(project, database))
|
||||
emit(stage='backup_skipped', reason='manual_backup_policy',
|
||||
detail='应用不自动备份;Mentor 原生修复仍可能生成自身备份。')
|
||||
if Path(job['cancel_signal']).exists():
|
||||
raise ValueError('REPAIR_CANCELLED_BEFORE_LAUNCH')
|
||||
if maintenance_context is not None:
|
||||
@@ -324,6 +331,7 @@ def repair_worker_main(job_path):
|
||||
if Path(job['cancel_signal']).exists():
|
||||
raise ValueError('REPAIR_CANCELLED_BEFORE_LAUNCH')
|
||||
process = subprocess.Popen([str(executable), '-p', str(project)], cwd=str(project.parent))
|
||||
result['native_started'] = True
|
||||
result['native_pid'] = process.pid
|
||||
emit(stage='native_started', pid=process.pid, project=str(project))
|
||||
if job.get('inspection_only'):
|
||||
|
||||
@@ -152,8 +152,8 @@ class MainWindow(QWidget):
|
||||
self.browse_button = QPushButton('选择'); self.browse_button.clicked.connect(self.choose_library)
|
||||
self.selected_batch_button = QPushButton('批量校验已选'); self.selected_batch_button.clicked.connect(self.verify_selected)
|
||||
self.batch_button = QPushButton('校验可见非 READY'); self.batch_button.clicked.connect(self.verify_all)
|
||||
self.icdb_repair_button = QPushButton('非 READY ICDB 检查与修复'); self.icdb_repair_button.clicked.connect(self.repair_icdb_all)
|
||||
self.icdb_repair_button.setToolTip('忽略 READY 项(包括已勾选项);先由原生工具检查占用和数据库,仅确认当前工程需要 ICDB Repair 时才修复。')
|
||||
self.icdb_repair_button = QPushButton('ICDB 批量检查'); self.icdb_repair_button.clicked.connect(self.repair_icdb_all)
|
||||
self.icdb_repair_button.setToolTip('检查可见的非 READY 工程;有勾选时仅检查勾选项。')
|
||||
self.backup_restore_button = QPushButton('从备份恢复 CBB…')
|
||||
self.backup_restore_button.clicked.connect(self.restore_backup)
|
||||
self.reimport_button = QPushButton('选择工程副本恢复失败项…')
|
||||
@@ -308,7 +308,8 @@ class MainWindow(QWidget):
|
||||
self.batch_button.setEnabled(ready and bool(self._eligible_names()))
|
||||
self.selected_batch_button.setEnabled(ready and bool(self._eligible_names(checked_only=True)))
|
||||
self.icdb_repair_button.setEnabled(ready and bool(self._maintenance_names()))
|
||||
self.backup_restore_button.setEnabled(ready and bool(self._maintenance_names()))
|
||||
self.backup_restore_button.setEnabled(ready and bool(
|
||||
self._eligible_names(checked_only=bool(self.selected_records()))))
|
||||
self.release_library_button.setEnabled(not self.busy and bool(self.lmc_edit.text().strip()))
|
||||
reasons = []
|
||||
for operation, widget in (('add', self.add_button), ('update', self.update_button), ('remove', self.remove_button)):
|
||||
@@ -488,7 +489,8 @@ class MainWindow(QWidget):
|
||||
return [r.name for r in records if r.status != 'READY' and r.name not in self.skipped_names]
|
||||
|
||||
def _maintenance_names(self):
|
||||
return self._eligible_names(checked_only=bool(self.selected_records()))
|
||||
records = self.selected_records() or self.visible_records()
|
||||
return [record.name for record in records if record.status != 'READY']
|
||||
|
||||
def _check_visible(self, state):
|
||||
self.cbb_table.blockSignals(True)
|
||||
@@ -684,16 +686,14 @@ class MainWindow(QWidget):
|
||||
self._run(names)
|
||||
|
||||
def repair_icdb_all(self):
|
||||
from .backup_notice import MANUAL_BACKUP_NOTICE
|
||||
if self.busy or not self.loaded_path: return
|
||||
names = self._maintenance_names()
|
||||
if not names: return
|
||||
answer = QMessageBox.question(self, '非 READY ICDB 检查与修复',
|
||||
f'{MANUAL_BACKUP_NOTICE}\nMentor 原生修复可能生成自身备份。\n\n当前中心库:{self.loaded_path}\n\n'
|
||||
f'将尝试打开 {len(names)} 个可见非 READY CBB'
|
||||
f'{"(仅勾选项)" if self.selected_records() else ""}。未确认状态不等于损坏。\n'
|
||||
'仅本次打开明确报出当前工程 ICDB 故障时调用原生修复,完成后可单独运行校验。\n'
|
||||
'若恢复了历史备份,请核对工程版本。\n\n是否开始?', QMessageBox.Yes | QMessageBox.No, QMessageBox.No)
|
||||
answer = QMessageBox.question(self, 'ICDB 批量检查',
|
||||
f'当前中心库:{self.loaded_path}\n\n'
|
||||
f'将检查 {len(names)} 个可见非 READY CBB'
|
||||
f'{"(仅勾选项)" if self.selected_records() else ""}。\n'
|
||||
'仅检查 ICDB 状态,不执行修复或回退。\n\n是否开始?', QMessageBox.Yes | QMessageBox.No, QMessageBox.No)
|
||||
if answer == QMessageBox.Yes:
|
||||
self._run(names, maintenance=True)
|
||||
|
||||
@@ -857,7 +857,7 @@ class MainWindow(QWidget):
|
||||
self.icdb_phase.setText('准备检查…')
|
||||
self.stop.clear(); self.recovery_path = None; self.recovery_button.setEnabled(False)
|
||||
self.output.clear(); self.status_label.setText(
|
||||
f'正在非 READY ICDB 检查与修复:共 {len(names)} 个 CBB' if maintenance
|
||||
f'正在 ICDB 批量检查:共 {len(names)} 个 CBB' if maintenance
|
||||
else f'正在校验:共 {len(names)} 个 CBB')
|
||||
def action():
|
||||
from cbb_refresh_verify.verify_runner import read_library_flag_if_available, run_verify
|
||||
@@ -992,7 +992,7 @@ class MainWindow(QWidget):
|
||||
row = self._row_by_name.get(block)
|
||||
if row is not None:
|
||||
detail = str(event.get('detail') or event.get('error') or '').strip()
|
||||
if str(event.get('error_category', '')).startswith('ICDB') and detail:
|
||||
if event.get('error_category') == 'ICDB_REPAIR_REQUIRED' and detail:
|
||||
detail = 'ICDB 问题:' + detail
|
||||
label = str(stage) if not detail else f'{stage}: {detail[:96]}'
|
||||
self.cbb_table.item(row, 3).setText(label)
|
||||
@@ -1038,24 +1038,22 @@ class MainWindow(QWidget):
|
||||
if self._global_icdb_run:
|
||||
from cbb_refresh_verify.icdb_maintenance import maintenance_counts
|
||||
counts = maintenance_counts(results)
|
||||
text = ('非 READY ICDB 检查已结束\n'
|
||||
f'修复并校验通过 {passed},失败/受阻 {failed},队列未执行 {skipped}\n'
|
||||
f'仅检查、未修复 {counts["checked_without_repair"]}(不计入修复成功)\n'
|
||||
f'原生修复完成、待单独校验 {counts["repaired_unverified"]},恢复备份待复核 {counts["review_required"]},'
|
||||
f'ICDB已修复/PCB版本待选 {counts["version_choice_required"]},'
|
||||
f'修复未确认 {counts["repair_unconfirmed"]}\n'
|
||||
text = ('ICDB 批量检查已结束\n'
|
||||
f'未发现异常 {counts["checked_without_repair"]},发现问题 {counts["issues_found"]},'
|
||||
f'占用 {counts["in_use"]},无法确认 {counts["unconfirmed"]},'
|
||||
f'取消 {counts["cancelled"]},队列未执行 {skipped}\n'
|
||||
f'完整日志:{report}\n仅失败日志:{failure_report_path(report)}')
|
||||
self.icdb_phase.setText('已停止,存在待处理项目' if failed or skipped else '已完成非 READY 检查')
|
||||
self.icdb_phase.setText('批量检查已结束')
|
||||
if any(not result.safe_to_continue for result in results):
|
||||
text += '\n未确认数据库或会话安全,已停止剩余校验。请查看恢复现场。'
|
||||
status_text = (f'已结束:通过 {passed},失败/受阻 {failed},'
|
||||
f'仅检查 {checked},未执行 {skipped + len(self.skipped_names)}。')
|
||||
if repaired:
|
||||
if self._global_icdb_run:
|
||||
status_text = (f'检查结束:未发现异常 {counts["checked_without_repair"]},'
|
||||
f'发现问题 {counts["issues_found"]},占用 {counts["in_use"]},'
|
||||
f'无法确认 {counts["unconfirmed"]},取消 {counts["cancelled"]},未执行 {skipped}。')
|
||||
if repaired and not self._global_icdb_run:
|
||||
status_text += f'\n原生 ICDB 修复完成 {repaired},待单独校验。'
|
||||
if self._global_icdb_run and counts['review_required']:
|
||||
status_text += f'\n恢复备份待复核 {counts["review_required"]},请核对工程版本。'
|
||||
if self._global_icdb_run and counts['version_choice_required']:
|
||||
status_text += f'\n待选择 PCB 版本 {counts["version_choice_required"]}。'
|
||||
first_failure = next((result.stderr for result in results
|
||||
if result.status not in ('PASS', 'SKIPPED', 'CHECKED', 'REPAIRED') and result.stderr), '')
|
||||
if first_failure:
|
||||
@@ -1072,7 +1070,7 @@ class MainWindow(QWidget):
|
||||
status_text += guidance
|
||||
self.status_label.setText(status_text.replace('\n', ' ')); self.output.append(text)
|
||||
self.summary = QMessageBox(self)
|
||||
self.summary.setWindowTitle('ICDB 维护结果' if self._global_icdb_run else 'CBB 校验结果')
|
||||
self.summary.setWindowTitle('ICDB 批量检查结果' if self._global_icdb_run else 'CBB 校验结果')
|
||||
self.summary.setText(status_text)
|
||||
self.summary.setDetailedText(text)
|
||||
self.summary.setIcon(QMessageBox.Warning if failed else QMessageBox.Information)
|
||||
@@ -1104,7 +1102,8 @@ class MainWindow(QWidget):
|
||||
management = getattr(self, 'management_dialog', None)
|
||||
if management is not None and management.isVisible():
|
||||
management.stop.set()
|
||||
self.stop.set(); self.status_label.setText('已请求取消;检查将停止,原生写入只等待安全结束,不强制终止。'); self._update()
|
||||
self.stop.set(); self.status_label.setText('已请求取消 ICDB 检查。' if self._global_icdb_run else
|
||||
'已请求取消;检查将停止,原生写入只等待安全结束,不强制终止。'); self._update()
|
||||
|
||||
def _failed(self, error):
|
||||
if self.library_lease is not None:
|
||||
|
||||
@@ -547,11 +547,8 @@ def run_verify(request, *, progress=None, flag_reader=None, process_runner=None,
|
||||
return VerifyResult('BLOCKED', stderr='已有 CBB 校验任务运行,请等待结束。',
|
||||
safe_to_continue=False)
|
||||
if request.maintenance:
|
||||
from .maintenance_entry import run_diagnosed_maintenance
|
||||
return run_diagnosed_maintenance(request, progress=progress, stop=stop,
|
||||
diagnose=lambda probe: run_verify(probe, progress=progress, flag_reader=flag_reader,
|
||||
process_runner=process_runner, port_check=port_check,
|
||||
dialog_supervisor_factory=dialog_supervisor_factory, version_prompt=version_prompt, stop=stop))
|
||||
from .maintenance_entry import run_icdb_check
|
||||
return run_icdb_check(request, progress=progress, stop=stop)
|
||||
from .library_lock import LibraryLock, LibraryBusy
|
||||
if Path(request.lmc_file).is_file():
|
||||
try:
|
||||
@@ -1248,6 +1245,13 @@ def write_failure_report(requests, results, root, *, path=None):
|
||||
skipped = len(results)-passed-len(failed)-checked-repaired
|
||||
lines = ['CBB Verify 失败清单', f'总数: {len(results)} 成功: {passed} 失败: {len(failed)} 未执行: {skipped} 仅检查未修复: {checked} ICDB已修复待校验: {repaired}',
|
||||
'CBB\t状态\t错误分类\t失败阶段\t桥状态\t原始错误\t证据\t实际耗时(秒)']
|
||||
if requests and all(req.maintenance for req in requests):
|
||||
from .icdb_maintenance import maintenance_counts
|
||||
counts = maintenance_counts(results)
|
||||
lines[:2] = ['ICDB 检查异常清单',
|
||||
f'总数: {len(results)} 未发现异常: {checked} 发现问题: {counts["issues_found"]} '
|
||||
f'占用: {counts["in_use"]} 无法确认: {counts["unconfirmed"]} '
|
||||
f'取消: {counts["cancelled"]} 未执行: {counts["skipped"]}']
|
||||
for req, result in failed:
|
||||
timings = ' '.join(f'{key}={value:.3f}s' +
|
||||
('(unfinished)' if key in result.incomplete_timing_phases else '')
|
||||
@@ -1268,6 +1272,8 @@ def write_batch_report(requests, results, root):
|
||||
path = root/('batch-' + time.strftime('%Y%m%d-%H%M%S') + '-' + uuid4().hex[:6] + '.log')
|
||||
lines = ['CBB Verify 批量结果',
|
||||
'流程: LMC 原生 Verify / ReusableCircuit PCB -> Project Integration -> Save/Close -> IsVerifiedReuseBlock READY(金标准)']
|
||||
if requests and all(req.maintenance for req in requests):
|
||||
lines = ['ICDB 批量检查结果', '流程: 原生 Project Backup 加载检查;不执行 Repair、Restore 或 CBB 校验。']
|
||||
for req, result in zip(requests, results):
|
||||
detail = _report_field(result.stderr or result.stdout.strip()[:200])
|
||||
seconds = ' '.join(f'{key}={value:.3f}s' +
|
||||
|
||||
@@ -0,0 +1,181 @@
|
||||
"""Batch ICDB inspection never opens PCB or dispatches Repair."""
|
||||
from dataclasses import replace
|
||||
import json
|
||||
|
||||
import pytest
|
||||
|
||||
from test_maintenance_entry import case, no_native_launch
|
||||
from test_maintenance_diagnosis import inspection
|
||||
|
||||
|
||||
@pytest.mark.parametrize('scenario,status,category,safe', [
|
||||
('healthy', 'CHECKED', '', True),
|
||||
('fault', 'FAIL', 'ICDB_REPAIR_REQUIRED', True),
|
||||
('busy', 'BLOCKED', 'ICDB_DATABASE_IN_USE', True),
|
||||
('unknown', 'FAIL', 'ICDB_INSPECTION_UNCONFIRMED', True),
|
||||
('unexpected_repair', 'FAIL', 'ICDB_INSPECTION_UNCONFIRMED', True),
|
||||
('missing_exit_proof', 'FAIL', 'ICDB_INSPECTION_UNCONFIRMED', False),
|
||||
('not_launched', 'FAIL', 'ICDB_INSPECTION_UNCONFIRMED', True),
|
||||
('unreleased', 'FAIL', 'ICDB_INSPECTION_UNCONFIRMED', False),
|
||||
('cancelled', 'CANCELLED', '', True),
|
||||
])
|
||||
def test_batch_check_only_loads_native_inspection(case, monkeypatch, scenario, status, category, safe):
|
||||
from cbb_refresh_verify import verify_runner as runner, native_repair, maintenance_entry as entry
|
||||
from test_native_occupancy import output
|
||||
request, _, address = case
|
||||
calls = []
|
||||
monkeypatch.setattr(runner, '_run_verify_serialized', lambda *a, **k: pytest.fail('check opened PCB'))
|
||||
monkeypatch.setattr(entry, 'assert_native_idle', lambda: pytest.fail('check used host-wide owner gate'))
|
||||
def native(target, root, **kw):
|
||||
assert kw['inspection_only'] is True and not kw.get('maintenance_context')
|
||||
calls.append('inspect')
|
||||
record = inspection(target, fault=scenario == 'fault')
|
||||
if scenario == 'busy':
|
||||
record.update(status='IN_USE', output=output(target.project, target.database, busy=True))
|
||||
if scenario in ('unknown', 'unreleased'):
|
||||
record.update(status='UNCONFIRMED', output='No conclusive native response')
|
||||
if scenario == 'unreleased': record['release']['native_exited'] = False
|
||||
if scenario == 'cancelled': record.update(status='CANCELLED')
|
||||
if scenario == 'unexpected_repair': record.update(status='REPAIRED', repair_requested=True)
|
||||
if scenario == 'missing_exit_proof': return {}
|
||||
if scenario == 'not_launched': return {'status': 'BLOCKED', 'native_started': False}
|
||||
return record
|
||||
monkeypatch.setattr(native_repair, 'run_native_repair', native)
|
||||
result = runner.run_verify(replace(request, auto_repair=True))
|
||||
assert calls == ['inspect']
|
||||
assert (result.status, result.error_category, result.safe_to_continue) == (status, category, safe)
|
||||
assert result.library_flag == 'UNKNOWN' and result.recovery_attempts == ()
|
||||
assert address.read_bytes() == b'old server address - preserved'
|
||||
record = json.loads(result.evidence_path.read_text('utf-8'))
|
||||
assert record['operation'] == 'icdb_batch_check' and record['automatic_repair'] is False
|
||||
|
||||
|
||||
@pytest.mark.parametrize('case_type', ['no_layout', 'no_pcb', 'no_icdb', 'ambiguous_repair_targets'])
|
||||
def test_inspection_does_not_require_repair_admission(case, monkeypatch, case_type):
|
||||
from cbb_refresh_verify import verify_runner as runner, native_repair
|
||||
request, project, address = case
|
||||
if case_type == 'no_layout': (project.parent/'PCB/Layout/LayoutDB.lyt').unlink()
|
||||
if case_type == 'no_pcb': (project.parent/'PCB/IP101GR.pcb').unlink()
|
||||
if case_type == 'no_icdb': (project.parent/'database/icdb.dat').unlink()
|
||||
if case_type == 'ambiguous_repair_targets':
|
||||
address.unlink()
|
||||
(project.parent/'PCB/pcb.prj').write_text('KEY iCDBDir "database"\n')
|
||||
db = project.parent/'PCB/database'; db.mkdir(); (db/'icdb.dat').touch()
|
||||
calls = []
|
||||
def native(target, *a, **kw):
|
||||
assert kw['inspection_only'] is True and target.project == project
|
||||
calls.append('inspect')
|
||||
return inspection(target)
|
||||
monkeypatch.setattr(native_repair, 'run_native_repair', native)
|
||||
result = runner.run_verify(request)
|
||||
assert calls == ['inspect']
|
||||
assert result.recovery_attempts == ()
|
||||
|
||||
|
||||
@pytest.mark.parametrize('before_launch', [True, False])
|
||||
def test_cancellation_never_dispatches_repair_or_reports_a_clean_check(case, monkeypatch, before_launch):
|
||||
from threading import Event
|
||||
from cbb_refresh_verify import verify_runner as runner, native_repair
|
||||
request, _, _ = case
|
||||
stop = Event(); calls = []
|
||||
if before_launch: stop.set()
|
||||
def native(target, *a, **kw):
|
||||
assert kw['inspection_only'] is True
|
||||
calls.append('inspect'); stop.set()
|
||||
return inspection(target)
|
||||
monkeypatch.setattr(native_repair, 'run_native_repair', native)
|
||||
result = runner.run_verify(request, stop=stop)
|
||||
assert result.status == 'CANCELLED' and result.safe_to_continue
|
||||
assert calls == ([] if before_launch else ['inspect'])
|
||||
|
||||
|
||||
def test_released_icdb_fault_continues_the_check_batch(case, monkeypatch):
|
||||
from cbb_refresh_verify import verify_runner as runner, native_repair
|
||||
request, _, _ = case
|
||||
calls = []
|
||||
def native(target, root, **kw):
|
||||
assert kw['inspection_only'] is True
|
||||
calls.append('inspect')
|
||||
return inspection(target, fault=len(calls) == 1)
|
||||
monkeypatch.setattr(native_repair, 'run_native_repair', native)
|
||||
monkeypatch.setattr(runner, '_run_verify_serialized', lambda *a, **k: pytest.fail('check opened PCB'))
|
||||
results = runner.run_batch([request, request])
|
||||
assert calls == ['inspect', 'inspect']
|
||||
assert [result.status for result in results] == ['FAIL', 'CHECKED']
|
||||
|
||||
|
||||
def test_inspection_ignores_other_pcb_and_skips_exclusive_repair_probe(tmp_path, monkeypatch):
|
||||
import win32con
|
||||
from test_native_repair import repair_worker_fixture
|
||||
from test_native_occupancy import output
|
||||
ui, root, job, actions = repair_worker_fixture(tmp_path, monkeypatch, 'active')
|
||||
data = json.loads(job.read_text('utf-8')); data['inspection_only'] = True
|
||||
job.write_text(json.dumps(data), encoding='utf-8')
|
||||
monkeypatch.setattr('cbb_refresh_verify.mentor_adapter.pcb_processes', lambda: [(999, 'other.pcb', '')])
|
||||
monkeypatch.setattr('cbb_refresh_verify.native_repair.check_repair_access',
|
||||
lambda *a: pytest.fail('inspection used exclusive Repair admission'))
|
||||
monkeypatch.setattr(ui, '_repair_command', lambda *a: pytest.fail('inspection resolved Repair command'))
|
||||
monkeypatch.setattr(ui, '_native_output', lambda *_: output(data['project'], data['database'], busy=True))
|
||||
assert ui.repair_worker_main(job) == 0
|
||||
assert actions == [(100, win32con.WM_CLOSE)]
|
||||
|
||||
|
||||
def test_ui_check_summary_reports_findings_and_never_claims_repair(qtbot, tmp_path, monkeypatch):
|
||||
from test_ui_filters import load_window
|
||||
from cbb_refresh_verify.verify_runner import VerifyResult
|
||||
from PySide6.QtWidgets import QMessageBox
|
||||
requests, prompts = [], []
|
||||
window = load_window(qtbot, tmp_path, monkeypatch,
|
||||
verifier=lambda req: (requests.append(req) or VerifyResult('FAIL',
|
||||
error_category='ICDB_REPAIR_REQUIRED', stderr='发现 ICDB 问题,未执行修复。')),
|
||||
status_refresher=lambda names, _: {name: 'PENDING' for name in names})
|
||||
monkeypatch.setattr(QMessageBox, 'question', lambda *a, **k: (prompts.append(a[2]) or QMessageBox.Yes))
|
||||
window.search_edit.setText('Beta')
|
||||
window.icdb_repair_button.click(); qtbot.waitUntil(lambda: not window.busy)
|
||||
assert requests[0].maintenance and not requests[0].auto_repair
|
||||
assert '批量检查' in window.icdb_repair_button.text()
|
||||
assert not any('手动备份' in text for text in prompts)
|
||||
assert window.summary.windowTitle() == 'ICDB 批量检查结果'
|
||||
assert '发现问题 1' in window.summary.text()
|
||||
assert '修复并校验通过' not in window.summary.detailedText()
|
||||
|
||||
|
||||
@pytest.mark.parametrize('category,label', [('ICDB_DATABASE_IN_USE', '占用 1'),
|
||||
('ICDB_INSPECTION_UNCONFIRMED', '无法确认 1')])
|
||||
def test_busy_or_unknown_inspection_is_not_labelled_as_database_damage(qtbot, tmp_path, monkeypatch, category, label):
|
||||
from test_ui_filters import load_window
|
||||
from cbb_refresh_verify.verify_runner import VerifyResult
|
||||
window = load_window(qtbot, tmp_path, monkeypatch,
|
||||
verifier=lambda _: VerifyResult('FAIL', error_category=category, stderr='暂未完成检查。'),
|
||||
status_refresher=lambda names, _: {name: 'PENDING' for name in names})
|
||||
window.search_edit.setText('Beta')
|
||||
window.icdb_repair_button.click(); qtbot.waitUntil(lambda: not window.busy)
|
||||
assert label in window.summary.text()
|
||||
assert 'ICDB 问题' not in window.cbb_table.item(window._row_by_name['Beta'], 3).text()
|
||||
|
||||
|
||||
def test_missing_pcb_can_be_checked_without_enabling_verify_or_restore(qtbot, tmp_path, monkeypatch):
|
||||
from test_ui_filters import load_window
|
||||
from cbb_refresh_verify.models import CbbRecord
|
||||
from cbb_refresh_verify.verify_runner import VerifyResult
|
||||
calls = []
|
||||
window = load_window(qtbot, tmp_path, monkeypatch,
|
||||
records=(CbbRecord('Missing', 'Power', status='PENDING'),),
|
||||
verifier=lambda req: (calls.append(req.block_name) or VerifyResult('CHECKED')),
|
||||
status_refresher=lambda names, _: {name: 'PENDING' for name in names})
|
||||
assert window.icdb_repair_button.isEnabled()
|
||||
assert not window.batch_button.isEnabled() and not window.backup_restore_button.isEnabled()
|
||||
window.icdb_repair_button.click(); qtbot.waitUntil(lambda: not window.busy)
|
||||
assert calls == ['Missing']
|
||||
|
||||
|
||||
def test_check_reports_describe_inspection_without_pcb_verification(case, tmp_path):
|
||||
from cbb_refresh_verify.verify_runner import write_batch_report, failure_report_path, VerifyResult
|
||||
request, _, _ = case
|
||||
report = write_batch_report([request], [VerifyResult('FAIL',
|
||||
error_category='ICDB_REPAIR_REQUIRED', stderr='发现 ICDB 问题,未执行修复。')], tmp_path/'reports')
|
||||
full = report.read_text('utf-8-sig')
|
||||
failed = failure_report_path(report).read_text('utf-8-sig')
|
||||
assert 'ICDB 批量检查' in full and 'Project Integration' not in full
|
||||
assert 'ICDB 检查异常' in failed and '发现问题: 1' in failed
|
||||
assert 'ICDB已修复待校验' not in failed
|
||||
@@ -56,7 +56,7 @@ def test_maintenance_guard_does_not_scan_other_cbb_projects(case, monkeypatch):
|
||||
|
||||
def test_repair_finishes_without_calling_verify(case, monkeypatch):
|
||||
from cbb_refresh_verify import native_repair, verify_runner as runner
|
||||
from test_maintenance_entry import patch_verification_after_fault
|
||||
from test_maintenance_entry import patch_verification_after_fault, run_legacy_maintenance
|
||||
from test_native_repair import complete_native_success
|
||||
req, _, address = case
|
||||
def repair(target, *a, **kw):
|
||||
@@ -65,7 +65,7 @@ def test_repair_finishes_without_calling_verify(case, monkeypatch):
|
||||
monkeypatch.setattr(native_repair, 'run_native_repair', repair)
|
||||
monkeypatch.setattr(native_repair, 'repair_release_state', lambda req, target, result: result['release'])
|
||||
patch_verification_after_fault(monkeypatch, runner, lambda *a, **k: pytest.fail('maintenance started CBB verification'))
|
||||
result = runner.run_verify(req)
|
||||
result = run_legacy_maintenance(req)
|
||||
assert result.status == 'REPAIRED' and result.safe_to_continue
|
||||
assert result.library_flag == 'UNKNOWN'
|
||||
assert result.recovery_attempts[0]['validation_passed'] is False
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"""Native occupancy must precede repair even when old addresses remain."""
|
||||
import pytest
|
||||
from test_maintenance_entry import case, no_native_launch, startup_failure
|
||||
from test_maintenance_entry import case, no_native_launch, startup_failure, run_legacy_maintenance
|
||||
from test_native_occupancy import output
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ def test_diagnosed_native_inspection_holds_lock_after_opening_pcb(case, monkeypa
|
||||
return inspection(target)
|
||||
monkeypatch.setattr(native_repair, 'run_native_repair', native)
|
||||
monkeypatch.setattr(runner, '_run_verify_serialized', startup)
|
||||
result = runner.run_verify(request)
|
||||
result = run_legacy_maintenance(request)
|
||||
assert result.status == 'CHECKED' and result.recovery_attempts == ()
|
||||
assert result.library_flag == 'UNKNOWN'
|
||||
assert result.safe_to_continue is True
|
||||
@@ -51,7 +51,7 @@ def test_unconfirmed_native_inspection_never_repairs(case, monkeypatch, fault):
|
||||
if fault == 'not_exited': record['release']['native_exited'] = False
|
||||
return record
|
||||
monkeypatch.setattr(native_repair, 'run_native_repair', native)
|
||||
result = runner.run_verify(request)
|
||||
result = run_legacy_maintenance(request)
|
||||
assert result.status == 'BLOCKED' and not result.recovery_attempts
|
||||
|
||||
|
||||
@@ -78,7 +78,7 @@ def test_native_fault_repairs_once_without_running_separate_verification(case, m
|
||||
monkeypatch.setattr(native_repair, 'run_native_repair', native)
|
||||
monkeypatch.setattr(native_repair, 'repair_release_state', lambda req, target, result: result['release'])
|
||||
monkeypatch.setattr(runner, '_run_verify_serialized', verify)
|
||||
result = runner.run_verify(request)
|
||||
result = run_legacy_maintenance(request)
|
||||
assert calls == ['open', 'inspect', 'repair']
|
||||
assert result.status == 'REPAIRED' and len(result.recovery_attempts) == 1
|
||||
assert result.library_flag == 'UNKNOWN' and not result.recovery_attempts[0]['validation_passed']
|
||||
@@ -59,6 +59,16 @@ def startup_failure(request):
|
||||
f"Machine:[fixture-server] Path:[{database}] session:[fixture-current-session]"))
|
||||
|
||||
|
||||
def run_legacy_maintenance(request, **kwargs):
|
||||
"""Keep explicit recovery helper coverage separate from the batch-check API."""
|
||||
from cbb_refresh_verify import verify_runner as runner, maintenance_entry as entry
|
||||
if not request.maintenance:
|
||||
return runner.run_verify(request, **kwargs)
|
||||
return entry.run_diagnosed_maintenance(request,
|
||||
diagnose=lambda probe: runner.run_verify(probe, **kwargs),
|
||||
progress=kwargs.get('progress'), stop=kwargs.get('stop'))
|
||||
|
||||
|
||||
def patch_verification_after_fault(monkeypatch, runner, verify):
|
||||
"""Inject only native process boundaries; production interprets the Output."""
|
||||
from cbb_refresh_verify import native_repair
|
||||
@@ -108,7 +118,7 @@ def test_diagnosed_maintenance_enters_official_repair_once(case, monkeypatch, pc
|
||||
assert req.lmc_file == request.lmc_file and req.block_name == request.block_name
|
||||
return runner.VerifyResult('PASS', library_flag='GREEN')
|
||||
patch_verification_after_fault(monkeypatch, runner, verify)
|
||||
result = runner.run_verify(request)
|
||||
result = run_legacy_maintenance(request)
|
||||
assert calls == ['repair'] and result.status == 'REPAIRED'
|
||||
assert result.recovery_attempts[0]['validation_passed'] is False
|
||||
assert result.library_flag == 'UNKNOWN'
|
||||
@@ -220,7 +230,7 @@ def test_ordinary_verify_calls_native_verifier_despite_existing_address(case, mo
|
||||
calls = []
|
||||
monkeypatch.setattr(runner, '_run_verify_serialized', lambda *a, **k:
|
||||
(calls.append('verify') or runner.VerifyResult('FAIL', stderr='native ICDB problem')))
|
||||
result = runner.run_verify(replace(request, maintenance=False))
|
||||
result = run_legacy_maintenance(replace(request, maintenance=False))
|
||||
assert calls == ['verify'] and result.status == 'FAIL' and result.safe_to_continue
|
||||
assert address.read_bytes() == b'old server address - preserved'
|
||||
|
||||
@@ -249,7 +259,7 @@ def test_maintenance_guard_blocks_before_native(case, monkeypatch, obstacle):
|
||||
monkeypatch.setattr(entry, 'address_snapshot', mutate)
|
||||
monkeypatch.setattr(native_repair, 'run_native_repair', lambda *a, **k: pytest.fail('guard bypass'))
|
||||
try:
|
||||
result = runner.run_verify(request)
|
||||
result = run_legacy_maintenance(request)
|
||||
assert result.status == 'BLOCKED' and not result.safe_to_continue
|
||||
assert result.error_stage == 'preflight'
|
||||
finally:
|
||||
@@ -298,7 +308,7 @@ def test_nonrepair_outcomes_never_verify_or_count_success(case, monkeypatch, sta
|
||||
'status': status, 'release': {'safe_to_continue': False}, 'detail': 'native result'})
|
||||
monkeypatch.setattr(native_repair, 'repair_release_state', lambda *a: {'safe_to_continue': False})
|
||||
patch_verification_after_fault(monkeypatch, runner, lambda *a, **k: pytest.fail('unsafe or nonrepair outcome reopened'))
|
||||
result = runner.run_verify(request)
|
||||
result = run_legacy_maintenance(request)
|
||||
assert result.status != 'PASS' and not result.safe_to_continue
|
||||
assert result.recovery_attempts[0]['status'] == status
|
||||
|
||||
@@ -312,7 +322,7 @@ def test_native_success_cannot_bypass_remaining_address(case, monkeypatch):
|
||||
# Native release queries remain mocked, actual address/exclusive checks stay real.
|
||||
monkeypatch.setattr('cbb_refresh_verify.mentor_adapter.pcb_processes', lambda: [])
|
||||
monkeypatch.setattr('cbb_refresh_verify.mentor_adapter._process_details', lambda name: [])
|
||||
result = runner.run_verify(request)
|
||||
result = run_legacy_maintenance(request)
|
||||
assert result.status != 'PASS' and not result.safe_to_continue
|
||||
|
||||
|
||||
@@ -408,7 +418,7 @@ def test_failed_content_does_not_block_other_items_after_actual_release(case, mo
|
||||
monkeypatch.setattr(native_repair, 'run_native_repair', repair)
|
||||
monkeypatch.setattr(native_repair, 'repair_release_state', lambda req, target, result: result['release'])
|
||||
patch_verification_after_fault(monkeypatch, runner, lambda *a, **k: pytest.fail('nonrepair outcome reopened'))
|
||||
result = runner.run_verify(request)
|
||||
result = run_legacy_maintenance(request)
|
||||
assert result.status != 'PASS'
|
||||
assert result.safe_to_continue is expected_safe
|
||||
assert result.recovery_attempts[0]['status'] == status
|
||||
@@ -427,7 +437,7 @@ def test_successful_icdb_repair_then_version_choice_reports_partial_completion(c
|
||||
patch_verification_after_fault(monkeypatch, runner, lambda *a, **k: runner.VerifyResult('FAIL',
|
||||
error_category='PCB_VERSION_CHOICE_REQUIRED', stderr='PCB版本待选:最后用户保存/自动保存 2026/9/24 23:06',
|
||||
safe_to_continue=False, evidence_path=request.evidence_dir/'verify/result.json'))
|
||||
result = runner.run_verify(request)
|
||||
result = run_legacy_maintenance(request)
|
||||
assert result.status == 'REPAIRED' and result.safe_to_continue
|
||||
assert '待单独校验' in result.stdout
|
||||
assert result.recovery_attempts[0]['native_status'] == 'REPAIRED'
|
||||
@@ -448,7 +458,7 @@ def test_user_chosen_pcb_history_is_not_reported_as_lossless_repair(case, monkey
|
||||
'choice': 'last_user_saved', 'date': '2026/9/24 23:06', 'confirm_sent': True, 'historical_restore': True}))
|
||||
return runner.VerifyResult('PASS', library_flag='GREEN', evidence_path=root/'result.json')
|
||||
patch_verification_after_fault(monkeypatch, runner, verify)
|
||||
result = runner.run_verify(request)
|
||||
result = run_legacy_maintenance(request)
|
||||
assert result.status == 'REPAIRED' and result.library_flag == 'UNKNOWN'
|
||||
assert result.recovery_attempts[0]['status'] == 'REPAIRED_UNVERIFIED'
|
||||
assert not (request.evidence_dir/'verify').exists()
|
||||
@@ -4,7 +4,7 @@ import json
|
||||
|
||||
import pytest
|
||||
|
||||
from test_maintenance_entry import case, no_native_launch
|
||||
from test_maintenance_entry import case, no_native_launch, run_legacy_maintenance
|
||||
|
||||
|
||||
def fault_text(database):
|
||||
@@ -35,7 +35,7 @@ def test_healthy_startup_skips_project_backup_even_with_old_address(case, monkey
|
||||
calls = []
|
||||
install_probe(monkeypatch, runner.VerifyResult('PASS', safe_to_continue=True), calls)
|
||||
forbid_backup(monkeypatch)
|
||||
result = runner.run_verify(replace(request, native_lm_verify=True))
|
||||
result = run_legacy_maintenance(replace(request, native_lm_verify=True))
|
||||
assert calls == ['open']
|
||||
assert result.status == 'CHECKED' and result.library_flag == 'UNKNOWN'
|
||||
assert result.recovery_attempts == () and result.safe_to_continue
|
||||
@@ -52,7 +52,7 @@ def test_generic_startup_errors_remain_failures_without_backup(case, monkeypatch
|
||||
failed = runner.VerifyResult('FAIL', stderr=message, safe_to_continue=True)
|
||||
install_probe(monkeypatch, failed, calls)
|
||||
forbid_backup(monkeypatch)
|
||||
result = runner.run_verify(request)
|
||||
result = run_legacy_maintenance(request)
|
||||
assert calls == ['open'] and result == failed
|
||||
|
||||
|
||||
@@ -72,7 +72,7 @@ def test_unmatched_or_unreleased_icdb_fault_never_enters_backup(case, monkeypatc
|
||||
calls = []
|
||||
install_probe(monkeypatch, failed, calls)
|
||||
forbid_backup(monkeypatch)
|
||||
result = runner.run_verify(request)
|
||||
result = run_legacy_maintenance(request)
|
||||
assert calls == ['open'] and result.status == failed.status
|
||||
assert not result.recovery_attempts
|
||||
assert result.safe_to_continue is failed.safe_to_continue
|
||||
@@ -91,7 +91,7 @@ def test_only_current_matching_fault_enters_native_maintenance(case, monkeypatch
|
||||
calls.append('maintenance')
|
||||
return runner.VerifyResult('REPAIRED')
|
||||
monkeypatch.setattr(entry, 'run_existing_address_maintenance', maintain)
|
||||
result = runner.run_verify(request)
|
||||
result = run_legacy_maintenance(request)
|
||||
assert calls == ['open', 'maintenance'] and result.status == 'REPAIRED'
|
||||
|
||||
|
||||
@@ -105,7 +105,7 @@ def test_old_saved_diagnosis_does_not_turn_generic_startup_failure_into_repair(c
|
||||
failure = runner.VerifyResult('FAIL', stderr='License unavailable', evidence_path=root/'result.json')
|
||||
install_probe(monkeypatch, failure, calls)
|
||||
forbid_backup(monkeypatch)
|
||||
assert runner.run_verify(request) == failure
|
||||
assert run_legacy_maintenance(request) == failure
|
||||
assert calls == ['open']
|
||||
|
||||
|
||||
@@ -145,7 +145,7 @@ def test_unsafe_startup_success_is_not_reported_as_healthy(case, monkeypatch):
|
||||
request, _, _ = case
|
||||
install_probe(monkeypatch, runner.VerifyResult('PASS', safe_to_continue=False), [])
|
||||
forbid_backup(monkeypatch)
|
||||
result = runner.run_verify(request)
|
||||
result = run_legacy_maintenance(request)
|
||||
assert result.status == 'FAIL' and not result.safe_to_continue
|
||||
|
||||
|
||||
@@ -161,7 +161,7 @@ def test_report_write_failure_does_not_block_a_released_healthy_project(case, mo
|
||||
if path.name == 'maintenance-result.json': raise PermissionError('report unavailable')
|
||||
return write(path, *args, **kwargs)
|
||||
monkeypatch.setattr(Path, 'write_text', unavailable)
|
||||
result = runner.run_verify(request)
|
||||
result = run_legacy_maintenance(request)
|
||||
assert result.status == 'CHECKED' and result.safe_to_continue
|
||||
assert result.evidence_path == evidence and evidence.read_text() == '{}'
|
||||
|
||||
@@ -180,6 +180,6 @@ def test_cancelled_startup_diagnosis_never_requests_repair(case, monkeypatch, be
|
||||
return startup_failure(req)
|
||||
monkeypatch.setattr(runner, '_run_verify_serialized', probe)
|
||||
forbid_backup(monkeypatch)
|
||||
result = runner.run_verify(request, stop=stop)
|
||||
result = run_legacy_maintenance(request, stop=stop)
|
||||
assert result.status == 'CANCELLED' and result.safe_to_continue
|
||||
assert calls == ([] if before_open else ['open'])
|
||||
@@ -78,7 +78,7 @@ def test_maintenance_summary_exposes_first_failure_reason(qtbot, tmp_path):
|
||||
assert detail not in window.summary.text()
|
||||
assert str(tmp_path) not in window.summary.text()
|
||||
assert detail not in window.status_label.text()
|
||||
assert '失败/受阻 1' in window.summary.text()
|
||||
assert '无法确认 1' in window.summary.text()
|
||||
|
||||
|
||||
def test_safe_maintenance_reloads_authoritative_catalog_after_worker_finishes(qtbot, tmp_path, monkeypatch):
|
||||
|
||||
@@ -19,7 +19,7 @@ def test_management_prompts_for_manual_backup_and_cancel_starts_nothing(qtbot, t
|
||||
assert '完整备份与检查点' not in seen[0]
|
||||
|
||||
|
||||
@pytest.mark.parametrize('action', ['verify_all', 'verify_selected', 'repair_icdb_all'])
|
||||
@pytest.mark.parametrize('action', ['verify_all', 'verify_selected'])
|
||||
def test_batch_prompts_once_for_manual_backup_and_cancel_does_not_start(qtbot, tmp_path, monkeypatch, action):
|
||||
from cbb_refresh_verify.ui.main_window import MainWindow
|
||||
from cbb_refresh_verify.models import CbbRecord, LibraryReadResult
|
||||
|
||||
+4
-3
@@ -78,7 +78,7 @@ def test_global_icdb_failure_preserves_untargeted_ready_and_stops_queue(qtbot, t
|
||||
assert window.cbb_table.item(1, 2).text() == '未知 / 需确认'
|
||||
assert window.cbb_table.item(2, 3).text().startswith('SKIPPED')
|
||||
|
||||
def test_global_icdb_progress_and_repair_summary(qtbot, tmp_path, monkeypatch):
|
||||
def test_global_icdb_progress_and_check_summary(qtbot, tmp_path, monkeypatch):
|
||||
from PySide6.QtWidgets import QMessageBox
|
||||
confirmations = []
|
||||
def confirm(*args, **kwargs):
|
||||
@@ -97,8 +97,9 @@ def test_global_icdb_progress_and_repair_summary(qtbot, tmp_path, monkeypatch):
|
||||
assert '非 READY' in confirmations[0]
|
||||
assert window.icdb_progress.value() == 1
|
||||
assert window.icdb_progress.maximum() == 1
|
||||
assert '恢复备份待复核 1' in window.status_label.text()
|
||||
assert window.summary.windowTitle() == 'ICDB 维护结果'
|
||||
assert '无法确认 1' in window.status_label.text()
|
||||
assert '恢复备份待复核' not in window.status_label.text()
|
||||
assert window.summary.windowTitle() == 'ICDB 批量检查结果'
|
||||
reports = list((tmp_path/'reports').glob('icdb-*.json'))
|
||||
assert len(reports) == 1
|
||||
|
||||
|
||||
Reference in new issue
Block a user