Skip to content

Append generated test macro so next test macros are aware of it #17

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 1, 2025

Conversation

kezhuw
Copy link
Contributor

@kezhuw kezhuw commented Apr 1, 2025

This is an attempt to improve capabilities among test macros to avoid duplicated test runs which is rare to be aware of.

The rationale is simple: procedure of attribute macro see only attributes following it. Macros next to processing macro will not see generated macro if it is generated in-place. So, instead of generating test macro in-place, appending generated test macro will let macros next to processing macro have chance to react, for example, not generate test macro if there is already one.

Without the fix, the new test will run twice.

See also tokio-rs/tokio#6497, d-e-s-o/test-log#46, frondeus/test-case#143, la10736/rstest#291, google/googletest-rust#561, kezhuw/stuck#53.

kezhuw and others added 2 commits April 1, 2025 12:58
This is an attempt to improve capabilities among test macros to avoid
duplicated test runs which is rare to be aware of.

The rationale is simple: procedure of attribute macro see only attributes
following it. Macros next to processing macro will not see generated
macro if it is generated in-place. So, instead of generating test macro
in-place, appending generated test macro will let macros next to processing
macro have chance to react, for example, not generate test macro if there
is already one.

Without the fix, the new test will run twice.

See also tokio-rs/tokio#6497, d-e-s-o/test-log#46, frondeus/test-case#143,
la10736/rstest#291, google/googletest-rust#561, kezhuw/stuck#53.
@frozenlib
Copy link
Owner

Thanks for the contribution! The changes look good. Merging now.

@frozenlib frozenlib merged commit 1b145db into frozenlib:master Apr 1, 2025
1 check passed
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.

2 participants