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

Function _check_crash_dumps

test.py:123–167  ·  view source on GitHub ↗

Check for crash dump files and warn the user.

()

Source from the content-addressed store, hash-verified

121
122
123def _check_crash_dumps() -> None:
124 """Check for crash dump files and warn the user."""
125 if not _GDB_CRASH_DIR.exists():
126 return
127 dumps = sorted(_GDB_CRASH_DIR.glob("crash_*.txt"))
128 if not dumps:
129 return
130
131 # Build a content fingerprint from file names + sizes + mtimes
132 import hashlib
133
134 h = hashlib.md5()
135 for d in dumps:
136 stat = d.stat()
137 h.update(f"{d.name}:{stat.st_size}:{stat.st_mtime_ns}".encode())
138 current_hash = h.hexdigest()
139
140 # Check if we already warned about these exact dumps
141 seen_hash = ""
142 if _GDB_CRASH_SEEN.exists():
143 seen_hash = _GDB_CRASH_SEEN.read_text().strip()
144
145 RED = "\033[91m"
146 YELLOW = "\033[93m"
147 RESET = "\033[0m"
148 BOLD = "\033[1m"
149
150 if current_hash == seen_hash:
151 # Already seen — muted one-liner
152 print(
153 f"{YELLOW}(crash dumps unchanged in .gdb_crash/ — {len(dumps)} file(s), run `bash lint` to clean){RESET}"
154 )
155 else:
156 # New or changed dumps — loud red warning
157 print(f"\n{RED}{BOLD}{'=' * 60}")
158 print(f" CRASH DUMP(S) DETECTED — {len(dumps)} file(s) in .gdb_crash/")
159 print(f"{'=' * 60}{RESET}")
160 for d in dumps:
161 size = d.stat().st_size
162 print(f" {RED}{d.name}{RESET} ({size} bytes)")
163 print(f"{RED}{BOLD}Inspect with: cat .gdb_crash/<file>{RESET}")
164 print(f"{RED}{BOLD}Clean with: bash lint{RESET}")
165 print(f"{RED}{BOLD}{'=' * 60}{RESET}\n")
166 # Stamp so subsequent runs show the muted warning
167 _GDB_CRASH_SEEN.write_text(current_hash)
168
169
170# Platform to emulator backend mapping for --run command (lazy-loaded).

Callers 1

mainFunction · 0.85

Calls 2

printFunction · 0.50
updateMethod · 0.45

Tested by

no test coverage detected