Skip to content

Conversation

@bjoernQ
Copy link
Contributor

@bjoernQ bjoernQ commented Oct 17, 2025

Thank you for your contribution!

We appreciate the time and effort you've put into this pull request.
To help us review it efficiently, please ensure you've gone through the following checklist:

Submission Checklist 📝

  • I have updated existing examples or added new ones (if applicable).
  • I have used cargo xtask fmt-packages command to ensure that all changed code is formatted correctly.
  • My changes were added to the CHANGELOG.md in the proper section.
  • I have added necessary changes to user code to the latest Migration Guide.
  • My changes are in accordance to the esp-rs developer guidelines

Extra:

Pull Request Details 📖

Description

This covers at least the check of the expansion of our attribute macros as asked for in #4343

For the "and can compile under certain conditions, i.e when building the stable hal etc." part, I'd say our hil-tests/examples cover the important macros (blocking,builder,doc_replace,interrupt,rtos_main) - not so much ram and lp_core.

I think the coverage here is quite ok (while not perfect) - for some macros like ram I'm not sure if we could even get every check triggering since some seem redundant but that needs more investigation.

image

(alert.rs is not really unit-testable but we usually see it working every day :) )
(lp_core.rs is missing a few fail-tests - given the overall state of the lp-core support I guess it's ok for now)

Might close #4343

skip-changelog since it's not user-visible.

Testing

CI

@bjoernQ bjoernQ added the skip-changelog No changelog modification needed label Oct 17, 2025
@bjoernQ bjoernQ marked this pull request as ready for review October 17, 2025 09:46
@bugadani bugadani requested a review from Copilot October 17, 2025 09:55
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds comprehensive unit tests for the procedural macros in esp-hal-procmacros, verifying both successful code expansion and error handling for various edge cases. The tests check that attribute macros like #[ram], #[handler], #[rtos_main], #[doc_replace], #[entry], and #[builder_lite] generate correct code and emit appropriate compile errors for invalid inputs.

Key changes:

  • Added test modules to each procmacro implementation file with extensive test coverage
  • Refactored internal functions to accept proc_macro2::TokenStream instead of proc_macro::TokenStream for testability
  • Added unwrap_or_compile_error! macro to standardize error handling
  • Modified doc comment code examples to use ignore instead of no_run

Reviewed Changes

Copilot reviewed 10 out of 11 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
xtask/src/lib.rs Added test configuration for esp-hal-procmacros package with required feature flags
esp-hal-procmacros/Cargo.toml Excluded testdata directory from package
esp-hal-procmacros/src/lib.rs Added unwrap_or_compile_error! macro, updated public API to convert between TokenStream types, changed doc examples to ignore
esp-hal-procmacros/src/rtos_main.rs Refactored to use proc_macro2::TokenStream, added 8 test cases for various scenarios
esp-hal-procmacros/src/ram.rs Refactored to use proc_macro2::TokenStream, added 19 test cases covering different ram placement options
esp-hal-procmacros/src/lp_core.rs Refactored to use proc_macro2::TokenStream, added filesystem abstraction for testing, added 5 test cases
esp-hal-procmacros/src/interrupt.rs Refactored to use proc_macro2::TokenStream, added 7 test cases for interrupt handler validation
esp-hal-procmacros/src/doc_replace.rs Refactored to use proc_macro2::TokenStream, added 8 test cases for doc replacement scenarios
esp-hal-procmacros/src/builder.rs Refactored to use proc_macro2::TokenStream, added 6 test cases for BuilderLite derive macro
esp-hal-procmacros/src/blocking.rs Refactored to use proc_macro2::TokenStream, added 3 test cases for blocking main validation

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copy link
Contributor

@JurajSadel JurajSadel left a comment

Choose a reason for hiding this comment

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

LGTM

@MabezDev MabezDev added this pull request to the merge queue Oct 20, 2025
Merged via the queue into esp-rs:main with commit 09db62a Oct 20, 2025
29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip-changelog No changelog modification needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Test attribute macros under various conditions

4 participants