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

Function check_test_result_cached

ci/meson/cache_utils.py:329–373  ·  view source on GitHub ↗

Check if the test result is cached and the test can be skipped. Returns True if: 1. A cache entry exists for this test name 2. The artifact (DLL/exe) exists at the saved path 3. The artifact mtime matches the cached value (+-0.001s) 4. The last result was "pass" Rationale f

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

Source from the content-addressed store, hash-verified

327
328
329def check_test_result_cached(
330 build_dir: Path, test_name: str, artifact_path: Path
331) -> bool:
332 """Check if the test result is cached and the test can be skipped.
333
334 Returns True if:
335 1. A cache entry exists for this test name
336 2. The artifact (DLL/exe) exists at the saved path
337 3. The artifact mtime matches the cached value (+-0.001s)
338 4. The last result was "pass"
339
340 Rationale for DLL mtime as the sole gate:
341 - src/ changes -> libfastled.a rebuilt (ar_content_preserving) -> DLL relinked -> mtime changes
342 - test source changes -> DLL recompiled + relinked -> mtime changes
343 - meson reconfiguration -> DLL rebuilt -> mtime changes
344 Any code change that would affect test behavior also changes the DLL mtime.
345
346 Overhead: ~3ms (one JSON read + one stat call). Savings: ~2s per cached run.
347 """
348 cache_file = _get_test_result_cache_file(build_dir)
349 if not cache_file.exists():
350 return False
351 if not artifact_path.exists():
352 return False
353
354 try:
355 with open(cache_file, "r", encoding="utf-8") as f:
356 cache = json.load(f)
357
358 entry = cache.get(test_name)
359 if not entry:
360 return False
361
362 if entry.get("result") != "pass":
363 return False
364
365 saved_mtime = entry.get("artifact_mtime", -1.0)
366 current_mtime = artifact_path.stat().st_mtime
367 if abs(current_mtime - saved_mtime) > 0.001:
368 return False
369
370 return True
371
372 except (OSError, json.JSONDecodeError, KeyError, TypeError, ValueError):
373 return False
374
375
376def save_test_result_state(

Callers

nothing calls this directly

Calls 4

absFunction · 0.50
loadMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected