-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
macros: forward input arguments in
#[tokio::test]
(#3691)
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
- Loading branch information
1 parent
1a72b28
commit 28d6879
Showing
5 changed files
with
47 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
use tests_build::tokio; | ||
|
||
fn main() {} | ||
|
||
// arguments and output type is forwarded so other macros can access them | ||
|
||
#[tokio::test] | ||
async fn test_fn_has_args(_x: u8) {} | ||
|
||
#[tokio::test] | ||
async fn test_has_output() -> Result<(), Box<dyn std::error::Error>> { | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters