Skip to content
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

macros: forward input arguments in #[tokio::test] #3691

Merged
merged 2 commits into from Apr 11, 2021

Conversation

davidpdrsn
Copy link
Member

Fixes #2388

Previously #[tokio::test] would error on functions that took
arguments. That meant other attribute macros couldn't do further
transformations on them. This changes that so arguments are forwarded as
is.

Whatever else might be included on the function is forwarded as well.
For example return type, generics, etc.

Worth noting that this is only for compatibility with other macros.
#[test]s that take arguments will still fail to compile.

A bit odd that trybuild tests don't fail #[test] functions with
arguments which is why the new tests are run with t.pass(...). They do
actually fail if part of a real crate.

Fixes #2388

Previously `#[tokio::test]` would error on functions that took
arguments. That meant other attribute macros couldn't do further
transformations on them. This changes that so arguments are forwarded as
is.

Whatever else might be included on the function is forwarded as well.
For example return type, generics, etc.

Worth noting that this is only for compatibility with other macros.
`#[test]`s that take arguments will still fail to compile.

A bit odd that [trybuild] tests don't fail `#[test]` functions with
arguments which is why the new tests are run with `t.pass(...)`. They do
actually fail if part of a real crate.

[trybuild]: https://crates.io/crates/trybuild
@davidpdrsn davidpdrsn added the A-tokio-macros Area: The tokio-macros crate label Apr 10, 2021
@taiki-e
Copy link
Member

taiki-e commented Apr 10, 2021

A bit odd that trybuild tests don't fail #[test] functions with arguments

I think this is because trybuild runs cargo run/cargo build/cargo check instead of cargo test. (rustdoc has a similar problem.)

Copy link
Member

@taiki-e taiki-e left a comment

Choose a reason for hiding this comment

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

LGTM aside from CI failure.

@davidpdrsn davidpdrsn merged commit 28d6879 into master Apr 11, 2021
@davidpdrsn davidpdrsn deleted the david/forward-tokio-test-args branch April 11, 2021 18:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-tokio-macros Area: The tokio-macros crate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Forwarding input arguments of #[tokio::test] annotated tests
2 participants