Compare commits

...
Author SHA1 Message Date
阿白叔 14cacb1d1c release: prepare v0.2.4-beta.4 and guard late management signals
Ignore queued management completion after its Qt receiver is destroyed. Isolate unrelated WMI and file-proof latency in simulated lifecycle tests while retaining real occupancy and writer-barrier coverage. Validation: 2428 tests passed, compile and whitespace checks passed, scoped review clean. Field ICDB inconsistency and Windows 10/production SMB remain unaccepted.
2026-11-18 10:13:55 +08:00
阿白叔 fa1f662e1d fix: preserve handoff cleanup and ICDB cancellation bindings 2026-11-18 09:05:22 +08:00
阿白叔 b4737b5102 docs: record final issue15 scoped review acceptance 2026-11-17 14:09:15 +08:00
16 changed files with 255 additions and 19 deletions

No files matched your search

@@ -1,6 +1,6 @@
# Issue 15 acceptance matrix # Issue 15 acceptance matrix
Refs #15. The final grouped review wave is implemented at `c1e2596` (B14). The complete suite passed **2,418 tests in 594.83 seconds**, actual exit code 0, with zero failures, errors or skips. Actual B13 ordinary Verify/Stop with automatic candidate-owned cleanup and cross-owner queued Versions passed; actual B13 CBB recovery passed source and target verification. B14 preserves explicit ordinary release promotion of an existing cold observer; that narrow change has source/real-process coverage and updated frozen checks. Native cases retain B13 identities. The final scoped independent review is pending. Refs #15. The final grouped review wave is implemented at `c1e2596` (B14). The complete suite passed **2,418 tests in 594.83 seconds**, actual exit code 0, with zero failures, errors or skips. Actual B13 ordinary Verify/Stop with automatic candidate-owned cleanup and cross-owner queued Versions passed; actual B13 CBB recovery passed source and target verification. B14 preserves explicit ordinary release promotion of an existing cold observer; that narrow change has source/real-process coverage and updated frozen checks. Native cases retain B13 identities. The final scoped independent review passed for 32dcd80..8869093: I1-I3 addressed; zero Critical/Important/Minor findings. This is a technical review, not field acceptance or merge/release approval.
## Executable bindings ## Executable bindings
@@ -2,7 +2,7 @@
Refs #15. This candidate records local Windows 11 acceptance and its limits; it is not a published release or field-acceptance approval. Refs #15. This candidate records local Windows 11 acceptance and its limits; it is not a published release or field-acceptance approval.
The final grouped review wave is implemented at `c1e2596` (B14). The complete suite passed **2,418 tests in 594.83 seconds**, actual exit code 0, with zero failures, errors or skips. Actual B13 ordinary Verify/Stop with automatic candidate-owned cleanup and cross-owner queued Versions passed; actual B13 CBB recovery passed source and target verification. B14 preserves explicit ordinary release promotion of an existing cold observer; that narrow change has source/real-process coverage and updated frozen checks. Native cases retain B13 identities. The final scoped independent review is pending. The final grouped review wave is implemented at `c1e2596` (B14). The complete suite passed **2,418 tests in 594.83 seconds**, actual exit code 0, with zero failures, errors or skips. Actual B13 ordinary Verify/Stop with automatic candidate-owned cleanup and cross-owner queued Versions passed; actual B13 CBB recovery passed source and target verification. B14 preserves explicit ordinary release promotion of an existing cold observer; that narrow change has source/real-process coverage and updated frozen checks. Native cases retain B13 identities. The final scoped independent review passed for 32dcd80..8869093: I1-I3 addressed; zero Critical/Important/Minor findings. This is a technical review, not field acceptance or merge/release approval.
The PR base is main at e4875b4. The branch also includes the previously approved efb8cae three-second confirmation defaults. The PR base is main at e4875b4. The branch also includes the previously approved efb8cae three-second confirmation defaults.
@@ -0,0 +1,38 @@
# PR 16 small review follow-up
Refs #15. Follow-up to review comment 446 on `b4737b5`; this does not authorize
merging, release publication or issue closure.
- Verify now propagates a registered `TaskHandoff` instead of recording it as a
close error and continuing a second native cleanup. It preserves the cancelled
or failed result as evidence before returning cleanup ownership to the observer.
- Repair runs local worker cleanup even when observer registration or handoff
raises. A live native worker retains its existing observer-owned handles;
`DesktopWorker.close()` does not terminate it or claim resources are released.
- Starting an ICDB check binds the fallback Stop signal to the task's actual
context. The normal global Stop and per-task cancellation policies are unchanged.
- Native Versions/Repair errors now explain that the main PRJ must contain exactly
one nonempty `iCDBDir` using a project-local relative path. Absolute paths,
including absolute paths inside Work, and multiple entries remain unsupported.
No PRJ is rewritten and no native tool is launched for rejected input.
The previously approved three-second defaults remain: submitted execution
continues; unknown ownership/read-write confirmation skips; version selection
uses the last manual save; exit saves; force termination defaults to cancellation.
This follow-up does not add or change those product decisions.
## Validation
The unchanged targeted baseline passed 31 tests. New behavior regressions first
recorded four failures and four passes; after the fixes all eight passed.
Related Verify, Repair, native-entry, observer, ICDB/UI and shutdown regressions
passed **363 tests in 157.24 seconds**, exit code 0.
Compilation and whitespace checks also passed. Independent scoped review found
zero Critical, Important or Minor issues in the follow-up fixes.
These are source tests with real task contexts and Qt controls; native process
boundaries are replaced where the tests require them. This follow-up does not
claim a new full-suite run, rebuilt frozen package, or actual Mentor acceptance.
The earlier 2,418-test full run and B14 package still belong to source `c1e2596`.
Original field inconsistency, the retained-phase native replay, Windows 10 and
production SMB acceptance remain outstanding as documented in the main matrix.
+34
View File
@@ -0,0 +1,34 @@
# CBB 刷新校验 v0.2.4-beta.4
Refs #15。延续测试版发行,供隔离副本和现场进一步验证。
## 本版改动
- 分开任务执行、原生客户端退出、资源释放及数据待恢复状态,减少旧记录和无关工程导致的误阻塞。
- 普通校验启动阶段取消时,只有完整未写入证明和准确归属才能处理已知提示并安全收尾;原结果保留为取消,不改成 READY。
- 已登记观察者可以持久化接管一次迟到启动的安全收尾;不循环重新打开或自动重放写操作。
- 文件哈希、复制、校验不再因嵌套线程池阻止程序退出。恢复准备不长期持有全局原生通道,迟到任务不能继续安装。
- 修正交接异常传递、Repair 本地资源清理、ICDB 停止信号绑定,以及管理窗口销毁后的迟到结果回调。
- 保留当前图标、三个菜单、READY 操作范围及手动备份政策。版本/Repair 对绝对或多条 iCDBDir 的拒绝原因现在明确显示,不自动修改工程引用。
- 沿用已确认的 3 秒默认策略;未知占用和读写确认默认跳过,强制终止默认取消。真实原生写入仍受保护。
## 发布验证
本次源码全量 **2,428 项通过,659.54 秒,退出码 0**;JUnit 零失败、零错误、零跳过。
管理窗口销毁后的成功/失败回调先复现失败,再通过实际 Qt 信号测试验证修复。
生命周期模拟测试隔离无关的机器 WMI/文件探测延迟,真实占用、独占句柄、资源证明和原生写入保护测试继续保留。
新增发布改动经独立限定复核,无 Critical、Important 或 Minor 遗留项。
Windows 包使用合并后的 main 提交构建并上传云端;仓库当前未配置云端打包工作流。
最终源码提交、冻结模块/资源及图标核对、冻结冒烟和 ZIP 校验结果见发行附件
`release-info.json`、`release-smoke.json` 和 `SHA256SUMS.txt`。
发布前因 C 盘耗尽中断的一轮,以及后续失败/修订的测试记录均保留,不计为通过。
## 使用与范围
完整解压 Windows ZIP,运行 `CbbRefreshVerify-Background/CbbRefreshVerify.exe`,保留 `_internal`。
库写操作前按提示手动备份。程序回滚不能撤销已经完成的中心库写入。
自动 ICDB Repair 仍关闭。原现场不一致故障未完整复现;独立接管阶段的原生 No/Close 重放、Windows 10、生产 SMB 尚未验收。
此前 B13 实际普通取消、后续原生调度与备份恢复的通过记录保留其原始源码/包版本,不能算成本发行包的原生重跑。
发布测试版不关闭工单 #15,也不代表这些现场边界已经解决。
+1 -1
View File
@@ -3,7 +3,7 @@ requires = ["setuptools>=84.1.0"]
build-backend = "setuptools.build_meta" build-backend = "setuptools.build_meta"
[project] [project]
name = "cbb-refresh-verify" name = "cbb-refresh-verify"
version = "0.2.4b3" version = "0.2.4b4"
requires-python = ">=3.12,<3.13" requires-python = ">=3.12,<3.13"
dependencies = ["PySide6>=6.7,<7", "pywin32>=306", "pywinauto>=0.6.9,<0.7", "Pillow>=13.0.0,<14"] dependencies = ["PySide6>=6.7,<7", "pywin32>=306", "pywinauto>=0.6.9,<0.7", "Pillow>=13.0.0,<14"]
+1 -1
View File
@@ -1 +1 @@
__version__ = "0.2.4b3" __version__ = "0.2.4b4"
+1 -1
View File
@@ -61,7 +61,7 @@ def native_backup_target(request, *, mode='versions', target_database=None):
values = re.findall(r'^KEY iCDBDir "([^"\r\n]+)"\s*$', _project_text(config), re.M) values = re.findall(r'^KEY iCDBDir "([^"\r\n]+)"\s*$', _project_text(config), re.M)
if len(values) != 1 or not values[0] or PureWindowsPath(values[0]).root or PureWindowsPath(values[0]).drive: if len(values) != 1 or not values[0] or PureWindowsPath(values[0]).root or PureWindowsPath(values[0]).drive:
if config == project or target_database is None: if config == project or target_database is None:
raise ValueError('NATIVE_TARGET_UNCONFIRMED: 主 PRJ 的 iCDBDir 未唯一绑定') raise ValueError('NATIVE_TARGET_UNCONFIRMED: 主 PRJ 的 iCDBDir 必须唯一且为工程内相对路径,不支持绝对路径或多条记录')
continue continue
database = (config.parent/values[0]).resolve() database = (config.parent/values[0]).resolve()
if not database.is_relative_to(project.parent.resolve()): if not database.is_relative_to(project.parent.resolve()):
+10 -8
View File
@@ -336,11 +336,13 @@ def _supervise_repair(command, desktop, cancel, root, timeout_seconds, progress,
worker.request_stop() worker.request_stop()
raise raise
finally: finally:
if entered: try:
native.__exit__(None, None, None) if entered:
if worker.poll() is None and getattr(worker, 'session_record_path', None): native.__exit__(None, None, None)
from .session_record import handoff_session if worker.poll() is None and getattr(worker, 'session_record_path', None):
from .operation_queue import hold_native_handoff from .session_record import handoff_session
handoff_session(worker.session_record_path, evidence_root=root, process=worker) from .operation_queue import hold_native_handoff
hold_native_handoff(worker, worker.session_record_path) handoff_session(worker.session_record_path, evidence_root=root, process=worker)
worker.close() hold_native_handoff(worker, worker.session_record_path)
finally:
worker.close()
+1
View File
@@ -1111,6 +1111,7 @@ class MainWindow(QWidget):
self._current_job = previous_job self._current_job = previous_job
self._jobs.pop(job.context.operation_id, None) self._jobs.pop(job.context.operation_id, None)
job.context = task.context job.context = task.context
self.stop = task.stop
self._jobs[job.context.operation_id] = job self._jobs[job.context.operation_id] = job
task.ui_job = job task.ui_job = job
task.revision = self._view_revision task.revision = self._view_revision
@@ -5,6 +5,7 @@ from pathlib import Path
from PySide6.QtCore import QObject, QThreadPool, Signal, Qt from PySide6.QtCore import QObject, QThreadPool, Signal, Qt
from PySide6.QtWidgets import (QCheckBox, QDialog, QFileDialog, QHBoxLayout, QLabel, from PySide6.QtWidgets import (QCheckBox, QDialog, QFileDialog, QHBoxLayout, QLabel,
QMessageBox, QPushButton, QTableWidget, QTableWidgetItem, QTextEdit, QVBoxLayout) QMessageBox, QPushButton, QTableWidget, QTableWidgetItem, QTextEdit, QVBoxLayout)
from shiboken6 import isValid
from .workers import ServiceWorker from .workers import ServiceWorker
from .backup_notice import MANUAL_BACKUP_NOTICE from .backup_notice import MANUAL_BACKUP_NOTICE
@@ -217,9 +218,10 @@ class ManagementDialog(QDialog):
'complete', 'RECOVERY_REQUIRED' if isinstance(error,TaskHandoff) else 'CANCELLED', 'complete', 'RECOVERY_REQUIRED' if isinstance(error,TaskHandoff) else 'CANCELLED',
not isinstance(error,TaskHandoff), str(error)) for r in requests] not isinstance(error,TaskHandoff), str(error)) for r in requests]
self.worker = ServiceWorker(execute) self.worker = ServiceWorker(execute)
self.worker.signals.succeeded.connect(context.guard_callback(self._result, current=lambda:self.context)) current = lambda: self.context if isValid(self) else None
self.worker.signals.failed.connect(context.guard_callback(self._failed, current=lambda:self.context)) self.worker.signals.succeeded.connect(context.guard_callback(self._result, current=current))
self.worker.signals.finished.connect(lambda:self._finished() if self.context is context else None) self.worker.signals.failed.connect(context.guard_callback(self._failed, current=current))
self.worker.signals.finished.connect(lambda:self._finished() if current() is context else None)
self.pool.start(self.worker) self.pool.start(self.worker)
def _emit(self, context, signal, value): def _emit(self, context, signal, value):
+7 -1
View File
@@ -1010,7 +1010,7 @@ def _run_verify(request, *, timing, progress=None, flag_reader=None, process_run
from .desktop_worker import DesktopWorker from .desktop_worker import DesktopWorker
from .dialog_supervisor import AgentDialogBackend, DialogSupervisor, Win32DialogBackend from .dialog_supervisor import AgentDialogBackend, DialogSupervisor, Win32DialogBackend
from .dialog_models import DialogPhase from .dialog_models import DialogPhase
from .operation_queue import check_active, native_channel from .operation_queue import TaskHandoff, check_active, native_channel
check_active() check_active()
worker_launch_attempted = False worker_launch_attempted = False
native = native_channel() native = native_channel()
@@ -1322,6 +1322,12 @@ def _run_verify(request, *, timing, progress=None, flag_reader=None, process_run
'detail': '已转后台观察,可查看状态'}) 'detail': '已转后台观察,可查看状态'})
from .operation_queue import hold_native_handoff from .operation_queue import hold_native_handoff
hold_native_handoff(process, process.session_record_path) hold_native_handoff(process, process.session_record_path)
except TaskHandoff as error:
handoff_result = _handoff_verify_result(error)
if handoff_result.evidence_path:
_write_optional_evidence(handoff_result.evidence_path,
{'block_name': request.block_name, **asdict(handoff_result)})
raise
except Exception as error: except Exception as error:
close_errors.append(str(error)) close_errors.append(str(error))
if 'process' in locals(): if 'process' in locals():
@@ -9,6 +9,7 @@ from uuid import uuid4
workspace = Path(sys.argv[1]).resolve() workspace = Path(sys.argv[1]).resolve()
bundle_root = Path(sys.argv[2]).resolve() bundle_root = Path(sys.argv[2]).resolve()
sys.path.insert(0, str(workspace/'src')) sys.path.insert(0, str(workspace/'src'))
from cbb_refresh_verify import __version__
exe = bundle_root/'dist/CbbRefreshVerify-Background/CbbRefreshVerify.exe' exe = bundle_root/'dist/CbbRefreshVerify-Background/CbbRefreshVerify.exe'
root = bundle_root/('smoke-' + uuid4().hex[:8]) root = bundle_root/('smoke-' + uuid4().hex[:8])
root.mkdir() root.mkdir()
@@ -64,7 +65,7 @@ finally:
from PyInstaller.archive.readers import ZlibArchiveReader from PyInstaller.archive.readers import ZlibArchiveReader
pyz = bundle_root/'build/CbbRefreshVerify/PYZ-00.pyz' pyz = bundle_root/'build/CbbRefreshVerify/PYZ-00.pyz'
code = ZlibArchiveReader(str(pyz)).extract('cbb_refresh_verify') code = ZlibArchiveReader(str(pyz)).extract('cbb_refresh_verify')
assert '0.2.4b3' in code.co_consts assert __version__ in code.co_consts
toc = ast.literal_eval((bundle_root/'build/CbbRefreshVerify/Analysis-00.toc').read_text('utf-8')) toc = ast.literal_eval((bundle_root/'build/CbbRefreshVerify/Analysis-00.toc').read_text('utf-8'))
stack, rows = [toc], [] stack, rows = [toc], []
while stack: while stack:
@@ -77,6 +78,6 @@ while stack:
stack.extend(value) stack.extend(value)
assert rows and all(Path(row[1]).is_relative_to(workspace/'src') for row in rows) assert rows and all(Path(row[1]).is_relative_to(workspace/'src') for row in rows)
results['module_origins'] = {'status': 'passed', 'module_count': len(rows), 'source_root': str(workspace/'src')} results['module_origins'] = {'status': 'passed', 'module_count': len(rows), 'source_root': str(workspace/'src')}
results['version'] = '0.2.4b3' results['version'] = __version__
(root/'result.json').write_text(json.dumps(results, ensure_ascii=False, indent=2), 'utf-8') (root/'result.json').write_text(json.dumps(results, ensure_ascii=False, indent=2), 'utf-8')
print(json.dumps({'evidence': str(root/'result.json'), **results}, ensure_ascii=False), flush=True) print(json.dumps({'evidence': str(root/'result.json'), **results}, ensure_ascii=False), flush=True)
@@ -91,6 +91,9 @@ def test_exited_verify_worker_outcome_read_is_bounded_and_releases_channel(tmp_p
def poll(self): return 0 def poll(self): return 0
def close(self): pass def close(self): pass
monkeypatch.setattr('cbb_refresh_verify.desktop_worker.DesktopWorker', ExitedWorker) monkeypatch.setattr('cbb_refresh_verify.desktop_worker.DesktopWorker', ExitedWorker)
# The fake worker has no native clients; cleanup probes are covered independently.
monkeypatch.setattr('cbb_refresh_verify.verify_runner._cleanup_session_processes',
lambda *args, **kwargs: {'safe_to_continue': True, 'remaining_pids': []})
original = Path.read_text original = Path.read_text
def read(path, *args, **kwargs): def read(path, *args, **kwargs):
if path.name == 'outcome.json': if path.name == 'outcome.json':
@@ -221,6 +224,9 @@ def test_handed_off_worker_accepts_exact_controls_but_excludes_new_writers(tmp_p
monkeypatch.setattr(sessions, '_request_native_cancel', answer) monkeypatch.setattr(sessions, '_request_native_cancel', answer)
monkeypatch.setattr(sessions, 'query_process_snapshot', lambda: [row] if child[0].poll() is None else []) monkeypatch.setattr(sessions, 'query_process_snapshot', lambda: [row] if child[0].poll() is None else [])
monkeypatch.setattr(sessions, '_process_windows', lambda _: {}) monkeypatch.setattr(sessions, '_process_windows', lambda _: {})
# Keep this real writer-barrier/control test independent of file-probe startup latency.
monkeypatch.setattr(sessions, '_finish_library_release',
lambda *args, **kwargs: {'status': 'RELEASE_CONFIRMED', 'library': str(library)})
command = lambda: sessions.release_residual_sessions(dict(library=str(library), sessions=[row]), command = lambda: sessions.release_residual_sessions(dict(library=str(library), sessions=[row]),
tmp_path/'controls', cancel_native=True) tmp_path/'controls', cancel_native=True)
def control_call(): def control_call():
+32
View File
@@ -0,0 +1,32 @@
"""Queued worker completion must not touch a destroyed management dialog."""
import pytest
from PySide6.QtWidgets import QMessageBox
from shiboken6 import delete, isValid
@pytest.mark.parametrize('failed', [False, True])
def test_queued_management_completion_ignores_deleted_receiver(qtbot, tmp_path, monkeypatch, failed):
from cbb_refresh_verify.management import ManagementRequest
from cbb_refresh_verify.ui import timed_prompt
from cbb_refresh_verify.ui.management_dialog import ManagementDialog
def run(*args, **kwargs):
if failed:
raise ValueError('simulated native-boundary failure')
return []
monkeypatch.setattr(timed_prompt, 'question', lambda *args, **kwargs: QMessageBox.Yes)
dialog = ManagementDialog([ManagementRequest('remove', tmp_path/'library.lmc', 'Block',
evidence_dir=tmp_path/'evidence')], runner=run)
completed = []
dialog.completed.connect(completed.append)
try:
dialog.execute_button.click()
worker = dialog.worker # Retain the real sender while its queued signals are delivered.
assert dialog.pool.waitForDone(3000)
delete(dialog)
assert not isValid(dialog)
qtbot.wait(30)
assert not completed
finally:
if isValid(dialog):
delete(dialog)
@@ -29,6 +29,8 @@ def test_soft_stop_finishes_current_transaction_and_skips_next(setup, qtbot, mon
entered, release = Event(), Event() entered, release = Event(), Event()
admitted, results = [], [] admitted, results = [], []
monkeypatch.setattr(backup_recovery, '_idle_check', lambda *a, **kw: None) monkeypatch.setattr(backup_recovery, '_idle_check', lambda *a, **kw: None)
# Native work is simulated here; machine WMI latency is not the stop/readback boundary.
monkeypatch.setattr('cbb_refresh_verify.owner_probe.query_owners', lambda names: [])
monkeypatch.setattr(timed_prompt, 'question', lambda *a, **kw: QMessageBox.Yes) monkeypatch.setattr(timed_prompt, 'question', lambda *a, **kw: QMessageBox.Yes)
class Worker: class Worker:
+112
View File
@@ -0,0 +1,112 @@
"""PR 16: handoff must preserve control flow, resource cleanup and cancellation."""
import json
from pathlib import Path
from threading import Event
from types import SimpleNamespace
import pytest
def test_verify_handoff_skips_duplicate_native_cleanup_and_keeps_result(tmp_path, monkeypatch):
from cbb_refresh_verify import operation_queue, verify_runner
from test_cancelled_session_handoff import worker_fixture
handoff = operation_queue.hold_native_handoff
state, _, run = worker_fixture(tmp_path, monkeypatch)
monkeypatch.setattr(operation_queue, 'hold_native_handoff', handoff)
late_cleanup = []
monkeypatch.setattr(verify_runner, '_cleanup_session_processes',
lambda *a, **kw: late_cleanup.append(True) or {'safe_to_continue': False})
completed = Event()
original = verify_runner._run_verify_task
def execute(*args, **kwargs):
try:
return original(*args, **kwargs)
finally:
completed.set()
monkeypatch.setattr(verify_runner, '_run_verify_task', execute)
result = run(True)
assert completed.wait(3)
assert result.status == 'CANCELLED' and not result.safe_to_continue
assert state['observers'] and not state['closed']
assert not late_cleanup, 'The registered observer owns native cleanup after handoff'
saved = json.loads(state['path'].with_name('result.json').read_text(encoding='utf-8'))
assert saved['status'] == 'CANCELLED' and saved['safe_to_continue'] is False
@pytest.mark.parametrize('registration_error', [False, True])
def test_repair_handoff_always_closes_local_worker_resources(tmp_path, monkeypatch, registration_error):
from cbb_refresh_verify import desktop_worker, native_repair, session_record
from cbb_refresh_verify.operation_queue import BatchTaskContext, TaskHandoff
events = []
class Worker:
pid = 700
session_record_path = tmp_path/'session.json'
def __init__(self, *args): pass
def bind_cancellation(self, path): pass
def bind_session(self, job): pass
def poll(self): return None
def request_stop(self): events.append('stop')
def close(self): events.append('close')
monkeypatch.setattr(desktop_worker, 'DesktopWorker', Worker)
ticks = iter((0, 100))
monkeypatch.setattr(native_repair, 'time', SimpleNamespace(monotonic=lambda: next(ticks)))
def observe(*args, **kwargs):
events.append('observe')
if registration_error:
raise OSError('observer registration failed')
monkeypatch.setattr(session_record, 'handoff_session', observe)
context = BatchTaskContext(str(tmp_path/'library.lmc'))
completed = Event()
def execute():
try:
return native_repair._supervise_repair([], 'CbbRepair_test', tmp_path/'cancel',
tmp_path, 1, None, None, {'start_gate': str(tmp_path/'start')})
finally:
completed.set()
with pytest.raises(OSError if registration_error else TaskHandoff):
context.run(execute)
assert completed.wait(3)
assert events == ['stop', 'observe', 'close']
def test_icdb_fallback_stop_cancels_the_active_task_context(qtbot, tmp_path, monkeypatch):
from cbb_refresh_verify.verify_runner import VerifyResult
from test_ui_filters import load_window
entered, release = Event(), Event()
def verify(request):
entered.set()
assert release.wait(3)
return VerifyResult('CANCELLED')
window = load_window(qtbot, tmp_path, monkeypatch, verifier=verify)
window._start_icdb_check(['Beta'])
try:
qtbot.waitUntil(entered.is_set)
window.stop.set()
assert window.icdb_task.stop.is_set(), 'Fallback Stop must cancel the running ICDB task'
finally:
window.icdb_task.cancel()
release.set()
qtbot.waitUntil(lambda: not window.icdb_task.active)
@pytest.mark.parametrize('mode', ['versions', 'repair'])
@pytest.mark.parametrize('config', [
'KEY iCDBDir "C:\\outside\\database"\n',
'KEY iCDBDir "database"\nKEY iCDBDir "other"\n',
])
def test_ambiguous_or_absolute_database_stops_before_native_launch(tmp_path, monkeypatch, mode, config):
from cbb_refresh_verify import native_backup
from test_native_backup import project_fixture
request, project = project_fixture(tmp_path)
project.write_text(config, encoding='utf-8')
monkeypatch.setattr(native_backup, 'native_backup_executable',
lambda *_: pytest.fail('Invalid database binding reached native preparation'))
with pytest.raises(ValueError, match='NATIVE_TARGET_UNCONFIRMED'):
native_backup.launch_native_backup(request, mode=mode)
assert not request.evidence_dir.exists()