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

Class PhaseTracker

ci/meson/phase_tracker.py:18–172  ·  view source on GitHub ↗

Thread-safe phase state tracker for build and test execution. Tracks the current phase (CONFIGURE/COMPILE/LINK/EXECUTE) to help disambiguate build and test failures. Uses atomic file writes and stale detection to handle process crashes gracefully. Example: tracker = Ph

Source from the content-addressed store, hash-verified

16
17
18class PhaseTracker:
19 """
20 Thread-safe phase state tracker for build and test execution.
21
22 Tracks the current phase (CONFIGURE/COMPILE/LINK/EXECUTE) to help
23 disambiguate build and test failures. Uses atomic file writes and
24 stale detection to handle process crashes gracefully.
25
26 Example:
27 tracker = PhaseTracker(build_dir, "quick")
28 tracker.set_phase("CONFIGURE")
29 # ... meson setup ...
30 tracker.set_phase("COMPILE", target="test_async")
31 # ... compilation ...
32 tracker.set_phase("EXECUTE", test_name="test_async")
33 # ... test execution ...
34 tracker.clear() # Success
35 """
36
37 def __init__(self, build_dir: Path, build_mode: str):
38 """
39 Initialize PhaseTracker.
40
41 Args:
42 build_dir: Meson build directory (e.g., .build/meson-quick)
43 build_mode: Build mode name (e.g., "quick", "debug", "release")
44 """
45 self.build_dir = Path(build_dir)
46 self.build_mode = build_mode
47 self.state_dir = self.build_dir.parent / "meson-state"
48 self.state_file = self.state_dir / f"current-phase-{build_mode}.json"
49 self._lock = threading.Lock()
50
51 # Ensure state directory exists
52 self.state_dir.mkdir(parents=True, exist_ok=True)
53
54 # Register cleanup handler for process exit
55 self._register_cleanup()
56
57 def set_phase(
58 self,
59 phase: Literal["CONFIGURE", "COMPILE", "LINK", "EXECUTE"],
60 test_name: Optional[str] = None,
61 target: Optional[str] = None,
62 path: Literal["sequential", "streaming"] = "sequential",
63 ) -> None:
64 """
65 Update phase state (thread-safe, atomic write).
66
67 Args:
68 phase: Current build/test phase
69 test_name: Name of test being executed (optional)
70 target: Compilation target (optional)
71 path: Execution path ("sequential" or "streaming")
72 """
73 with self._lock:
74 state = {
75 "phase": phase,

Callers 2

stream_compile_onlyFunction · 0.90
run_meson_build_and_testFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected