fix: bind persisted inventory cache coverage to full checksum

This commit is contained in:
阿白叔 committed 2026-10-23 16:10:00 +08:00
1 parent c787ef325b
commit 9837ca581b
2 files changed
+32 -3

No files matched your search

@@ -39,3 +39,23 @@ def test_corrupted_disk_cache_is_quarantined_and_read_once(tmp_path):
assert DiscoveryCache(root).discover(project,('OLD',),False,loader)==discovery
assert calls==[1]
assert list((root/'discovery-cache').glob('*.bad-*'))
def test_corrupted_cache_coverage_cannot_authorize_incomplete_reuse(tmp_path):
from dx_productivity.trial_task_center.discovery_cache import DiscoveryCache
from dx_productivity.trial_task_center.quick_run_protocol import ProjectDiscovery
project = tmp_path/'p/demo.prj'; project.parent.mkdir(); project.write_text('project')
root = tmp_path/'data'
discovery = ProjectDiscovery((('main','1'),), {('main','1'): frozenset({'OLD'})})
DiscoveryCache(root).discover(project, ('OLD',), False, lambda: discovery)
path = next((root/'discovery-cache').glob('*.json'))
value = json.loads(path.read_text())
value['parts'].append('other')
path.write_text(json.dumps(value))
calls = []
def loader():
calls.append(1)
return discovery
DiscoveryCache(root).discover(project, ('OTHER',), False, loader)
assert calls == [1]
assert list((root/'discovery-cache').glob('*.bad-*'))