Skip to content

refactor(lint): port EM_ASM clang-format pytest to Rust; drop 3 duplicate pytests (#3308) - #3321

Merged
zackees merged 1 commit into
masterfrom
fix/3308b-em-asm-port
Jun 20, 2026
Merged

zackees merged 1 commit into
masterfrom
fix/3308b-em-asm-port

Conversation

@zackees

@zackees zackees commented Jun 20, 2026 •

Copy link
Copy Markdown
Member

Summary

Issue #3308 PR-B (2 of 3 critical fixes from the issue). Consolidates four duplicate Python pytests into the Rust-backed fastled-lint fast path.

  • New EmAsmClangFormatChecker in ci/lint_cpp_rs/src/checkers/preprocessor.rs ports the WASM EM_ASM_ + clang-format off rule from ci/tests/test_wasm_clang_format.py — same scope (src/platforms/wasm/ with .h/.cpp), same trigger (file contains EM_ASM_ AND lacks clang-format off), one violation at line 1.
  • Registered at all 3 required CLI sites (supported_checker_names, supported_python_checker_names, create_checkers) plus RUST_SUPPORTED_CHECKERS in ci/lint_cpp/rust_bridge.py.
  • 3 inline Rust tests cover positive / negative / out-of-scope cases.
  • Deleted ci/tests/test_wasm_clang_format.py, test_missing_pragma_once.py, test_no_include_after_namespace.py, test_wrong_defines.py — the last three duplicate PragmaOnceChecker, IncludeAfterNamespaceChecker, and the WRONG_DEFINES block of BannedDefineChecker respectively (all verified to exist in ci/lint_cpp_rs/src/checkers/). No external code imported any of the four pytests.

A/B parity

Before deletion, both paths produced empty violation sets and exit 0 against the live tree:

  • uv run pytest ci/tests/test_wasm_clang_format.py → 1 passed
  • fastled-lint --checker em_asm_clang_format --format text → All Rust C++ linting checks passed! (exit 0)
  • Combined pragma_once,include_after_namespace,banned_define Rust run vs the three deleted pytests → both clean.

Test plan

  • bash lint --cpp → exit 0
  • uv run python ci/lint_cpp/run_all_checkers.py → all checks passed
  • Rust inline tests (em_asm_*) all green (positive, negative, out-of-scope)
  • A/B parity vs deleted pytests on whole src tree

Refs #3308.

Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added a new code validator for WASM source files
  • Tests

    • Added unit tests for the new WASM validator
    • Removed legacy Python-based CI tests, migrated to modern Rust-based implementation

…cate pytests (#3308)

Issue #3308 PR-B: consolidate four duplicate Python pytests into the
Rust-backed fastled-lint fast path. The Rust checker subset already
covers PragmaOnceChecker, IncludeAfterNamespaceChecker and the
WRONG_DEFINES set inside BannedDefineChecker, so the matching pytests
under ci/tests/ were re-running the same rule on every CI invocation
without adding coverage.

Changes:
- New EmAsmClangFormatChecker in ci/lint_cpp_rs/src/checkers/preprocessor.rs.
  Scope matches the original pytest exactly: walks src/platforms/wasm/
  for files ending in .h or .cpp and emits one violation at line 1 when
  the file contains EM_ASM_ but no clang-format off marker.
- Wired into supported_checker_names, supported_python_checker_names and
  create_checkers in processor_registry_cli.rs.
- Mirrored into RUST_SUPPORTED_CHECKERS in ci/lint_cpp/rust_bridge.py so
  the Python orchestrator skips the legacy checker class.
- Three inline tests covering the positive case, the suppression case
  and the out-of-scope case (src/fl/* must be ignored even when content
  matches the trigger pattern).
- Deleted ci/tests/test_wasm_clang_format.py, test_missing_pragma_once.py,
  test_no_include_after_namespace.py and test_wrong_defines.py after
  A/B parity (matching empty violation sets and exit codes) confirmed
  against the live src/ tree.

Verified: bash lint --cpp, uv run python ci/lint_cpp/run_all_checkers.py,
and the Rust em_asm inline tests (via soldr) all pass.

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

coderabbitai Bot commented Jun 20, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 8f9b9b5c-72a7-4409-b0b9-9fecd0af9a48

📥 Commits

Reviewing files that changed from the base of the PR and between d20d978 and 4a45b5f.

📒 Files selected for processing (8)
  • ci/lint_cpp/rust_bridge.py
  • ci/lint_cpp_rs/src/checkers/preprocessor.rs
  • ci/lint_cpp_rs/src/lint_core/processor_registry_cli.rs
  • ci/lint_cpp_rs/src/lint_core/tests.rs
  • ci/tests/test_missing_pragma_once.py
  • ci/tests/test_no_include_after_namespace.py
  • ci/tests/test_wasm_clang_format.py
  • ci/tests/test_wrong_defines.py
💤 Files with no reviewable changes (4)
  • ci/tests/test_missing_pragma_once.py
  • ci/tests/test_no_include_after_namespace.py
  • ci/tests/test_wrong_defines.py
  • ci/tests/test_wasm_clang_format.py

📝 Walkthrough

Walkthrough

Ports EmAsmClangFormatChecker from Python to Rust: a new FileContentChecker is added to preprocessor.rs scoped to src/platforms/wasm files, wired into the CLI registry and Python/Rust bridge, and covered by three unit tests. Four Python CI test files (test_wasm_clang_format.py, test_missing_pragma_once.py, test_no_include_after_namespace.py, test_wrong_defines.py) are removed.

Changes

EmAsmClangFormatChecker Rust port and Python test retirement

Layer / File(s) Summary
EmAsmClangFormatChecker implementation and unit tests
ci/lint_cpp_rs/src/checkers/preprocessor.rs, ci/lint_cpp_rs/src/lint_core/tests.rs
Adds EmAsmClangFormatChecker struct with should_process_file (restricts to src/platforms/wasm .h/.cpp) and check_file_content (one violation at line 1 when EM_ASM_ is present but clang-format off is absent). Three unit tests validate the violation, no-violation, and out-of-scope cases.
CLI registry wiring and Python bridge registration
ci/lint_cpp_rs/src/lint_core/processor_registry_cli.rs, ci/lint_cpp/rust_bridge.py
Registers em_asm_clang_format in supported_checker_names() and create_checkers(), exposes EmAsmClangFormatChecker in supported_python_checker_names(), and adds "EmAsmClangFormatChecker" to RUST_SUPPORTED_CHECKERS for Rust fast-path filtering and parity checks.
Retired Python test files
ci/tests/test_wasm_clang_format.py, ci/tests/test_missing_pragma_once.py, ci/tests/test_no_include_after_namespace.py, ci/tests/test_wrong_defines.py
Removes four Python unittest modules (totalling ~466 lines) that scanned source trees for WASM clang-format, #pragma once, include-after-namespace, and wrong-defines violations, now superseded by the Rust linter.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related issues

Possibly related PRs

  • FastLED/FastLED#2689: Established the Rust/Python bridge and --rust wiring infrastructure that EmAsmClangFormatChecker is now plugged into.
  • FastLED/FastLED#2692: Modified RUST_SUPPORTED_CHECKERS and the Rust/Python parity test harness that this PR extends with the new checker entry.
  • FastLED/FastLED#3121: Refactored the modular checker/registry structure in preprocessor.rs and processor_registry_cli.rs that this PR's new checker and wiring build upon.

Poem

🐇 Hippity-hop, the Python tests are gone,
A Rust checker now carries the check along!
EM_ASM_ files must clang-format off,
Or the linter will grumble and loudly scoff.
Four old test files? Quietly retired today—
The rabbit ports linters the fast-path way! 🦀

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 41.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: porting an EM_ASM clang-format pytest to Rust and removing three duplicate pytests.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ 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 fix/3308b-em-asm-port

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.

@zackees
zackees merged commit 493e9a2 into master Jun 20, 2026
10 of 11 checks passed
@fastled-project-sync fastled-project-sync Bot moved this from Triage to Done in FastLED Tracker Jun 20, 2026
@zackees
zackees deleted the fix/3308b-em-asm-port branch August 21, 2026 19:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant