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

Function validate_test_artifact

ci/meson/streaming_runner.py:43–95  ·  view source on GitHub ↗

Validate a test/example binary before running it. Returns ``None`` if the artifact is fresh and ready to run. Returns a populated ``TestResult`` (``success=False``) if the artifact is missing or stale, so the caller can surface the failure directly instead of silently running broken

(
    test_path: Path, build_start_time: float
)

Source from the content-addressed store, hash-verified

41
42
43def validate_test_artifact(
44 test_path: Path, build_start_time: float
45) -> Optional[TestResult]:
46 """Validate a test/example binary before running it.
47
48 Returns ``None`` if the artifact is fresh and ready to run. Returns
49 a populated ``TestResult`` (``success=False``) if the artifact is
50 missing or stale, so the caller can surface the failure directly
51 instead of silently running broken/old code.
52
53 Why this matters (FastLED #3011): the streaming compiler submits
54 tests to the runner as soon as Ninja prints ``[N/M] Linking <X>``
55 — but that line is Ninja&#x27;s PRE-link announcement, NOT a success
56 signal. If the link then FAILS (zccache daemon crash under the
57 parallel-link storm, ld.lld permission error, etc.) ``test_path``
58 is either missing entirely (clean build) or stale from a previous
59 build sitting in the same build dir. Running it produces a
60 false pass or false fail; refusing to run it surfaces the link
61 failure where it belongs.
62 """
63 if not test_path.exists():
64 return TestResult(
65 success=False,
66 output=(
67 f"[MESON] ❌ Test artifact missing: {test_path}\n"
68 f" Link likely failed during the parallel-link storm "
69 f"(zccache daemon crash, ld.lld error, etc.) — see "
70 f"FastLED #3011. Refusing to run a missing DLL.\n"
71 f" Resolve the underlying link failure and re-run."
72 ),
73 )
74 try:
75 dll_mtime = test_path.stat().st_mtime
76 except OSError:
77 # stat() failure is non-fatal — let the subprocess loader
78 # surface whatever it actually sees on disk.
79 return None
80 if dll_mtime < build_start_time:
81 return TestResult(
82 success=False,
83 output=(
84 f"[MESON] ❌ Stale test artifact: {test_path}\n"
85 f" DLL mtime ({dll_mtime:.2f}) predates this build's "
86 f"start ({build_start_time:.2f}). The current link "
87 f"likely failed and left a previous build's DLL behind "
88 f"— running it would produce misleading results (see "
89 f"FastLED #3011).\n"
90 f" Resolve the underlying link failure (`zccache stop` "
91 f"+ retry usually clears the daemon-crash variant) and "
92 f"re-run."
93 ),
94 )
95 return None
96
97
98@dataclass

Calls 1

TestResultClass · 0.90