Detect what changed since last cache. Returns: { "unchanged": True/False, "new_tests": ["test_foo", "test_bar"], "deleted_tests": ["test_old"], "modified_tests": [] # Not implemented yet }
(tests_dir: Path, build_dir: Path)
| 153 | |
| 154 | |
| 155 | def detect_changes(tests_dir: Path, build_dir: Path) -> dict[str, list[str] | bool]: |
| 156 | """ |
| 157 | Detect what changed since last cache. |
| 158 | |
| 159 | Returns: |
| 160 | { |
| 161 | "unchanged": True/False, |
| 162 | "new_tests": ["test_foo", "test_bar"], |
| 163 | "deleted_tests": ["test_old"], |
| 164 | "modified_tests": [] # Not implemented yet |
| 165 | } |
| 166 | """ |
| 167 | cache = load_cache(build_dir) |
| 168 | |
| 169 | if cache is None: |
| 170 | # No cache - everything is new |
| 171 | return { |
| 172 | "unchanged": False, |
| 173 | "new_tests": [], |
| 174 | "deleted_tests": [], |
| 175 | "modified_tests": [], |
| 176 | } |
| 177 | |
| 178 | # Compute current hash |
| 179 | current_hash = compute_test_files_hash(tests_dir) |
| 180 | |
| 181 | # If hashes match, nothing changed |
| 182 | if cache["hash"] == current_hash: |
| 183 | return { |
| 184 | "unchanged": True, |
| 185 | "new_tests": [], |
| 186 | "deleted_tests": [], |
| 187 | "modified_tests": [], |
| 188 | } |
| 189 | |
| 190 | # Hash mismatch - need to run organize_tests.py to get actual differences |
| 191 | # For now, just report that something changed |
| 192 | return { |
| 193 | "unchanged": False, |
| 194 | "new_tests": [], |
| 195 | "deleted_tests": [], |
| 196 | "modified_tests": [], |
| 197 | } |
| 198 | |
| 199 | |
| 200 | def main() -> None: |
no test coverage detected