Load cached test metadata from build directory. Args: build_dir: Meson build directory (e.g., .build/meson-quick/) Returns: Cache dictionary with keys: hash, timestamp, metadata None if cache doesn't exist or is invalid
(build_dir: Path)
| 85 | |
| 86 | |
| 87 | def load_cache(build_dir: Path) -> dict | None: |
| 88 | """ |
| 89 | Load cached test metadata from build directory. |
| 90 | |
| 91 | Args: |
| 92 | build_dir: Meson build directory (e.g., .build/meson-quick/) |
| 93 | |
| 94 | Returns: |
| 95 | Cache dictionary with keys: hash, timestamp, metadata |
| 96 | None if cache doesn't exist or is invalid |
| 97 | """ |
| 98 | cache_file = build_dir / CACHE_FILENAME |
| 99 | if not cache_file.exists(): |
| 100 | return None |
| 101 | |
| 102 | try: |
| 103 | with open(cache_file, "r", encoding="utf-8") as f: |
| 104 | cache = json.load(f) |
| 105 | |
| 106 | # Validate cache structure |
| 107 | required_keys = ["hash", "timestamp", "metadata"] |
| 108 | if not all(key in cache for key in required_keys): |
| 109 | return None |
| 110 | |
| 111 | return cache |
| 112 | except (json.JSONDecodeError, OSError): |
| 113 | return None |
| 114 | |
| 115 | |
| 116 | def save_cache(build_dir: Path, tests_hash: str, metadata: str) -> None: |
no test coverage detected