Skip to content

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

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 1 commit into from
Feb 17, 2025

Conversation

kezhuw
Copy link
Contributor

@kezhuw kezhuw commented Jan 20, 2025

#[gtest] will benefit from la10736/rstest#291, we could also benefit other test macros.

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.

We could deprecate #[googletest::test] oneday after la10736/rstest#291 released.

See: tokio-rs/tokio#6497, d-e-s-o/test-log#46, frondeus/test-case#143, la10736/rstest#291, kezhuw/stuck#53.
Refs: rust-lang/rust#67839, rust-lang/rust#82419.

@gribozavr
Copy link
Collaborator

@kezhuw Sorry for the delayed response! Your PR has developed a merge conflict with the code at HEAD, could you fix it?

Generally this approach LGTM.

@gribozavr gribozavr assigned gribozavr and kezhuw and unassigned gribozavr Feb 17, 2025
`#[gtest]` will benefit from la10736/rstest#291, we could also benefit
other test macros.

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.

We could deprecate `#[googletest::test]` oneday after la10736/rstest#291
released.

See: tokio-rs/tokio#6497, d-e-s-o/test-log#46, frondeus/test-case#143,
la10736/rstest#291, kezhuw/stuck#53.
Refs: rust-lang/rust#67839, rust-lang/rust#82419.
@kezhuw kezhuw force-pushed the test-proc-macros-cooperation branch from dc7620d to ee4996d Compare February 17, 2025 11:54
@kezhuw
Copy link
Contributor Author

kezhuw commented Feb 17, 2025

@gribozavr Conflict resolved. Please take another look.

@gribozavr gribozavr assigned gribozavr and unassigned kezhuw Feb 17, 2025
@copybara-service copybara-service bot merged commit 08f6807 into google:main Feb 17, 2025
20 of 21 checks passed
kezhuw added a commit to kezhuw/test-strategy that referenced this pull request 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.
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