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

Function save_test_result_state

ci/meson/cache_utils.py:376–406  ·  view source on GitHub ↗

Save test result to cache for future skip decisions. Records artifact path + mtime and pass/fail result. Called after each test run (success or failure) so the next run can skip re-execution when the artifact is unchanged and the last result was "pass".

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

Source from the content-addressed store, hash-verified

374
375
376def save_test_result_state(
377 build_dir: Path, test_name: str, artifact_path: Path, passed: bool
378) -> None:
379 """Save test result to cache for future skip decisions.
380
381 Records artifact path + mtime and pass/fail result.
382 Called after each test run (success or failure) so the next run can skip
383 re-execution when the artifact is unchanged and the last result was "pass".
384 """
385 cache_file = _get_test_result_cache_file(build_dir)
386 try:
387 existing: dict = {}
388 if cache_file.exists():
389 try:
390 with open(cache_file, "r", encoding="utf-8") as f:
391 existing = json.load(f)
392 except (json.JSONDecodeError, OSError):
393 existing = {}
394
395 if artifact_path.exists():
396 existing[test_name] = {
397 "artifact_path": str(artifact_path),
398 "artifact_mtime": artifact_path.stat().st_mtime,
399 "result": "pass" if passed else "fail",
400 }
401
402 with open(cache_file, "w", encoding="utf-8") as f:
403 json.dump(existing, f)
404
405 except (OSError, json.JSONDecodeError):
406 pass # Non-critical — next run will fall back to running normally
407
408
409# ---------------------------------------------------------------------------

Callers 1

run_direct_testFunction · 0.90

Calls 3

loadMethod · 0.45
dumpMethod · 0.45

Tested by

no test coverage detected