Skip to content

feat(ci): fbuild native-QEMU smoke test - #2346

Merged
zackees merged 1 commit into
masterfrom
feat/fbuild-qemu-smoke
Apr 19, 2026
Merged

zackees merged 1 commit into
masterfrom
feat/fbuild-qemu-smoke

Conversation

@zackees

@zackees zackees commented Apr 19, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Adds tests/fbuild_qemu_smoke/ — a minimal standalone PlatformIO project with a tiny FastLED sketch that prints FBUILD-QEMU-TEST-OK on boot.
  • Adds ci/tests/test_fbuild_qemu.py — invokes fbuild test-emu on the smoke project and asserts the boot marker.

Status: no longer xfail

The previous revision carried xfail(strict=False) tracking FastLED/fbuild#130 (daemon error: request failed on Windows despite a healthy daemon). That upstream bug was fixed in fbuild 2.1.20 (closed 2026-04-19). Since master now pins fbuild>=2.1.20 via #2353, this smoke test should pass on all platforms — the xfail marker is removed and subprocess.list2cmdline() is used in the error diagnostic per CodeRabbit's guideline feedback.

Why a dedicated project under tests/fbuild_qemu_smoke/

FastLED's root platformio.ini uses src_dir = ./src (the library itself, no setup()/loop()). fbuild test-emu needs an actual sketch. Keeping the smoke project small and standalone (single-env esp32dev, DIO flash mode for QEMU compat, FastLED via lib_deps = symlink://../..) avoids tangling with the Docker-based QEMU runner in ci/runners/qemu_runner.py.

Test plan

  • uv sync (resolves fbuild==2.1.20)
  • uv run pytest ci/tests/test_fbuild_qemu.py -v — now passes (xfail removed)
  • Manual: uv run fbuild test-emu tests/fbuild_qemu_smoke -e esp32dev --emulator qemu --timeout 10

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Documentation

    • Added CI test suite documentation with commands and coverage overview
    • Added QEMU smoke test project documentation with manual execution instructions
  • Tests

    • Added smoke test for QEMU emulation flow validation, including library resolution and boot behavior verification
    • Test includes configurable skip conditions and comprehensive output validation

@coderabbitai

coderabbitai Bot commented Apr 19, 2026 •

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

This PR adds CI test infrastructure to validate fbuild's native QEMU emulation path on ESP32, including a pytest test module that invokes fbuild, a minimal PlatformIO smoke project with an Arduino sketch, and supporting documentation.

Changes

Cohort / File(s) Summary
CI Test Documentation
ci/tests/README.md
Documentation describing the CI-side pytest suite, listing primary commands and functional areas covered (flash-merge utilities, example filtering, daemon helpers, fbuild adapters, etc.).
QEMU Smoke Test
ci/tests/test_fbuild_qemu.py
Pytest module with a smoke test for native fbuild test-emu flow; globally skips if fbuild not on PATH, conditionally skips if smoke project missing or FASTLED_SKIP_FBUILD_QEMU is set; executes fbuild with 10-minute timeout and verifies exit code and success marker string in output.
Smoke Project Config
tests/fbuild_qemu_smoke/platformio.ini
PlatformIO project configuration for esp32dev environment; pulls FastLED via symlink, sets flash mode to dio, uses huge_app.csv partitions, and enables QEMU-specific build flags.
Smoke Project Documentation
tests/fbuild_qemu_smoke/README.md, tests/fbuild_qemu_smoke/src/README.md
Documentation for the smoke project; describes its role in validating fbuild's QEMU execution path and library resolution, with manual execution instructions and success criteria.
Smoke Project Sketch
tests/fbuild_qemu_smoke/src/main.ino
Minimal Arduino sketch initializing Serial, configuring a FastLED WS2812 LED, and printing FBUILD-QEMU-TEST-OK on successful boot to signal test completion.

Sequence Diagram

sequenceDiagram
    participant Pytest as Pytest Runner
    participant Subprocess as subprocess.run()
    participant fbuild as fbuild Executable
    participant QEMU as QEMU Emulator
    participant Output as Serial Output

    Pytest->>Pytest: Check skip conditions<br/>(PATH, env vars, project exists)
    Pytest->>Subprocess: Execute fbuild test-emu<br/>esp32dev --emulator qemu
    Subprocess->>fbuild: Invoke with timeout (10 min)
    fbuild->>QEMU: Build & start emulation
    QEMU->>Output: Boot Arduino sketch
    Output->>Output: Print FBUILD-QEMU-TEST-BOOT
    Output->>Output: Initialize FastLED, set LED
    Output->>Output: Print FBUILD-QEMU-TEST-OK
    QEMU-->>fbuild: Complete
    fbuild-->>Subprocess: Exit code 0
    Subprocess-->>Pytest: Return with stdout/stderr
    Pytest->>Pytest: Assert return code == 0
    Pytest->>Pytest: Assert success marker in output
    Pytest->>Pytest: Pass/Fail with diagnostics
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related issues

Possibly related PRs

Poem

🐰 A test suite springs to life, so neat and lean,
With QEMU dancing in the fluorescent sheen,
FastLED sparkles in the emulated air,
While pytest hops about without a care! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title 'feat(ci): fbuild native-QEMU smoke test' directly and clearly summarizes the main change: adding a native QEMU smoke test for fbuild in the CI test suite.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/fbuild-qemu-smoke

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
pyproject.toml (1)

44-50: ⚠️ Potential issue | 🟡 Minor

Duplicate running-process dependency still present.

Line 44 pins running-process>=3.0.9 while line 50 re-lists running-process>=3.0.7. The PR description mentions removing a duplicate fbuild line, but this second duplicate was missed. Pip/uv will accept it, but it's confusing and the weaker >=3.0.7 is dead. Suggest removing line 50.

Proposed fix
     "bleak>=0.22.3",
-    "running-process>=3.0.7",
 ]
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@pyproject.toml` around lines 44 - 50, The pyproject.toml contains a duplicate
dependency "running-process" with two versions (>=3.0.9 and >=3.0.7); remove the
weaker duplicate entry ("running-process>=3.0.7") so only
"running-process>=3.0.9" remains, keeping the dependency list clean and
unambiguous; update any surrounding commas or trailing punctuation if needed to
keep the TOML array syntax valid.
🧹 Nitpick comments (3)
ci/tests/test_fbuild_qemu.py (1)

63-68: subprocess.run timeout will raise TimeoutExpired, not xfail cleanly.

With timeout=600 and no try/except, a hung fbuild (plausible given the upstream daemon bug tracked in #130) raises subprocess.TimeoutExpired. Under xfail(strict=False) that still counts as xfail, so this is benign today — but once the xfail is removed (per the PR plan) an upstream hang would turn into a hard CI error instead of a clean failure with diagnostics. Consider catching TimeoutExpired and converting it to a pytest.fail with captured partial output, alongside KeyboardInterrupt handled first per the repo's Python standards.

Sketch
-    proc = subprocess.run(
-        cmd,
-        capture_output=True,
-        text=True,
-        timeout=600,
-    )
+    try:
+        proc = subprocess.run(
+            cmd,
+            capture_output=True,
+            text=True,
+            timeout=600,
+        )
+    except KeyboardInterrupt:
+        raise
+    except subprocess.TimeoutExpired as e:
+        pytest.fail(
+            f"fbuild test-emu timed out after {e.timeout}s.\n"
+            f"CMD: {subprocess.list2cmdline(cmd)}\n"
+            f"--- STDOUT ---\n{(e.stdout or b'').decode(errors='replace') if isinstance(e.stdout, bytes) else (e.stdout or '')}\n"
+            f"--- STDERR ---\n{(e.stderr or b'').decode(errors='replace') if isinstance(e.stderr, bytes) else (e.stderr or '')}"
+        )

As per coding guidelines: "All Python try-catch blocks must handle KeyboardInterrupt before other exceptions".

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@ci/tests/test_fbuild_qemu.py` around lines 63 - 68, Wrap the subprocess.run
call that invokes cmd (the block using capture_output=True, text=True,
timeout=600) in a try/except that first handles KeyboardInterrupt (re-raise) and
then catches subprocess.TimeoutExpired; on TimeoutExpired call pytest.fail with
a message including the partial output (use the exception's stdout/stderr
attributes or captured output) so CI reports a clean failure with diagnostics
instead of crashing. Ensure you reference the subprocess.run invocation when
adding the try/except and import pytest if not already present.
tests/fbuild_qemu_smoke/README.md (1)

12-14: Nit: specify a language on the fenced code block.

markdownlint flags MD040. Use ```bash (or text) so the block renders with correct highlighting.

Proposed fix
-```
+```bash
 fbuild test-emu tests/fbuild_qemu_smoke -e esp32dev --emulator qemu --timeout 10
</details>

<details>
<summary>🤖 Prompt for AI Agents</summary>

Verify each finding against the current code and only fix it if needed.

In @tests/fbuild_qemu_smoke/README.md around lines 12 - 14, Update the fenced
code block in tests/fbuild_qemu_smoke/README.md to specify a language for syntax
highlighting (e.g., change the opening fence from tobash) so the example
command fbuild test-emu tests/fbuild_qemu_smoke -e esp32dev --emulator qemu --timeout 10 is rendered correctly and satisfies markdownlint MD040.


</details>

</blockquote></details>
<details>
<summary>tests/fbuild_qemu_smoke/platformio.ini (1)</summary><blockquote>

`10-10`: **Pin the `espressif32` platform to a specific version for CI stability.**

`platform = platformio/espressif32` floats to the latest registry version, which can cause this smoke test to break unexpectedly when unrelated platform updates occur. Most of the codebase pins to specific versions (e.g., `51.03.04` in `ci/adafruit_bridge` and `ci/kitchensink`, or `55.03.35` in the root `platformio.ini`). For consistency and stability, match the version used in the primary project configuration.

<details>
<summary>🤖 Prompt for AI Agents</summary>

```
Verify each finding against the current code and only fix it if needed.

In `@tests/fbuild_qemu_smoke/platformio.ini` at line 10, The platform declaration
"platform = platformio/espressif32" should be pinned to a specific version for
CI stability; update that setting to use the same fixed espressif32 version used
in the main project (replace the floating platform value with the pinned version
used in root platformio.ini, e.g., 55.03.35) so tests stop floating to the
latest registry releases.
```

</details>

</blockquote></details>

</blockquote></details>

<details>
<summary>🤖 Prompt for all review comments with AI agents</summary>

Verify each finding against the current code and only fix it if needed.

Inline comments:
In @ci/tests/test_fbuild_qemu.py:

  • Around line 70-75: The assertion builds a human-readable command string using
    ' '.join(cmd) which misrepresents arguments with spaces; replace that with
    subprocess.list2cmdline(cmd) in the assertion message (the one referencing
    proc.returncode, cmd, proc.stdout, proc.stderr) and ensure the module imports
    subprocess at the top of ci/tests/test_fbuild_qemu.py if it's not already
    imported.

Outside diff comments:
In @pyproject.toml:

  • Around line 44-50: The pyproject.toml contains a duplicate dependency
    "running-process" with two versions (>=3.0.9 and >=3.0.7); remove the weaker
    duplicate entry ("running-process>=3.0.7") so only "running-process>=3.0.9"
    remains, keeping the dependency list clean and unambiguous; update any
    surrounding commas or trailing punctuation if needed to keep the TOML array
    syntax valid.

Nitpick comments:
In @ci/tests/test_fbuild_qemu.py:

  • Around line 63-68: Wrap the subprocess.run call that invokes cmd (the block
    using capture_output=True, text=True, timeout=600) in a try/except that first
    handles KeyboardInterrupt (re-raise) and then catches subprocess.TimeoutExpired;
    on TimeoutExpired call pytest.fail with a message including the partial output
    (use the exception's stdout/stderr attributes or captured output) so CI reports
    a clean failure with diagnostics instead of crashing. Ensure you reference the
    subprocess.run invocation when adding the try/except and import pytest if not
    already present.

In @tests/fbuild_qemu_smoke/platformio.ini:

  • Line 10: The platform declaration "platform = platformio/espressif32" should
    be pinned to a specific version for CI stability; update that setting to use the
    same fixed espressif32 version used in the main project (replace the floating
    platform value with the pinned version used in root platformio.ini, e.g.,
    55.03.35) so tests stop floating to the latest registry releases.

In @tests/fbuild_qemu_smoke/README.md:

  • Around line 12-14: Update the fenced code block in
    tests/fbuild_qemu_smoke/README.md to specify a language for syntax highlighting
    (e.g., change the opening fence from tobash) so the example command
    fbuild test-emu tests/fbuild_qemu_smoke -e esp32dev --emulator qemu --timeout 10 is rendered correctly and satisfies markdownlint MD040.

</details>

<details>
<summary>🪄 Autofix (Beta)</summary>

Fix all unresolved CodeRabbit comments on this PR:

- [ ] <!-- {"checkboxId": "4b0d0e0a-96d7-4f10-b296-3a18ea78f0b9"} --> Push a commit to this branch (recommended)
- [ ] <!-- {"checkboxId": "ff5b1114-7d8c-49e6-8ac1-43f82af23a33"} --> Create a new PR with the fixes

</details>

---

<details>
<summary>ℹ️ Review info</summary>

<details>
<summary>⚙️ Run configuration</summary>

**Configuration used**: Path: .coderabbit.yaml

**Review profile**: CHILL

**Plan**: Pro

**Run ID**: `5fff1b9c-d9fb-4a3c-b4d0-b3e57731d281`

</details>

<details>
<summary>📥 Commits</summary>

Reviewing files that changed from the base of the PR and between 06c4019f2a6e3a86bbf7f69a0e1fa5e0715797e3 and 44499586ef0449c61ebf2dbc24bda714dc97bee8.

</details>

<details>
<summary>📒 Files selected for processing (7)</summary>

* `ci/tests/README.md`
* `ci/tests/test_fbuild_qemu.py`
* `pyproject.toml`
* `tests/fbuild_qemu_smoke/README.md`
* `tests/fbuild_qemu_smoke/platformio.ini`
* `tests/fbuild_qemu_smoke/src/README.md`
* `tests/fbuild_qemu_smoke/src/main.ino`

</details>

</details>

<!-- This is an auto-generated comment by CodeRabbit for review status -->

Comment thread ci/tests/test_fbuild_qemu.py Resolved
Adds a minimal standalone PlatformIO project under
`tests/fbuild_qemu_smoke/` with a tiny FastLED sketch that prints
`FBUILD-QEMU-TEST-OK` on boot, plus `ci/tests/test_fbuild_qemu.py`
which invokes `fbuild test-emu` against it and asserts the marker.

## Why a dedicated project
FastLED's root `platformio.ini` uses `src_dir = ./src` (the library
itself, no `setup()`/`loop()`). `fbuild test-emu` needs an actual
sketch. Keeping the smoke project small and standalone (single-env
`esp32dev`, DIO flash mode for QEMU compat, FastLED via
`lib_deps = symlink://../..`) avoids tangling with the Docker-based
QEMU runner in `ci/runners/qemu_runner.py`.

## Status
fbuild 2.1.20 resolves FastLED/fbuild#130 (`daemon error: request
failed` on Windows despite healthy daemon) — the previous `xfail`
marker is removed and this is now a passing smoke test as of the
fbuild pin bump in #2353. The pytest `skipif` falls back to
"fbuild not on PATH" if fbuild isn't installed.

## Review fixes
- `CMD: {subprocess.list2cmdline(cmd)}` in the failure message per
  the repo guideline (CodeRabbit feedback on the previous revision).

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@zackees
zackees force-pushed the feat/fbuild-qemu-smoke branch from 4449958 to ecd876d Compare April 19, 2026 08:43
@zackees zackees changed the title feat(ci): fbuild native-QEMU smoke (xfail on FastLED/fbuild#130) feat(ci): fbuild native-QEMU smoke test Apr 19, 2026
zackees added a commit that referenced this pull request Apr 19, 2026
…flict markers

Adds a `grep -q '^<<<<<<< ' pyproject.toml` pre-check in every `.claude`
hook command. If unresolved merge conflict markers are present, the hook
short-circuits through the existing `||` fallback and exits 0 with a
descriptive warning instead of letting `uv run` crash with a TOML parse
error (which propagates as hook failure and blocks every subsequent tool
call).

Without this guard, a mid-rebase state where git leaves conflict markers
in `pyproject.toml` creates a catch-22: every Claude tool invocation
triggers a PreToolUse hook → uv can't parse pyproject.toml → hook exits
non-zero → tool is blocked → the agent literally cannot fix the file
because every tool (Read, Write, Edit, Bash, Skill, ToolSearch) is
locked out. We hit this today during the PR #2346 rebase — user had to
fix pyproject.toml manually in a terminal to unblock the agent.

Implementation: single `grep` call (~1ms) in each hook's shell command;
the `||` fallback clause now covers both failure modes (no pyproject.toml
found AND conflict markers present) with an updated error message.

Also adds a `_conflict_marker_guard` key in settings.json documenting
the rationale so future readers know why the grep is there.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@ci/tests/test_fbuild_qemu.py`:
- Around line 16-19: Mark the smoke test(s) in this module xfail on Windows when
the external `fbuild` tool is present: import pytest and sys (since only os,
shutil, subprocess, Path are currently imported) and add
pytest.mark.xfail(condition=sys.platform.startswith("win") and
shutil.which("fbuild") is not None, reason="xfail on Windows while
FastLED/fbuild#130 is open") to the relevant test function(s) in this file (the
test(s) around lines 35-43 that exercise QEMU/fbuild). Ensure the marker uses
the condition so non-Windows runs still behave normally.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 5db73d00-d461-4db2-8c63-236b78b04ad4

📥 Commits

Reviewing files that changed from the base of the PR and between 4449958 and ecd876d.

📒 Files selected for processing (6)
  • ci/tests/README.md
  • ci/tests/test_fbuild_qemu.py
  • tests/fbuild_qemu_smoke/README.md
  • tests/fbuild_qemu_smoke/platformio.ini
  • tests/fbuild_qemu_smoke/src/README.md
  • tests/fbuild_qemu_smoke/src/main.ino
✅ Files skipped from review due to trivial changes (5)
  • tests/fbuild_qemu_smoke/src/README.md
  • ci/tests/README.md
  • tests/fbuild_qemu_smoke/README.md
  • tests/fbuild_qemu_smoke/platformio.ini
  • tests/fbuild_qemu_smoke/src/main.ino

Comment on lines +16 to +19
import os
import shutil
import subprocess
from pathlib import Path

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Add the intended Windows xfail marker.

The PR objective says this smoke test is expected to xfail for FastLED/fbuild#130. As written, Windows CI will hard-fail when fbuild is present.

Proposed fix
 import os
 import shutil
 import subprocess
+import sys
 from pathlib import Path
@@
 `@pytest.mark.skipif`(
     os.environ.get("FASTLED_SKIP_FBUILD_QEMU") == "1",
     reason="FASTLED_SKIP_FBUILD_QEMU=1",
 )
+@pytest.mark.xfail(
+    sys.platform == "win32",
+    reason="FastLED/fbuild#130: fbuild daemon API fails during test-emu on Windows",
+    strict=False,
+)
 def test_fbuild_test_emu_esp32dev() -> None:

Also applies to: 35-43

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@ci/tests/test_fbuild_qemu.py` around lines 16 - 19, Mark the smoke test(s) in
this module xfail on Windows when the external `fbuild` tool is present: import
pytest and sys (since only os, shutil, subprocess, Path are currently imported)
and add pytest.mark.xfail(condition=sys.platform.startswith("win") and
shutil.which("fbuild") is not None, reason="xfail on Windows while
FastLED/fbuild#130 is open") to the relevant test function(s) in this file (the
test(s) around lines 35-43 that exercise QEMU/fbuild). Ensure the marker uses
the condition so non-Windows runs still behave normally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant