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

Function main

ci/wasm_test.py:124–306  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

122
123
124async def main() -> None:
125 args = parse_args()
126
127 # Print colorful status message
128 console.print()
129 console.print(
130 Panel.fit(
131 f"[bold cyan]FastLED WASM Test Runner[/bold cyan]\n\n"
132 f"[yellow]Will:[/yellow]\n"
133 f" [green]✓[/green] Launch headless browser demo for [bold]{args.example}[/bold]\n"
134 f" [green]✓[/green] Poll for up to 30 seconds\n"
135 f" [green]✓[/green] Verify FastLED initialization & rendering\n"
136 f" [green]✓[/green] Exit automatically",
137 title="[bold magenta]Test Plan[/bold magenta]",
138 border_style="cyan",
139 )
140 )
141 console.print()
142
143 install_playwright_browsers()
144 # Find a free port starting from 8080
145 port = _find_free_port()
146 console.print(f"[dim]Using port: {port}[/dim]")
147
148 # Start the HTTP server
149 os.chdir(str(PROJECT_ROOT))
150 directory = Path(f"examples/{args.example}/fastled_js")
151 console.print(f"[cyan]Testing example:[/cyan] [bold]{args.example}[/bold]")
152 console.print(f"[dim]Server directory: {directory}[/dim]")
153 server_process = start_http_server(port=port, directory=directory)
154
155 try:
156 # Wait for server to be ready by attempting to connect
157 max_retries = 20
158 retry_delay = 0.5
159 server_ready = False
160
161 for attempt in range(max_retries):
162 if not server_process.is_alive():
163 raise Exception(f"HTTP server failed to start on port {port}")
164
165 with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
166 s.settimeout(1)
167 try:
168 s.connect(("localhost", port))
169 server_ready = True
170 break
171 except (ConnectionRefusedError, socket.timeout):
172 if attempt < max_retries - 1:
173 time.sleep(retry_delay)
174
175 if not server_ready:
176 raise Exception(
177 f"HTTP server on port {port} did not become ready within {max_retries * retry_delay}s"
178 )
179
180 # Use Playwright to test the server
181 async with async_playwright() as p:

Callers 1

wasm_test.pyFile · 0.70

Calls 14

CounterClass · 0.85
onMethod · 0.80
terminateMethod · 0.80
parse_argsFunction · 0.70
_find_free_portFunction · 0.70
start_http_serverFunction · 0.70
printMethod · 0.45
socketMethod · 0.45
connectMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected