Test accuracy of change detection across all cache types.
()
| 179 | |
| 180 | |
| 181 | def test_accuracy_all_caches() -> None: |
| 182 | """Test accuracy of change detection across all cache types.""" |
| 183 | with tempfile.TemporaryDirectory() as temp_dir: |
| 184 | temp_path = Path(temp_dir) |
| 185 | test_dir = temp_path / "test_files" |
| 186 | cache_dir = temp_path / ".cache" |
| 187 | cache_dir.mkdir(exist_ok=True) |
| 188 | |
| 189 | files = create_test_files(test_dir, 3) |
| 190 | include = ["**/*.txt"] |
| 191 | root = str(test_dir) |
| 192 | |
| 193 | # TwoLayerFingerprintCache accuracy |
| 194 | two_layer = TwoLayerFingerprintCache(cache_dir, "accuracy_two_layer") |
| 195 | two_layer.check_needs_update(include=include, root=root) |
| 196 | two_layer.mark_success() |
| 197 | |
| 198 | # Modify one file |
| 199 | time.sleep(0.05) |
| 200 | files[1].write_text("Modified content\n") |
| 201 | |
| 202 | needs_update = two_layer.check_needs_update(include=include, root=root) |
| 203 | assert needs_update, ( |
| 204 | "TwoLayerFingerprintCache: Should detect single file change" |
| 205 | ) |
| 206 | |
| 207 | # HashFingerprintCache accuracy |
| 208 | hash_cache = HashFingerprintCache(cache_dir, "accuracy_hash") |
| 209 | hash_cache.check_needs_update(include=include, root=root) |
| 210 | hash_cache.mark_success() |
| 211 | |
| 212 | # Modify different file |
| 213 | time.sleep(0.05) |
| 214 | files[2].write_text("Different modified content\n") |
| 215 | |
| 216 | needs_update = hash_cache.check_needs_update(include=include, root=root) |
| 217 | assert needs_update, "HashFingerprintCache: Should detect single file change" |
| 218 | |
| 219 | |
| 220 | def test_stress_rapid_operations() -> None: |
nothing calls this directly
no test coverage detected