fix: narrow cross-item and cross-library blockers
This commit is contained in:
1 parent
53118bae19
commit
aea6192ef9
8 files changed
+178
-15
No files matched your search
@@ -41,6 +41,21 @@ def test_batch_continuation_follows_actual_release(tmp_path, monkeypatch, status
|
||||
if owner: owner['handle'].Close()
|
||||
|
||||
|
||||
def test_item_failure_with_confirmed_release_does_not_stop_unrelated_items(tmp_path):
|
||||
from cbb_refresh_verify.verify_runner import VerifyRequest, VerifyResult
|
||||
library = tmp_path/'library.lmc'; library.touch()
|
||||
requests = [VerifyRequest(library, name, tmp_path/'evidence') for name in ('A', 'B')]
|
||||
calls = []
|
||||
def verify(request):
|
||||
calls.append(request.block_name)
|
||||
return VerifyResult('FAIL' if request.block_name == 'A' else 'PASS',
|
||||
stderr='单项失败但会话已释放' if request.block_name == 'A' else '',
|
||||
safe_to_continue=True)
|
||||
results = runner.run_batch(requests, verifier=verify)
|
||||
assert calls == ['A', 'B']
|
||||
assert [result.status for result in results] == ['FAIL', 'PASS']
|
||||
|
||||
|
||||
def test_stop_worker_escalates_only_after_cooperative_deadline():
|
||||
calls = []
|
||||
class Worker:
|
||||
|
||||
@@ -41,6 +41,47 @@ def test_catalog_checkpoint_does_not_disable_ordinary_verify(qtbot, tmp_path, mo
|
||||
assert 'ICDB' in window.cbb_table.item(window._row_by_name['Beta'], 3).text()
|
||||
|
||||
|
||||
def test_management_release_block_is_scoped_to_the_loaded_library(qtbot, tmp_path, monkeypatch):
|
||||
from test_ui_filters import load_window
|
||||
from cbb_refresh_verify.management import Capability
|
||||
adapter = type('Adapter', (), {
|
||||
'capabilities': lambda self: {name: Capability(True, 'available')
|
||||
for name in ('add', 'update', 'remove')}})()
|
||||
window = load_window(qtbot, tmp_path, monkeypatch, management_adapter=adapter)
|
||||
window._management_unsafe = True
|
||||
window._management_unsafe_library = (tmp_path/'library-a.lmc').resolve()
|
||||
window.lmc_edit.setText(str(tmp_path/'library-b.lmc'))
|
||||
window.loaded_path = str(tmp_path/'library-b.lmc')
|
||||
window.mentor_lmc_path = Path(window.loaded_path)
|
||||
window.select_visible_button.click()
|
||||
window._update()
|
||||
assert window.add_button.isEnabled()
|
||||
assert '上次管理操作' not in window._management_block_reason('update')
|
||||
|
||||
|
||||
def test_loading_a_different_library_clears_old_management_block(qtbot, tmp_path, monkeypatch):
|
||||
from test_ui_filters import load_window
|
||||
window = load_window(qtbot, tmp_path, monkeypatch)
|
||||
old = (tmp_path/'library-a.lmc').resolve()
|
||||
window._management_unsafe = True
|
||||
window._management_unsafe_library = old
|
||||
window.lmc_edit.setText(str(tmp_path/'library-b.lmc'))
|
||||
window.load_library()
|
||||
qtbot.waitUntil(lambda: not window.busy)
|
||||
assert not window._management_unsafe
|
||||
assert window._management_unsafe_library is None
|
||||
|
||||
|
||||
def test_targeted_native_idle_ignores_unrelated_native_command(tmp_path, monkeypatch):
|
||||
from cbb_refresh_verify import maintenance_entry as entry
|
||||
from cbb_refresh_verify.native_repair import RepairTarget
|
||||
project = tmp_path/'target.prj'; project.touch()
|
||||
monkeypatch.setattr('cbb_refresh_verify.owner_probe.query_owners', lambda names: [
|
||||
{'pid': 10, 'name': 'ExpeditionPCB.exe', 'command': 'ExpeditionPCB.exe other.pcb'},
|
||||
])
|
||||
entry.assert_native_idle(RepairTarget(project, tmp_path/'database'))
|
||||
|
||||
|
||||
def test_maintenance_guard_does_not_scan_other_cbb_projects(case, monkeypatch):
|
||||
from cbb_refresh_verify import maintenance_entry as entry
|
||||
from cbb_refresh_verify import scoped_manifest as manifests
|
||||
|
||||
@@ -134,6 +134,17 @@ def test_release_proof_checks_addresses_and_exclusive_databases(tmp_path, monkey
|
||||
assert proof['exclusive_files'] == [str(library)]
|
||||
|
||||
|
||||
def test_scoped_release_ignores_another_cbb_address(tmp_path, monkeypatch):
|
||||
import cbb_refresh_verify.library_lock as locks
|
||||
import cbb_refresh_verify.owner_probe as probe
|
||||
monkeypatch.setattr(probe, 'query_owners', lambda *_: [])
|
||||
library = tmp_path/'lib.lmc'; library.touch()
|
||||
other = tmp_path/'ReusableBlocksLP/Other/Work/database/cdbsvr/sAddress.adr'
|
||||
other.parent.mkdir(parents=True); other.touch()
|
||||
with locks._prove_library_released(library, block_name='Target') as proof:
|
||||
assert proof['addresses'] == []
|
||||
|
||||
|
||||
def test_release_probe_timeout_does_not_clear_retained_checkpoint(tmp_path, monkeypatch):
|
||||
import cbb_refresh_verify.library_lock as locks
|
||||
import cbb_refresh_verify.owner_probe as probe
|
||||
|
||||
Reference in new issue
Block a user