MCPcopy Create free account
hub / github.com/FastLED/FastLED / test_cached

Function test_cached

ci/early_exit_cache.py:242–279  ·  view source on GitHub ↗

Check if test result is cached and test can be skipped (stdlib only). Verifies that: 1. Test result cache file exists 2. Test artifact (DLL/SO) file exists 3. Cached result was "pass" 4. Artifact hasn't been recompiled since cache write Mirrors ci/meson/cache_utils.

(build_dir: Path, test_name: str, artifact_path: Path)

Source from the content-addressed store, hash-verified

240
241
242def test_cached(build_dir: Path, test_name: str, artifact_path: Path) -> bool:
243 """Check if test result is cached and test can be skipped (stdlib only).
244
245 Verifies that:
246 1. Test result cache file exists
247 2. Test artifact (DLL/SO) file exists
248 3. Cached result was "pass"
249 4. Artifact hasn't been recompiled since cache write
250
251 Mirrors ci/meson/cache_utils.check_test_result_cached() without importing
252 that module.
253
254 Args:
255 build_dir: Meson build directory.
256 test_name: Test name (e.g. "fl_alloca").
257 artifact_path: Path to test artifact (DLL or SO file).
258
259 Returns:
260 True if test result is cached and artifact hasn't changed,
261 False if test needs to be re-run.
262 """
263 cache_file = build_dir / ".test_result_cache.json"
264 if not cache_file.exists() or not artifact_path.exists():
265 return False
266 try:
267 with open(cache_file, "r", encoding="utf-8") as f:
268 cache = json.load(f)
269 entry = cache.get(test_name)
270 if not entry or entry.get("result") != "pass":
271 return False
272 if (
273 abs(artifact_path.stat().st_mtime - entry.get("artifact_mtime", -1.0))
274 > 0.001
275 ):
276 return False
277 return True
278 except (OSError, json.JSONDecodeError, KeyError, TypeError, ValueError):
279 return False
280
281
282def full_run_cache(

Callers 1

check_single_test_cachedFunction · 0.85

Calls 3

absFunction · 0.50
loadMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected