Test cache consistency after simulated crash (no mark_success).
()
| 424 | |
| 425 | |
| 426 | def test_consistency_after_crash() -> None: |
| 427 | """Test cache consistency after simulated crash (no mark_success).""" |
| 428 | with tempfile.TemporaryDirectory() as temp_dir: |
| 429 | temp_path = Path(temp_dir) |
| 430 | test_dir = temp_path / "test_files" |
| 431 | cache_dir = temp_path / ".cache" |
| 432 | cache_dir.mkdir(exist_ok=True) |
| 433 | |
| 434 | create_test_files(test_dir, 3) |
| 435 | include = ["**/*.txt"] |
| 436 | root = str(test_dir) |
| 437 | |
| 438 | # TwoLayerFingerprintCache - check but don't mark success (simulated crash) |
| 439 | two_layer = TwoLayerFingerprintCache(cache_dir, "crash_two_layer") |
| 440 | two_layer.check_needs_update(include=include, root=root) |
| 441 | # Intentionally skip mark_success() |
| 442 | |
| 443 | # Create new instance - should still need update |
| 444 | two_layer2 = TwoLayerFingerprintCache(cache_dir, "crash_two_layer") |
| 445 | needs_update = two_layer2.check_needs_update(include=include, root=root) |
| 446 | assert needs_update, ( |
| 447 | "TwoLayerFingerprintCache: Should still need update after crash" |
| 448 | ) |
| 449 | |
| 450 | # HashFingerprintCache - check but don't mark success |
| 451 | hash_cache = HashFingerprintCache(cache_dir, "crash_hash") |
| 452 | hash_cache.check_needs_update(include=include, root=root) |
| 453 | # Intentionally skip mark_success() |
| 454 | |
| 455 | # Create new instance - should still need update |
| 456 | hash_cache2 = HashFingerprintCache(cache_dir, "crash_hash") |
| 457 | needs_update = hash_cache2.check_needs_update(include=include, root=root) |
| 458 | assert needs_update, ( |
| 459 | "HashFingerprintCache: Should still need update after crash" |
| 460 | ) |
nothing calls this directly
no test coverage detected