forked from tokio-rs/tokio
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
macros: custom package name for #[tokio::main] and #[tokio::test]
This also enables `#[crate::test(package = "crate")]` in unit tests. Sees rust-lang/cargo#5653. Fixes tokio-rs#2312.
- Loading branch information
Showing
5 changed files
with
169 additions
and
34 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
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,25 @@ | ||
#![cfg(feature = "full")] | ||
|
||
use std as tokio; | ||
|
||
use ::tokio as tokio1; | ||
|
||
async fn compute() -> usize { | ||
let join = tokio1::spawn(async { tokio::mem::size_of::<u8>() }); | ||
join.await.unwrap() | ||
} | ||
|
||
#[tokio1::main(package = "tokio1")] | ||
async fn compute_main() -> usize { | ||
compute().await | ||
} | ||
|
||
#[test] | ||
fn package_rename_main() { | ||
assert_eq!(1, compute_main()); | ||
} | ||
|
||
#[tokio1::test(package = "tokio1")] | ||
async fn package_rename_test() { | ||
assert_eq!(1, compute().await); | ||
} |