diff --git a/Cargo.toml b/Cargo.toml index ec50183..a1cc20f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,4 +1,7 @@ [workspace] + +resolver = "1" + members = [ "async-entry", "test-async-entry", diff --git a/async-entry/Cargo.toml b/async-entry/Cargo.toml index dcbb80e..ff841e1 100644 --- a/async-entry/Cargo.toml +++ b/async-entry/Cargo.toml @@ -12,9 +12,22 @@ extended Tokio's proc macros. """ categories = ["asynchronous"] +[features] + +default = [] + +# Use tokio as runtime: +# https://tokio.rs/ +tokio = [] + +# Use monoio as runtime: +# https://github.com/bytedance/monoio +monoio = [] + [lib] proc-macro = true + [dependencies] syn = { version = "1.0.56", features = ["full"] } quote = "1" @@ -24,4 +37,5 @@ proc-macro2 = "1.0.7" [dev-dependencies] anyhow = "1.0.55" tokio = { version = "1.7.1", features = ["macros", "rt","rt-multi-thread", "sync", "test-util"] } +monoio = { version = "0.1.0", features = [] } tracing = "0.1.29" diff --git a/async-entry/src/lib.rs b/async-entry/src/lib.rs index b97e829..a13ed69 100644 --- a/async-entry/src/lib.rs +++ b/async-entry/src/lib.rs @@ -5,9 +5,21 @@ use proc_macro2::Span; use quote::quote; use quote::quote_spanned; use quote::ToTokens; +use syn::__private::TokenStream2; use syn::parse::Parser; use syn::ItemFn; +fn get_runtime_name() -> &'static str { + if cfg!(feature = "tokio") { + return "tokio"; + } + if cfg!(feature = "monoio") { + return "monoio"; + } else { + return "tokio"; + } +} + #[derive(Debug, Clone, Copy, PartialEq)] enum RuntimeFlavor { CurrentThread, @@ -143,9 +155,17 @@ impl Configuration { fn macro_name(&self) -> &'static str { if self.is_test { - "tokio::test" + match get_runtime_name() { + "tokio" => "tokio::test", + "monoio" => "monoio::test", + _ => unreachable!(), + } } else { - "tokio::main" + match get_runtime_name() { + "tokio" => "tokio::main", + "monoio" => "monoio::main", + _ => unreachable!(), + } } } @@ -333,9 +353,17 @@ fn build_config(args: AttributeArgs, rt_multi_thread: bool) -> Result; -/// Marks async function to be executed by runtime, suitable to test environment +/// Marks async function to be executed by async runtime, suitable to test environment +/// +/// It supports: +/// - [tokio](https://tokio.rs/) +/// - [monoio](https://github.com/bytedance/monoio) /// -/// ## Usage +/// By default it uses `tokio` runtime. Switch runtime with feature flags: +/// - `tokio`: tokio runtime; +/// - `monoio`: monoio runtime; +/// +/// ## Usage for tokio runtime /// /// ### Multi-thread runtime /// @@ -432,6 +460,29 @@ type AttributeArgs = syn::punctuated::Punctuated::new()... +/// // rt.block_on(body); +/// // } +/// ``` +/// /// ### NOTE: /// /// If you rename the async_entry crate in your dependencies this macro will not work. @@ -479,31 +530,7 @@ fn build_test_fn(mut item_fn: ItemFn, config: FinalConfig) -> Result quote_spanned! {last_stmt_start_span=> - #rt_builder::new_current_thread() - }, - RuntimeFlavor::Threaded => quote_spanned! {last_stmt_start_span=> - #rt_builder::new_multi_thread() - }, - }; - - if let Some(v) = config.worker_threads { - rt_builder = quote! { #rt_builder.worker_threads(#v) }; - } - - if let Some(v) = config.start_paused { - rt_builder = quote! { #rt_builder.start_paused(#v) }; - } - - let rt = quote! { - #rt_builder - .enable_all() - .build() - .expect("Failed building the Runtime") - }; + let rt = build_runtime(last_stmt_start_span, &config)?; let init = if let Some(init) = config.init { let init_str = format!("let _g = {};", init.0); @@ -563,7 +590,8 @@ fn build_test_fn(mut item_fn: ItemFn, config: FinalConfig) -> Result Result Result { + let rt_builder = { + match get_runtime_name() { + "tokio" => { + let mut rt_builder = quote! { tokio::runtime::Builder }; + + rt_builder = match config.flavor { + RuntimeFlavor::CurrentThread => quote_spanned! {span=> + #rt_builder::new_current_thread() + }, + RuntimeFlavor::Threaded => quote_spanned! {span=> + #rt_builder::new_multi_thread() + }, + }; + + if let Some(v) = config.worker_threads { + rt_builder = quote! { #rt_builder.worker_threads(#v) }; + } + + if let Some(v) = config.start_paused { + rt_builder = quote! { #rt_builder.start_paused(#v) }; + } + rt_builder + } + "monoio" => { + let rt_builder = quote! { monoio::RuntimeBuilder::::new() }; + rt_builder + } + _ => unreachable!(), + } + }; + + let rt: TokenStream2 = quote! { + #rt_builder + .enable_all() + .build() + .expect("Failed building the Runtime") + }; + + Ok(rt) +} + /// Parse TokenStream of some fn fn parse_item_fn(item: TokenStream) -> Result { let input = syn::parse::(item.clone())?; diff --git a/async-entry/want-monoio b/async-entry/want-monoio new file mode 100644 index 0000000..6182de9 --- /dev/null +++ b/async-entry/want-monoio @@ -0,0 +1,499 @@ +#![feature(prelude_import)] +#[prelude_import] +use std::prelude::rust_2021::*; +#[macro_use] +extern crate std; +extern crate test; +#[cfg(test)] +#[rustc_test_marker = "empty"] +pub const empty: test::TestDescAndFn = test::TestDescAndFn { + desc: test::TestDesc { + name: test::StaticTestName("empty"), + ignore: false, + ignore_message: ::core::option::Option::None, + source_file: "async-entry/tests/it.rs", + start_line: 2usize, + start_col: 10usize, + end_line: 2usize, + end_col: 15usize, + compile_fail: false, + no_run: false, + should_panic: test::ShouldPanic::No, + test_type: test::TestType::IntegrationTest, + }, + testfn: test::StaticTestFn(|| test::assert_test_result(empty())), +}; +fn empty() { + let body = async {}; + #[allow(unused_mut)] + let mut rt = monoio::RuntimeBuilder::::new() + .enable_all() + .build() + .expect("Failed building the Runtime"); + #[allow(clippy::expect_used)] + rt.block_on(body); +} +extern crate test; +#[cfg(test)] +#[rustc_test_marker = "empty_with_parentheses"] +pub const empty_with_parentheses: test::TestDescAndFn = test::TestDescAndFn { + desc: test::TestDesc { + name: test::StaticTestName("empty_with_parentheses"), + ignore: false, + ignore_message: ::core::option::Option::None, + source_file: "async-entry/tests/it.rs", + start_line: 5usize, + start_col: 10usize, + end_line: 5usize, + end_col: 32usize, + compile_fail: false, + no_run: false, + should_panic: test::ShouldPanic::No, + test_type: test::TestType::IntegrationTest, + }, + testfn: test::StaticTestFn(|| test::assert_test_result(empty_with_parentheses())), +}; +fn empty_with_parentheses() { + let body = async {}; + #[allow(unused_mut)] + let mut rt = monoio::RuntimeBuilder::::new() + .enable_all() + .build() + .expect("Failed building the Runtime"); + #[allow(clippy::expect_used)] + rt.block_on(body); +} +extern crate test; +#[cfg(test)] +#[rustc_test_marker = "empty_tail_expr"] +pub const empty_tail_expr: test::TestDescAndFn = test::TestDescAndFn { + desc: test::TestDesc { + name: test::StaticTestName("empty_tail_expr"), + ignore: false, + ignore_message: ::core::option::Option::None, + source_file: "async-entry/tests/it.rs", + start_line: 8usize, + start_col: 10usize, + end_line: 8usize, + end_col: 25usize, + compile_fail: false, + no_run: false, + should_panic: test::ShouldPanic::No, + test_type: test::TestType::IntegrationTest, + }, + testfn: test::StaticTestFn(|| test::assert_test_result(empty_tail_expr())), +}; +fn empty_tail_expr() -> anyhow::Result<()> { + let body = async { Ok(()) }; + #[allow(unused_mut)] + let mut rt = monoio::RuntimeBuilder::::new() + .enable_all() + .build() + .expect("Failed building the Runtime"); + #[allow(clippy::expect_used)] + rt.block_on(body) +} +extern crate test; +#[cfg(test)] +#[rustc_test_marker = "empty_return_expr"] +pub const empty_return_expr: test::TestDescAndFn = test::TestDescAndFn { + desc: test::TestDesc { + name: test::StaticTestName("empty_return_expr"), + ignore: false, + ignore_message: ::core::option::Option::None, + source_file: "async-entry/tests/it.rs", + start_line: 13usize, + start_col: 10usize, + end_line: 13usize, + end_col: 27usize, + compile_fail: false, + no_run: false, + should_panic: test::ShouldPanic::No, + test_type: test::TestType::IntegrationTest, + }, + testfn: test::StaticTestFn(|| test::assert_test_result(empty_return_expr())), +}; +fn empty_return_expr() -> anyhow::Result<()> { + let body = async { + return Ok(()); + }; + #[allow(unused_mut)] + let mut rt = monoio::RuntimeBuilder::::new() + .enable_all() + .build() + .expect("Failed building the Runtime"); + #[allow(clippy::expect_used)] + return rt.block_on(body); +} +extern crate test; +#[cfg(test)] +#[rustc_test_marker = "empty_trace_span"] +pub const empty_trace_span: test::TestDescAndFn = test::TestDescAndFn { + desc: test::TestDesc { + name: test::StaticTestName("empty_trace_span"), + ignore: false, + ignore_message: ::core::option::Option::None, + source_file: "async-entry/tests/it.rs", + start_line: 18usize, + start_col: 10usize, + end_line: 18usize, + end_col: 26usize, + compile_fail: false, + no_run: false, + should_panic: test::ShouldPanic::No, + test_type: test::TestType::IntegrationTest, + }, + testfn: test::StaticTestFn(|| test::assert_test_result(empty_trace_span())), +}; +fn empty_trace_span() { + let body = async {}; + use tracing::Instrument; + let body_span = { + use ::tracing::__macro_support::Callsite as _; + static CALLSITE: ::tracing::__macro_support::MacroCallsite = { + use ::tracing::__macro_support::MacroCallsite; + static META: ::tracing::Metadata<'static> = { + ::tracing_core::metadata::Metadata::new( + "empty_trace_span", + "it", + ::tracing::Level::INFO, + Some("async-entry/tests/it.rs"), + Some(17u32), + Some("it"), + ::tracing_core::field::FieldSet::new( + &[], + ::tracing_core::callsite::Identifier(&CALLSITE), + ), + ::tracing::metadata::Kind::SPAN, + ) + }; + MacroCallsite::new(&META) + }; + let mut interest = ::tracing::subscriber::Interest::never(); + if ::tracing::Level::INFO <= ::tracing::level_filters::STATIC_MAX_LEVEL + && ::tracing::Level::INFO <= ::tracing::level_filters::LevelFilter::current() + && { + interest = CALLSITE.interest(); + !interest.is_never() + } + && CALLSITE.is_enabled(interest) + { + let meta = CALLSITE.metadata(); + ::tracing::Span::new(meta, &{ meta.fields().value_set(&[]) }) + } else { + let span = CALLSITE.disabled_span(); + {}; + span + } + }; + let body = body.instrument(body_span); + #[allow(unused_mut)] + let mut rt = monoio::RuntimeBuilder::::new() + .enable_all() + .build() + .expect("Failed building the Runtime"); + #[allow(clippy::expect_used)] + rt.block_on(body); +} +extern crate test; +#[cfg(test)] +#[rustc_test_marker = "empty_trace_lib"] +pub const empty_trace_lib: test::TestDescAndFn = test::TestDescAndFn { + desc: test::TestDesc { + name: test::StaticTestName("empty_trace_lib"), + ignore: false, + ignore_message: ::core::option::Option::None, + source_file: "async-entry/tests/it.rs", + start_line: 21usize, + start_col: 10usize, + end_line: 21usize, + end_col: 25usize, + compile_fail: false, + no_run: false, + should_panic: test::ShouldPanic::No, + test_type: test::TestType::IntegrationTest, + }, + testfn: test::StaticTestFn(|| test::assert_test_result(empty_trace_lib())), +}; +fn empty_trace_lib() { + let body = async {}; + use tracing::Instrument; + let body_span = { + use ::tracing::__macro_support::Callsite as _; + static CALLSITE: ::tracing::__macro_support::MacroCallsite = { + use ::tracing::__macro_support::MacroCallsite; + static META: ::tracing::Metadata<'static> = { + ::tracing_core::metadata::Metadata::new( + "empty_trace_lib", + "it", + ::tracing::Level::INFO, + Some("async-entry/tests/it.rs"), + Some(20u32), + Some("it"), + ::tracing_core::field::FieldSet::new( + &[], + ::tracing_core::callsite::Identifier(&CALLSITE), + ), + ::tracing::metadata::Kind::SPAN, + ) + }; + MacroCallsite::new(&META) + }; + let mut interest = ::tracing::subscriber::Interest::never(); + if ::tracing::Level::INFO <= ::tracing::level_filters::STATIC_MAX_LEVEL + && ::tracing::Level::INFO <= ::tracing::level_filters::LevelFilter::current() + && { + interest = CALLSITE.interest(); + !interest.is_never() + } + && CALLSITE.is_enabled(interest) + { + let meta = CALLSITE.metadata(); + ::tracing::Span::new(meta, &{ meta.fields().value_set(&[]) }) + } else { + let span = CALLSITE.disabled_span(); + {}; + span + } + }; + let body = body.instrument(body_span); + #[allow(unused_mut)] + let mut rt = monoio::RuntimeBuilder::::new() + .enable_all() + .build() + .expect("Failed building the Runtime"); + #[allow(clippy::expect_used)] + rt.block_on(body); +} +fn g() {} +extern crate test; +#[cfg(test)] +#[rustc_test_marker = "with_init"] +pub const with_init: test::TestDescAndFn = test::TestDescAndFn { + desc: test::TestDesc { + name: test::StaticTestName("with_init"), + ignore: false, + ignore_message: ::core::option::Option::None, + source_file: "async-entry/tests/it.rs", + start_line: 26usize, + start_col: 10usize, + end_line: 26usize, + end_col: 19usize, + compile_fail: false, + no_run: false, + should_panic: test::ShouldPanic::No, + test_type: test::TestType::IntegrationTest, + }, + testfn: test::StaticTestFn(|| test::assert_test_result(with_init())), +}; +fn with_init() { + let _g = g(); + let body = async {}; + #[allow(unused_mut)] + let mut rt = monoio::RuntimeBuilder::::new() + .enable_all() + .build() + .expect("Failed building the Runtime"); + #[allow(clippy::expect_used)] + rt.block_on(body); +} +extern crate test; +#[cfg(test)] +#[rustc_test_marker = "current_thread"] +pub const current_thread: test::TestDescAndFn = test::TestDescAndFn { + desc: test::TestDesc { + name: test::StaticTestName("current_thread"), + ignore: false, + ignore_message: ::core::option::Option::None, + source_file: "async-entry/tests/it.rs", + start_line: 29usize, + start_col: 10usize, + end_line: 29usize, + end_col: 24usize, + compile_fail: false, + no_run: false, + should_panic: test::ShouldPanic::No, + test_type: test::TestType::IntegrationTest, + }, + testfn: test::StaticTestFn(|| test::assert_test_result(current_thread())), +}; +fn current_thread() { + let body = async {}; + #[allow(unused_mut)] + let mut rt = monoio::RuntimeBuilder::::new() + .enable_all() + .build() + .expect("Failed building the Runtime"); + #[allow(clippy::expect_used)] + rt.block_on(body); +} +extern crate test; +#[cfg(test)] +#[rustc_test_marker = "multi_thread"] +pub const multi_thread: test::TestDescAndFn = test::TestDescAndFn { + desc: test::TestDesc { + name: test::StaticTestName("multi_thread"), + ignore: false, + ignore_message: ::core::option::Option::None, + source_file: "async-entry/tests/it.rs", + start_line: 32usize, + start_col: 10usize, + end_line: 32usize, + end_col: 22usize, + compile_fail: false, + no_run: false, + should_panic: test::ShouldPanic::No, + test_type: test::TestType::IntegrationTest, + }, + testfn: test::StaticTestFn(|| test::assert_test_result(multi_thread())), +}; +fn multi_thread() { + let body = async {}; + #[allow(unused_mut)] + let mut rt = monoio::RuntimeBuilder::::new() + .enable_all() + .build() + .expect("Failed building the Runtime"); + #[allow(clippy::expect_used)] + rt.block_on(body); +} +extern crate test; +#[cfg(test)] +#[rustc_test_marker = "multi_thread_0"] +pub const multi_thread_0: test::TestDescAndFn = test::TestDescAndFn { + desc: test::TestDesc { + name: test::StaticTestName("multi_thread_0"), + ignore: false, + ignore_message: ::core::option::Option::None, + source_file: "async-entry/tests/it.rs", + start_line: 35usize, + start_col: 10usize, + end_line: 35usize, + end_col: 24usize, + compile_fail: false, + no_run: false, + should_panic: test::ShouldPanic::No, + test_type: test::TestType::IntegrationTest, + }, + testfn: test::StaticTestFn(|| test::assert_test_result(multi_thread_0())), +}; +fn multi_thread_0() { + let body = async {}; + #[allow(unused_mut)] + let mut rt = monoio::RuntimeBuilder::::new() + .enable_all() + .build() + .expect("Failed building the Runtime"); + #[allow(clippy::expect_used)] + rt.block_on(body); +} +extern crate test; +#[cfg(test)] +#[rustc_test_marker = "multi_thread_n"] +pub const multi_thread_n: test::TestDescAndFn = test::TestDescAndFn { + desc: test::TestDesc { + name: test::StaticTestName("multi_thread_n"), + ignore: false, + ignore_message: ::core::option::Option::None, + source_file: "async-entry/tests/it.rs", + start_line: 38usize, + start_col: 10usize, + end_line: 38usize, + end_col: 24usize, + compile_fail: false, + no_run: false, + should_panic: test::ShouldPanic::No, + test_type: test::TestType::IntegrationTest, + }, + testfn: test::StaticTestFn(|| test::assert_test_result(multi_thread_n())), +}; +fn multi_thread_n() { + let body = async {}; + #[allow(unused_mut)] + let mut rt = monoio::RuntimeBuilder::::new() + .enable_all() + .build() + .expect("Failed building the Runtime"); + #[allow(clippy::expect_used)] + rt.block_on(body); +} +extern crate test; +#[cfg(test)] +#[rustc_test_marker = "multi_thread_n_without_flavor"] +pub const multi_thread_n_without_flavor: test::TestDescAndFn = test::TestDescAndFn { + desc: test::TestDesc { + name: test::StaticTestName("multi_thread_n_without_flavor"), + ignore: false, + ignore_message: ::core::option::Option::None, + source_file: "async-entry/tests/it.rs", + start_line: 41usize, + start_col: 10usize, + end_line: 41usize, + end_col: 39usize, + compile_fail: false, + no_run: false, + should_panic: test::ShouldPanic::No, + test_type: test::TestType::IntegrationTest, + }, + testfn: test::StaticTestFn(|| test::assert_test_result(multi_thread_n_without_flavor())), +}; +fn multi_thread_n_without_flavor() { + let body = async {}; + #[allow(unused_mut)] + let mut rt = monoio::RuntimeBuilder::::new() + .enable_all() + .build() + .expect("Failed building the Runtime"); + #[allow(clippy::expect_used)] + rt.block_on(body); +} +extern crate test; +#[cfg(test)] +#[rustc_test_marker = "start_paused"] +pub const start_paused: test::TestDescAndFn = test::TestDescAndFn { + desc: test::TestDesc { + name: test::StaticTestName("start_paused"), + ignore: false, + ignore_message: ::core::option::Option::None, + source_file: "async-entry/tests/it.rs", + start_line: 44usize, + start_col: 10usize, + end_line: 44usize, + end_col: 22usize, + compile_fail: false, + no_run: false, + should_panic: test::ShouldPanic::No, + test_type: test::TestType::IntegrationTest, + }, + testfn: test::StaticTestFn(|| test::assert_test_result(start_paused())), +}; +fn start_paused() { + let body = async {}; + #[allow(unused_mut)] + let mut rt = monoio::RuntimeBuilder::::new() + .enable_all() + .build() + .expect("Failed building the Runtime"); + #[allow(clippy::expect_used)] + rt.block_on(body); +} +#[rustc_main] +#[coverage(off)] +pub fn main() -> () { + extern crate test; + test::test_main_static(&[ + ¤t_thread, + &empty, + &empty_return_expr, + &empty_tail_expr, + &empty_trace_lib, + &empty_trace_span, + &empty_with_parentheses, + &multi_thread, + &multi_thread_0, + &multi_thread_n, + &multi_thread_n_without_flavor, + &start_paused, + &with_init, + ]) +} diff --git a/async-entry/want b/async-entry/want-tokio similarity index 77% rename from async-entry/want rename to async-entry/want-tokio index 0209d35..c6ff848 100644 --- a/async-entry/want +++ b/async-entry/want-tokio @@ -5,12 +5,17 @@ use std::prelude::rust_2021::*; extern crate std; extern crate test; #[cfg(test)] -#[rustc_test_marker] +#[rustc_test_marker = "empty"] pub const empty: test::TestDescAndFn = test::TestDescAndFn { desc: test::TestDesc { name: test::StaticTestName("empty"), ignore: false, ignore_message: ::core::option::Option::None, + source_file: "async-entry/tests/it.rs", + start_line: 2usize, + start_col: 10usize, + end_line: 2usize, + end_col: 15usize, compile_fail: false, no_run: false, should_panic: test::ShouldPanic::No, @@ -20,7 +25,8 @@ pub const empty: test::TestDescAndFn = test::TestDescAndFn { }; fn empty() { let body = async {}; - let rt = tokio::runtime::Builder::new_current_thread() + #[allow(unused_mut)] + let mut rt = tokio::runtime::Builder::new_current_thread() .enable_all() .build() .expect("Failed building the Runtime"); @@ -29,12 +35,17 @@ fn empty() { } extern crate test; #[cfg(test)] -#[rustc_test_marker] +#[rustc_test_marker = "empty_with_parentheses"] pub const empty_with_parentheses: test::TestDescAndFn = test::TestDescAndFn { desc: test::TestDesc { name: test::StaticTestName("empty_with_parentheses"), ignore: false, ignore_message: ::core::option::Option::None, + source_file: "async-entry/tests/it.rs", + start_line: 5usize, + start_col: 10usize, + end_line: 5usize, + end_col: 32usize, compile_fail: false, no_run: false, should_panic: test::ShouldPanic::No, @@ -44,7 +55,8 @@ pub const empty_with_parentheses: test::TestDescAndFn = test::TestDescAndFn { }; fn empty_with_parentheses() { let body = async {}; - let rt = tokio::runtime::Builder::new_current_thread() + #[allow(unused_mut)] + let mut rt = tokio::runtime::Builder::new_current_thread() .enable_all() .build() .expect("Failed building the Runtime"); @@ -53,12 +65,17 @@ fn empty_with_parentheses() { } extern crate test; #[cfg(test)] -#[rustc_test_marker] +#[rustc_test_marker = "empty_tail_expr"] pub const empty_tail_expr: test::TestDescAndFn = test::TestDescAndFn { desc: test::TestDesc { name: test::StaticTestName("empty_tail_expr"), ignore: false, ignore_message: ::core::option::Option::None, + source_file: "async-entry/tests/it.rs", + start_line: 8usize, + start_col: 10usize, + end_line: 8usize, + end_col: 25usize, compile_fail: false, no_run: false, should_panic: test::ShouldPanic::No, @@ -68,7 +85,8 @@ pub const empty_tail_expr: test::TestDescAndFn = test::TestDescAndFn { }; fn empty_tail_expr() -> anyhow::Result<()> { let body = async { Ok(()) }; - let rt = tokio::runtime::Builder::new_current_thread() + #[allow(unused_mut)] + let mut rt = tokio::runtime::Builder::new_current_thread() .enable_all() .build() .expect("Failed building the Runtime"); @@ -77,12 +95,17 @@ fn empty_tail_expr() -> anyhow::Result<()> { } extern crate test; #[cfg(test)] -#[rustc_test_marker] +#[rustc_test_marker = "empty_return_expr"] pub const empty_return_expr: test::TestDescAndFn = test::TestDescAndFn { desc: test::TestDesc { name: test::StaticTestName("empty_return_expr"), ignore: false, ignore_message: ::core::option::Option::None, + source_file: "async-entry/tests/it.rs", + start_line: 13usize, + start_col: 10usize, + end_line: 13usize, + end_col: 27usize, compile_fail: false, no_run: false, should_panic: test::ShouldPanic::No, @@ -94,7 +117,8 @@ fn empty_return_expr() -> anyhow::Result<()> { let body = async { return Ok(()); }; - let rt = tokio::runtime::Builder::new_current_thread() + #[allow(unused_mut)] + let mut rt = tokio::runtime::Builder::new_current_thread() .enable_all() .build() .expect("Failed building the Runtime"); @@ -103,12 +127,17 @@ fn empty_return_expr() -> anyhow::Result<()> { } extern crate test; #[cfg(test)] -#[rustc_test_marker] +#[rustc_test_marker = "empty_trace_span"] pub const empty_trace_span: test::TestDescAndFn = test::TestDescAndFn { desc: test::TestDesc { name: test::StaticTestName("empty_trace_span"), ignore: false, ignore_message: ::core::option::Option::None, + source_file: "async-entry/tests/it.rs", + start_line: 18usize, + start_col: 10usize, + end_line: 18usize, + end_col: 26usize, compile_fail: false, no_run: false, should_panic: test::ShouldPanic::No, @@ -158,7 +187,8 @@ fn empty_trace_span() { } }; let body = body.instrument(body_span); - let rt = tokio::runtime::Builder::new_current_thread() + #[allow(unused_mut)] + let mut rt = tokio::runtime::Builder::new_current_thread() .enable_all() .build() .expect("Failed building the Runtime"); @@ -167,12 +197,17 @@ fn empty_trace_span() { } extern crate test; #[cfg(test)] -#[rustc_test_marker] +#[rustc_test_marker = "empty_trace_lib"] pub const empty_trace_lib: test::TestDescAndFn = test::TestDescAndFn { desc: test::TestDesc { name: test::StaticTestName("empty_trace_lib"), ignore: false, ignore_message: ::core::option::Option::None, + source_file: "async-entry/tests/it.rs", + start_line: 21usize, + start_col: 10usize, + end_line: 21usize, + end_col: 25usize, compile_fail: false, no_run: false, should_panic: test::ShouldPanic::No, @@ -222,7 +257,8 @@ fn empty_trace_lib() { } }; let body = body.instrument(body_span); - let rt = tokio::runtime::Builder::new_current_thread() + #[allow(unused_mut)] + let mut rt = tokio::runtime::Builder::new_current_thread() .enable_all() .build() .expect("Failed building the Runtime"); @@ -232,12 +268,17 @@ fn empty_trace_lib() { fn g() {} extern crate test; #[cfg(test)] -#[rustc_test_marker] +#[rustc_test_marker = "with_init"] pub const with_init: test::TestDescAndFn = test::TestDescAndFn { desc: test::TestDesc { name: test::StaticTestName("with_init"), ignore: false, ignore_message: ::core::option::Option::None, + source_file: "async-entry/tests/it.rs", + start_line: 26usize, + start_col: 10usize, + end_line: 26usize, + end_col: 19usize, compile_fail: false, no_run: false, should_panic: test::ShouldPanic::No, @@ -248,7 +289,8 @@ pub const with_init: test::TestDescAndFn = test::TestDescAndFn { fn with_init() { let _g = g(); let body = async {}; - let rt = tokio::runtime::Builder::new_current_thread() + #[allow(unused_mut)] + let mut rt = tokio::runtime::Builder::new_current_thread() .enable_all() .build() .expect("Failed building the Runtime"); @@ -257,12 +299,17 @@ fn with_init() { } extern crate test; #[cfg(test)] -#[rustc_test_marker] +#[rustc_test_marker = "current_thread"] pub const current_thread: test::TestDescAndFn = test::TestDescAndFn { desc: test::TestDesc { name: test::StaticTestName("current_thread"), ignore: false, ignore_message: ::core::option::Option::None, + source_file: "async-entry/tests/it.rs", + start_line: 29usize, + start_col: 10usize, + end_line: 29usize, + end_col: 24usize, compile_fail: false, no_run: false, should_panic: test::ShouldPanic::No, @@ -272,7 +319,8 @@ pub const current_thread: test::TestDescAndFn = test::TestDescAndFn { }; fn current_thread() { let body = async {}; - let rt = tokio::runtime::Builder::new_current_thread() + #[allow(unused_mut)] + let mut rt = tokio::runtime::Builder::new_current_thread() .enable_all() .build() .expect("Failed building the Runtime"); @@ -281,12 +329,17 @@ fn current_thread() { } extern crate test; #[cfg(test)] -#[rustc_test_marker] +#[rustc_test_marker = "multi_thread"] pub const multi_thread: test::TestDescAndFn = test::TestDescAndFn { desc: test::TestDesc { name: test::StaticTestName("multi_thread"), ignore: false, ignore_message: ::core::option::Option::None, + source_file: "async-entry/tests/it.rs", + start_line: 32usize, + start_col: 10usize, + end_line: 32usize, + end_col: 22usize, compile_fail: false, no_run: false, should_panic: test::ShouldPanic::No, @@ -296,7 +349,8 @@ pub const multi_thread: test::TestDescAndFn = test::TestDescAndFn { }; fn multi_thread() { let body = async {}; - let rt = tokio::runtime::Builder::new_multi_thread() + #[allow(unused_mut)] + let mut rt = tokio::runtime::Builder::new_multi_thread() .enable_all() .build() .expect("Failed building the Runtime"); @@ -305,12 +359,17 @@ fn multi_thread() { } extern crate test; #[cfg(test)] -#[rustc_test_marker] +#[rustc_test_marker = "multi_thread_0"] pub const multi_thread_0: test::TestDescAndFn = test::TestDescAndFn { desc: test::TestDesc { name: test::StaticTestName("multi_thread_0"), ignore: false, ignore_message: ::core::option::Option::None, + source_file: "async-entry/tests/it.rs", + start_line: 35usize, + start_col: 10usize, + end_line: 35usize, + end_col: 24usize, compile_fail: false, no_run: false, should_panic: test::ShouldPanic::No, @@ -320,7 +379,8 @@ pub const multi_thread_0: test::TestDescAndFn = test::TestDescAndFn { }; fn multi_thread_0() { let body = async {}; - let rt = tokio::runtime::Builder::new_current_thread() + #[allow(unused_mut)] + let mut rt = tokio::runtime::Builder::new_current_thread() .enable_all() .build() .expect("Failed building the Runtime"); @@ -329,12 +389,17 @@ fn multi_thread_0() { } extern crate test; #[cfg(test)] -#[rustc_test_marker] +#[rustc_test_marker = "multi_thread_n"] pub const multi_thread_n: test::TestDescAndFn = test::TestDescAndFn { desc: test::TestDesc { name: test::StaticTestName("multi_thread_n"), ignore: false, ignore_message: ::core::option::Option::None, + source_file: "async-entry/tests/it.rs", + start_line: 38usize, + start_col: 10usize, + end_line: 38usize, + end_col: 24usize, compile_fail: false, no_run: false, should_panic: test::ShouldPanic::No, @@ -344,7 +409,8 @@ pub const multi_thread_n: test::TestDescAndFn = test::TestDescAndFn { }; fn multi_thread_n() { let body = async {}; - let rt = tokio::runtime::Builder::new_multi_thread() + #[allow(unused_mut)] + let mut rt = tokio::runtime::Builder::new_multi_thread() .worker_threads(10usize) .enable_all() .build() @@ -354,12 +420,17 @@ fn multi_thread_n() { } extern crate test; #[cfg(test)] -#[rustc_test_marker] +#[rustc_test_marker = "multi_thread_n_without_flavor"] pub const multi_thread_n_without_flavor: test::TestDescAndFn = test::TestDescAndFn { desc: test::TestDesc { name: test::StaticTestName("multi_thread_n_without_flavor"), ignore: false, ignore_message: ::core::option::Option::None, + source_file: "async-entry/tests/it.rs", + start_line: 41usize, + start_col: 10usize, + end_line: 41usize, + end_col: 39usize, compile_fail: false, no_run: false, should_panic: test::ShouldPanic::No, @@ -369,7 +440,8 @@ pub const multi_thread_n_without_flavor: test::TestDescAndFn = test::TestDescAnd }; fn multi_thread_n_without_flavor() { let body = async {}; - let rt = tokio::runtime::Builder::new_multi_thread() + #[allow(unused_mut)] + let mut rt = tokio::runtime::Builder::new_multi_thread() .worker_threads(10usize) .enable_all() .build() @@ -379,12 +451,17 @@ fn multi_thread_n_without_flavor() { } extern crate test; #[cfg(test)] -#[rustc_test_marker] +#[rustc_test_marker = "start_paused"] pub const start_paused: test::TestDescAndFn = test::TestDescAndFn { desc: test::TestDesc { name: test::StaticTestName("start_paused"), ignore: false, ignore_message: ::core::option::Option::None, + source_file: "async-entry/tests/it.rs", + start_line: 44usize, + start_col: 10usize, + end_line: 44usize, + end_col: 22usize, compile_fail: false, no_run: false, should_panic: test::ShouldPanic::No, @@ -394,7 +471,8 @@ pub const start_paused: test::TestDescAndFn = test::TestDescAndFn { }; fn start_paused() { let body = async {}; - let rt = tokio::runtime::Builder::new_current_thread() + #[allow(unused_mut)] + let mut rt = tokio::runtime::Builder::new_current_thread() .start_paused(true) .enable_all() .build() @@ -403,21 +481,22 @@ fn start_paused() { rt.block_on(body); } #[rustc_main] +#[coverage(off)] pub fn main() -> () { extern crate test; test::test_main_static(&[ + ¤t_thread, &empty, - &empty_with_parentheses, - &empty_tail_expr, &empty_return_expr, - &empty_trace_span, + &empty_tail_expr, &empty_trace_lib, - &with_init, - ¤t_thread, + &empty_trace_span, + &empty_with_parentheses, &multi_thread, &multi_thread_0, &multi_thread_n, &multi_thread_n_without_flavor, &start_paused, + &with_init, ]) } diff --git a/lib-crate/Cargo.toml b/lib-crate/Cargo.toml index 5fa4015..16ef09b 100644 --- a/lib-crate/Cargo.toml +++ b/lib-crate/Cargo.toml @@ -7,4 +7,5 @@ edition = "2021" [dependencies] tokio = { version = "1.7.1", features = ["macros", "rt","rt-multi-thread", "sync", "test-util"] } +monoio = { version = "0.1.0", features = [] } tracing = "0.1.29" diff --git a/lib-crate/src/lib.rs b/lib-crate/src/lib.rs index be45646..f1512d5 100644 --- a/lib-crate/src/lib.rs +++ b/lib-crate/src/lib.rs @@ -1,5 +1,6 @@ //! A crate collects indirect dependency for test. //! It is referenced by crate `test-async-entry`. +pub use monoio; pub use tokio; pub use tracing; diff --git a/test-async-entry/Cargo.toml b/test-async-entry/Cargo.toml index 627f890..c173bd9 100644 --- a/test-async-entry/Cargo.toml +++ b/test-async-entry/Cargo.toml @@ -13,6 +13,11 @@ extended Tokio's proc macros. categories = ["asynchronous"] +[features] + +tokio = ["async-entry/tokio"] +monoio = ["async-entry/monoio"] + [dependencies] syn = { version = "1.0.56", features = ["full"] } diff --git a/test-async-entry/tests/it-external.rs b/test-async-entry/tests/it-external.rs index bae7782..9578375 100644 --- a/test-async-entry/tests/it-external.rs +++ b/test-async-entry/tests/it-external.rs @@ -1,5 +1,8 @@ // Use the imported mod e.g. `tracing` to build. +#[allow(unused_imports)] +use lib_crate::monoio; +#[allow(unused_imports)] use lib_crate::tokio; use lib_crate::tracing; diff --git a/test-async-entry/tests/it-tracing-lib.rs b/test-async-entry/tests/it-tracing-lib.rs index f905307..9f34d35 100644 --- a/test-async-entry/tests/it-tracing-lib.rs +++ b/test-async-entry/tests/it-tracing-lib.rs @@ -1,3 +1,6 @@ +#[allow(unused_imports)] +use lib_crate::monoio; +#[allow(unused_imports)] use lib_crate::tokio; /// Specify where to load tracing and tracing_future. diff --git a/test-async-entry/want-external-monoio b/test-async-entry/want-external-monoio new file mode 100644 index 0000000..55ee954 --- /dev/null +++ b/test-async-entry/want-external-monoio @@ -0,0 +1,504 @@ +#![feature(prelude_import)] +#[prelude_import] +use std::prelude::rust_2021::*; +#[macro_use] +extern crate std; +#[allow(unused_imports)] +use lib_crate::monoio; +#[allow(unused_imports)] +use lib_crate::tokio; +use lib_crate::tracing; +extern crate test; +#[cfg(test)] +#[rustc_test_marker = "empty"] +pub const empty: test::TestDescAndFn = test::TestDescAndFn { + desc: test::TestDesc { + name: test::StaticTestName("empty"), + ignore: false, + ignore_message: ::core::option::Option::None, + source_file: "test-async-entry/tests/it-external.rs", + start_line: 10usize, + start_col: 10usize, + end_line: 10usize, + end_col: 15usize, + compile_fail: false, + no_run: false, + should_panic: test::ShouldPanic::No, + test_type: test::TestType::IntegrationTest, + }, + testfn: test::StaticTestFn(|| test::assert_test_result(empty())), +}; +fn empty() { + let body = async {}; + #[allow(unused_mut)] + let mut rt = monoio::RuntimeBuilder::::new() + .enable_all() + .build() + .expect("Failed building the Runtime"); + #[allow(clippy::expect_used)] + rt.block_on(body); +} +extern crate test; +#[cfg(test)] +#[rustc_test_marker = "empty_with_parentheses"] +pub const empty_with_parentheses: test::TestDescAndFn = test::TestDescAndFn { + desc: test::TestDesc { + name: test::StaticTestName("empty_with_parentheses"), + ignore: false, + ignore_message: ::core::option::Option::None, + source_file: "test-async-entry/tests/it-external.rs", + start_line: 13usize, + start_col: 10usize, + end_line: 13usize, + end_col: 32usize, + compile_fail: false, + no_run: false, + should_panic: test::ShouldPanic::No, + test_type: test::TestType::IntegrationTest, + }, + testfn: test::StaticTestFn(|| test::assert_test_result(empty_with_parentheses())), +}; +fn empty_with_parentheses() { + let body = async {}; + #[allow(unused_mut)] + let mut rt = monoio::RuntimeBuilder::::new() + .enable_all() + .build() + .expect("Failed building the Runtime"); + #[allow(clippy::expect_used)] + rt.block_on(body); +} +extern crate test; +#[cfg(test)] +#[rustc_test_marker = "empty_tail_expr"] +pub const empty_tail_expr: test::TestDescAndFn = test::TestDescAndFn { + desc: test::TestDesc { + name: test::StaticTestName("empty_tail_expr"), + ignore: false, + ignore_message: ::core::option::Option::None, + source_file: "test-async-entry/tests/it-external.rs", + start_line: 16usize, + start_col: 10usize, + end_line: 16usize, + end_col: 25usize, + compile_fail: false, + no_run: false, + should_panic: test::ShouldPanic::No, + test_type: test::TestType::IntegrationTest, + }, + testfn: test::StaticTestFn(|| test::assert_test_result(empty_tail_expr())), +}; +fn empty_tail_expr() -> anyhow::Result<()> { + let body = async { Ok(()) }; + #[allow(unused_mut)] + let mut rt = monoio::RuntimeBuilder::::new() + .enable_all() + .build() + .expect("Failed building the Runtime"); + #[allow(clippy::expect_used)] + rt.block_on(body) +} +extern crate test; +#[cfg(test)] +#[rustc_test_marker = "empty_return_expr"] +pub const empty_return_expr: test::TestDescAndFn = test::TestDescAndFn { + desc: test::TestDesc { + name: test::StaticTestName("empty_return_expr"), + ignore: false, + ignore_message: ::core::option::Option::None, + source_file: "test-async-entry/tests/it-external.rs", + start_line: 21usize, + start_col: 10usize, + end_line: 21usize, + end_col: 27usize, + compile_fail: false, + no_run: false, + should_panic: test::ShouldPanic::No, + test_type: test::TestType::IntegrationTest, + }, + testfn: test::StaticTestFn(|| test::assert_test_result(empty_return_expr())), +}; +fn empty_return_expr() -> anyhow::Result<()> { + let body = async { + return Ok(()); + }; + #[allow(unused_mut)] + let mut rt = monoio::RuntimeBuilder::::new() + .enable_all() + .build() + .expect("Failed building the Runtime"); + #[allow(clippy::expect_used)] + return rt.block_on(body); +} +extern crate test; +#[cfg(test)] +#[rustc_test_marker = "empty_trace_span"] +pub const empty_trace_span: test::TestDescAndFn = test::TestDescAndFn { + desc: test::TestDesc { + name: test::StaticTestName("empty_trace_span"), + ignore: false, + ignore_message: ::core::option::Option::None, + source_file: "test-async-entry/tests/it-external.rs", + start_line: 26usize, + start_col: 10usize, + end_line: 26usize, + end_col: 26usize, + compile_fail: false, + no_run: false, + should_panic: test::ShouldPanic::No, + test_type: test::TestType::IntegrationTest, + }, + testfn: test::StaticTestFn(|| test::assert_test_result(empty_trace_span())), +}; +fn empty_trace_span() { + let body = async {}; + use tracing::Instrument; + let body_span = { + use ::tracing::__macro_support::Callsite as _; + static CALLSITE: ::tracing::__macro_support::MacroCallsite = { + use ::tracing::__macro_support::MacroCallsite; + static META: ::tracing::Metadata<'static> = { + ::tracing_core::metadata::Metadata::new( + "empty_trace_span", + "it_external", + ::tracing::Level::INFO, + Some("test-async-entry/tests/it-external.rs"), + Some(25u32), + Some("it_external"), + ::tracing_core::field::FieldSet::new( + &[], + ::tracing_core::callsite::Identifier(&CALLSITE), + ), + ::tracing::metadata::Kind::SPAN, + ) + }; + MacroCallsite::new(&META) + }; + let mut interest = ::tracing::subscriber::Interest::never(); + if ::tracing::Level::INFO <= ::tracing::level_filters::STATIC_MAX_LEVEL + && ::tracing::Level::INFO <= ::tracing::level_filters::LevelFilter::current() + && { + interest = CALLSITE.interest(); + !interest.is_never() + } + && CALLSITE.is_enabled(interest) + { + let meta = CALLSITE.metadata(); + ::tracing::Span::new(meta, &{ meta.fields().value_set(&[]) }) + } else { + let span = CALLSITE.disabled_span(); + {}; + span + } + }; + let body = body.instrument(body_span); + #[allow(unused_mut)] + let mut rt = monoio::RuntimeBuilder::::new() + .enable_all() + .build() + .expect("Failed building the Runtime"); + #[allow(clippy::expect_used)] + rt.block_on(body); +} +extern crate test; +#[cfg(test)] +#[rustc_test_marker = "specify_trace_lib_to_root"] +pub const specify_trace_lib_to_root: test::TestDescAndFn = test::TestDescAndFn { + desc: test::TestDesc { + name: test::StaticTestName("specify_trace_lib_to_root"), + ignore: false, + ignore_message: ::core::option::Option::None, + source_file: "test-async-entry/tests/it-external.rs", + start_line: 29usize, + start_col: 10usize, + end_line: 29usize, + end_col: 35usize, + compile_fail: false, + no_run: false, + should_panic: test::ShouldPanic::No, + test_type: test::TestType::IntegrationTest, + }, + testfn: test::StaticTestFn(|| test::assert_test_result(specify_trace_lib_to_root())), +}; +fn specify_trace_lib_to_root() { + let body = async {}; + use ::tracing::Instrument; + let body_span = { + use ::tracing::__macro_support::Callsite as _; + static CALLSITE: ::tracing::__macro_support::MacroCallsite = { + use ::tracing::__macro_support::MacroCallsite; + static META: ::tracing::Metadata<'static> = { + ::tracing_core::metadata::Metadata::new( + "specify_trace_lib_to_root", + "it_external", + ::tracing::Level::INFO, + Some("test-async-entry/tests/it-external.rs"), + Some(28u32), + Some("it_external"), + ::tracing_core::field::FieldSet::new( + &[], + ::tracing_core::callsite::Identifier(&CALLSITE), + ), + ::tracing::metadata::Kind::SPAN, + ) + }; + MacroCallsite::new(&META) + }; + let mut interest = ::tracing::subscriber::Interest::never(); + if ::tracing::Level::INFO <= ::tracing::level_filters::STATIC_MAX_LEVEL + && ::tracing::Level::INFO <= ::tracing::level_filters::LevelFilter::current() + && { + interest = CALLSITE.interest(); + !interest.is_never() + } + && CALLSITE.is_enabled(interest) + { + let meta = CALLSITE.metadata(); + ::tracing::Span::new(meta, &{ meta.fields().value_set(&[]) }) + } else { + let span = CALLSITE.disabled_span(); + {}; + span + } + }; + let body = body.instrument(body_span); + #[allow(unused_mut)] + let mut rt = monoio::RuntimeBuilder::::new() + .enable_all() + .build() + .expect("Failed building the Runtime"); + #[allow(clippy::expect_used)] + rt.block_on(body); +} +fn g() {} +extern crate test; +#[cfg(test)] +#[rustc_test_marker = "with_init"] +pub const with_init: test::TestDescAndFn = test::TestDescAndFn { + desc: test::TestDesc { + name: test::StaticTestName("with_init"), + ignore: false, + ignore_message: ::core::option::Option::None, + source_file: "test-async-entry/tests/it-external.rs", + start_line: 34usize, + start_col: 10usize, + end_line: 34usize, + end_col: 19usize, + compile_fail: false, + no_run: false, + should_panic: test::ShouldPanic::No, + test_type: test::TestType::IntegrationTest, + }, + testfn: test::StaticTestFn(|| test::assert_test_result(with_init())), +}; +fn with_init() { + let _g = g(); + let body = async {}; + #[allow(unused_mut)] + let mut rt = monoio::RuntimeBuilder::::new() + .enable_all() + .build() + .expect("Failed building the Runtime"); + #[allow(clippy::expect_used)] + rt.block_on(body); +} +extern crate test; +#[cfg(test)] +#[rustc_test_marker = "current_thread"] +pub const current_thread: test::TestDescAndFn = test::TestDescAndFn { + desc: test::TestDesc { + name: test::StaticTestName("current_thread"), + ignore: false, + ignore_message: ::core::option::Option::None, + source_file: "test-async-entry/tests/it-external.rs", + start_line: 37usize, + start_col: 10usize, + end_line: 37usize, + end_col: 24usize, + compile_fail: false, + no_run: false, + should_panic: test::ShouldPanic::No, + test_type: test::TestType::IntegrationTest, + }, + testfn: test::StaticTestFn(|| test::assert_test_result(current_thread())), +}; +fn current_thread() { + let body = async {}; + #[allow(unused_mut)] + let mut rt = monoio::RuntimeBuilder::::new() + .enable_all() + .build() + .expect("Failed building the Runtime"); + #[allow(clippy::expect_used)] + rt.block_on(body); +} +extern crate test; +#[cfg(test)] +#[rustc_test_marker = "multi_thread"] +pub const multi_thread: test::TestDescAndFn = test::TestDescAndFn { + desc: test::TestDesc { + name: test::StaticTestName("multi_thread"), + ignore: false, + ignore_message: ::core::option::Option::None, + source_file: "test-async-entry/tests/it-external.rs", + start_line: 40usize, + start_col: 10usize, + end_line: 40usize, + end_col: 22usize, + compile_fail: false, + no_run: false, + should_panic: test::ShouldPanic::No, + test_type: test::TestType::IntegrationTest, + }, + testfn: test::StaticTestFn(|| test::assert_test_result(multi_thread())), +}; +fn multi_thread() { + let body = async {}; + #[allow(unused_mut)] + let mut rt = monoio::RuntimeBuilder::::new() + .enable_all() + .build() + .expect("Failed building the Runtime"); + #[allow(clippy::expect_used)] + rt.block_on(body); +} +extern crate test; +#[cfg(test)] +#[rustc_test_marker = "multi_thread_0"] +pub const multi_thread_0: test::TestDescAndFn = test::TestDescAndFn { + desc: test::TestDesc { + name: test::StaticTestName("multi_thread_0"), + ignore: false, + ignore_message: ::core::option::Option::None, + source_file: "test-async-entry/tests/it-external.rs", + start_line: 43usize, + start_col: 10usize, + end_line: 43usize, + end_col: 24usize, + compile_fail: false, + no_run: false, + should_panic: test::ShouldPanic::No, + test_type: test::TestType::IntegrationTest, + }, + testfn: test::StaticTestFn(|| test::assert_test_result(multi_thread_0())), +}; +fn multi_thread_0() { + let body = async {}; + #[allow(unused_mut)] + let mut rt = monoio::RuntimeBuilder::::new() + .enable_all() + .build() + .expect("Failed building the Runtime"); + #[allow(clippy::expect_used)] + rt.block_on(body); +} +extern crate test; +#[cfg(test)] +#[rustc_test_marker = "multi_thread_n"] +pub const multi_thread_n: test::TestDescAndFn = test::TestDescAndFn { + desc: test::TestDesc { + name: test::StaticTestName("multi_thread_n"), + ignore: false, + ignore_message: ::core::option::Option::None, + source_file: "test-async-entry/tests/it-external.rs", + start_line: 46usize, + start_col: 10usize, + end_line: 46usize, + end_col: 24usize, + compile_fail: false, + no_run: false, + should_panic: test::ShouldPanic::No, + test_type: test::TestType::IntegrationTest, + }, + testfn: test::StaticTestFn(|| test::assert_test_result(multi_thread_n())), +}; +fn multi_thread_n() { + let body = async {}; + #[allow(unused_mut)] + let mut rt = monoio::RuntimeBuilder::::new() + .enable_all() + .build() + .expect("Failed building the Runtime"); + #[allow(clippy::expect_used)] + rt.block_on(body); +} +extern crate test; +#[cfg(test)] +#[rustc_test_marker = "multi_thread_n_without_flavor"] +pub const multi_thread_n_without_flavor: test::TestDescAndFn = test::TestDescAndFn { + desc: test::TestDesc { + name: test::StaticTestName("multi_thread_n_without_flavor"), + ignore: false, + ignore_message: ::core::option::Option::None, + source_file: "test-async-entry/tests/it-external.rs", + start_line: 49usize, + start_col: 10usize, + end_line: 49usize, + end_col: 39usize, + compile_fail: false, + no_run: false, + should_panic: test::ShouldPanic::No, + test_type: test::TestType::IntegrationTest, + }, + testfn: test::StaticTestFn(|| test::assert_test_result(multi_thread_n_without_flavor())), +}; +fn multi_thread_n_without_flavor() { + let body = async {}; + #[allow(unused_mut)] + let mut rt = monoio::RuntimeBuilder::::new() + .enable_all() + .build() + .expect("Failed building the Runtime"); + #[allow(clippy::expect_used)] + rt.block_on(body); +} +extern crate test; +#[cfg(test)] +#[rustc_test_marker = "start_paused"] +pub const start_paused: test::TestDescAndFn = test::TestDescAndFn { + desc: test::TestDesc { + name: test::StaticTestName("start_paused"), + ignore: false, + ignore_message: ::core::option::Option::None, + source_file: "test-async-entry/tests/it-external.rs", + start_line: 52usize, + start_col: 10usize, + end_line: 52usize, + end_col: 22usize, + compile_fail: false, + no_run: false, + should_panic: test::ShouldPanic::No, + test_type: test::TestType::IntegrationTest, + }, + testfn: test::StaticTestFn(|| test::assert_test_result(start_paused())), +}; +fn start_paused() { + let body = async {}; + #[allow(unused_mut)] + let mut rt = monoio::RuntimeBuilder::::new() + .enable_all() + .build() + .expect("Failed building the Runtime"); + #[allow(clippy::expect_used)] + rt.block_on(body); +} +#[rustc_main] +#[coverage(off)] +pub fn main() -> () { + extern crate test; + test::test_main_static(&[ + ¤t_thread, + &empty, + &empty_return_expr, + &empty_tail_expr, + &empty_trace_span, + &empty_with_parentheses, + &multi_thread, + &multi_thread_0, + &multi_thread_n, + &multi_thread_n_without_flavor, + &specify_trace_lib_to_root, + &start_paused, + &with_init, + ]) +} diff --git a/test-async-entry/want-external b/test-async-entry/want-external-tokio similarity index 76% rename from test-async-entry/want-external rename to test-async-entry/want-external-tokio index d24cfab..f032857 100644 --- a/test-async-entry/want-external +++ b/test-async-entry/want-external-tokio @@ -3,16 +3,24 @@ use std::prelude::rust_2021::*; #[macro_use] extern crate std; +#[allow(unused_imports)] +use lib_crate::monoio; +#[allow(unused_imports)] use lib_crate::tokio; use lib_crate::tracing; extern crate test; #[cfg(test)] -#[rustc_test_marker] +#[rustc_test_marker = "empty"] pub const empty: test::TestDescAndFn = test::TestDescAndFn { desc: test::TestDesc { name: test::StaticTestName("empty"), ignore: false, ignore_message: ::core::option::Option::None, + source_file: "test-async-entry/tests/it-external.rs", + start_line: 10usize, + start_col: 10usize, + end_line: 10usize, + end_col: 15usize, compile_fail: false, no_run: false, should_panic: test::ShouldPanic::No, @@ -22,7 +30,8 @@ pub const empty: test::TestDescAndFn = test::TestDescAndFn { }; fn empty() { let body = async {}; - let rt = tokio::runtime::Builder::new_current_thread() + #[allow(unused_mut)] + let mut rt = tokio::runtime::Builder::new_current_thread() .enable_all() .build() .expect("Failed building the Runtime"); @@ -31,12 +40,17 @@ fn empty() { } extern crate test; #[cfg(test)] -#[rustc_test_marker] +#[rustc_test_marker = "empty_with_parentheses"] pub const empty_with_parentheses: test::TestDescAndFn = test::TestDescAndFn { desc: test::TestDesc { name: test::StaticTestName("empty_with_parentheses"), ignore: false, ignore_message: ::core::option::Option::None, + source_file: "test-async-entry/tests/it-external.rs", + start_line: 13usize, + start_col: 10usize, + end_line: 13usize, + end_col: 32usize, compile_fail: false, no_run: false, should_panic: test::ShouldPanic::No, @@ -46,7 +60,8 @@ pub const empty_with_parentheses: test::TestDescAndFn = test::TestDescAndFn { }; fn empty_with_parentheses() { let body = async {}; - let rt = tokio::runtime::Builder::new_current_thread() + #[allow(unused_mut)] + let mut rt = tokio::runtime::Builder::new_current_thread() .enable_all() .build() .expect("Failed building the Runtime"); @@ -55,12 +70,17 @@ fn empty_with_parentheses() { } extern crate test; #[cfg(test)] -#[rustc_test_marker] +#[rustc_test_marker = "empty_tail_expr"] pub const empty_tail_expr: test::TestDescAndFn = test::TestDescAndFn { desc: test::TestDesc { name: test::StaticTestName("empty_tail_expr"), ignore: false, ignore_message: ::core::option::Option::None, + source_file: "test-async-entry/tests/it-external.rs", + start_line: 16usize, + start_col: 10usize, + end_line: 16usize, + end_col: 25usize, compile_fail: false, no_run: false, should_panic: test::ShouldPanic::No, @@ -70,7 +90,8 @@ pub const empty_tail_expr: test::TestDescAndFn = test::TestDescAndFn { }; fn empty_tail_expr() -> anyhow::Result<()> { let body = async { Ok(()) }; - let rt = tokio::runtime::Builder::new_current_thread() + #[allow(unused_mut)] + let mut rt = tokio::runtime::Builder::new_current_thread() .enable_all() .build() .expect("Failed building the Runtime"); @@ -79,12 +100,17 @@ fn empty_tail_expr() -> anyhow::Result<()> { } extern crate test; #[cfg(test)] -#[rustc_test_marker] +#[rustc_test_marker = "empty_return_expr"] pub const empty_return_expr: test::TestDescAndFn = test::TestDescAndFn { desc: test::TestDesc { name: test::StaticTestName("empty_return_expr"), ignore: false, ignore_message: ::core::option::Option::None, + source_file: "test-async-entry/tests/it-external.rs", + start_line: 21usize, + start_col: 10usize, + end_line: 21usize, + end_col: 27usize, compile_fail: false, no_run: false, should_panic: test::ShouldPanic::No, @@ -96,7 +122,8 @@ fn empty_return_expr() -> anyhow::Result<()> { let body = async { return Ok(()); }; - let rt = tokio::runtime::Builder::new_current_thread() + #[allow(unused_mut)] + let mut rt = tokio::runtime::Builder::new_current_thread() .enable_all() .build() .expect("Failed building the Runtime"); @@ -105,12 +132,17 @@ fn empty_return_expr() -> anyhow::Result<()> { } extern crate test; #[cfg(test)] -#[rustc_test_marker] +#[rustc_test_marker = "empty_trace_span"] pub const empty_trace_span: test::TestDescAndFn = test::TestDescAndFn { desc: test::TestDesc { name: test::StaticTestName("empty_trace_span"), ignore: false, ignore_message: ::core::option::Option::None, + source_file: "test-async-entry/tests/it-external.rs", + start_line: 26usize, + start_col: 10usize, + end_line: 26usize, + end_col: 26usize, compile_fail: false, no_run: false, should_panic: test::ShouldPanic::No, @@ -131,7 +163,7 @@ fn empty_trace_span() { "it_external", ::tracing::Level::INFO, Some("test-async-entry/tests/it-external.rs"), - Some(22u32), + Some(25u32), Some("it_external"), ::tracing_core::field::FieldSet::new( &[], @@ -160,7 +192,8 @@ fn empty_trace_span() { } }; let body = body.instrument(body_span); - let rt = tokio::runtime::Builder::new_current_thread() + #[allow(unused_mut)] + let mut rt = tokio::runtime::Builder::new_current_thread() .enable_all() .build() .expect("Failed building the Runtime"); @@ -169,12 +202,17 @@ fn empty_trace_span() { } extern crate test; #[cfg(test)] -#[rustc_test_marker] +#[rustc_test_marker = "specify_trace_lib_to_root"] pub const specify_trace_lib_to_root: test::TestDescAndFn = test::TestDescAndFn { desc: test::TestDesc { name: test::StaticTestName("specify_trace_lib_to_root"), ignore: false, ignore_message: ::core::option::Option::None, + source_file: "test-async-entry/tests/it-external.rs", + start_line: 29usize, + start_col: 10usize, + end_line: 29usize, + end_col: 35usize, compile_fail: false, no_run: false, should_panic: test::ShouldPanic::No, @@ -195,7 +233,7 @@ fn specify_trace_lib_to_root() { "it_external", ::tracing::Level::INFO, Some("test-async-entry/tests/it-external.rs"), - Some(25u32), + Some(28u32), Some("it_external"), ::tracing_core::field::FieldSet::new( &[], @@ -224,7 +262,8 @@ fn specify_trace_lib_to_root() { } }; let body = body.instrument(body_span); - let rt = tokio::runtime::Builder::new_current_thread() + #[allow(unused_mut)] + let mut rt = tokio::runtime::Builder::new_current_thread() .enable_all() .build() .expect("Failed building the Runtime"); @@ -234,12 +273,17 @@ fn specify_trace_lib_to_root() { fn g() {} extern crate test; #[cfg(test)] -#[rustc_test_marker] +#[rustc_test_marker = "with_init"] pub const with_init: test::TestDescAndFn = test::TestDescAndFn { desc: test::TestDesc { name: test::StaticTestName("with_init"), ignore: false, ignore_message: ::core::option::Option::None, + source_file: "test-async-entry/tests/it-external.rs", + start_line: 34usize, + start_col: 10usize, + end_line: 34usize, + end_col: 19usize, compile_fail: false, no_run: false, should_panic: test::ShouldPanic::No, @@ -250,7 +294,8 @@ pub const with_init: test::TestDescAndFn = test::TestDescAndFn { fn with_init() { let _g = g(); let body = async {}; - let rt = tokio::runtime::Builder::new_current_thread() + #[allow(unused_mut)] + let mut rt = tokio::runtime::Builder::new_current_thread() .enable_all() .build() .expect("Failed building the Runtime"); @@ -259,12 +304,17 @@ fn with_init() { } extern crate test; #[cfg(test)] -#[rustc_test_marker] +#[rustc_test_marker = "current_thread"] pub const current_thread: test::TestDescAndFn = test::TestDescAndFn { desc: test::TestDesc { name: test::StaticTestName("current_thread"), ignore: false, ignore_message: ::core::option::Option::None, + source_file: "test-async-entry/tests/it-external.rs", + start_line: 37usize, + start_col: 10usize, + end_line: 37usize, + end_col: 24usize, compile_fail: false, no_run: false, should_panic: test::ShouldPanic::No, @@ -274,7 +324,8 @@ pub const current_thread: test::TestDescAndFn = test::TestDescAndFn { }; fn current_thread() { let body = async {}; - let rt = tokio::runtime::Builder::new_current_thread() + #[allow(unused_mut)] + let mut rt = tokio::runtime::Builder::new_current_thread() .enable_all() .build() .expect("Failed building the Runtime"); @@ -283,12 +334,17 @@ fn current_thread() { } extern crate test; #[cfg(test)] -#[rustc_test_marker] +#[rustc_test_marker = "multi_thread"] pub const multi_thread: test::TestDescAndFn = test::TestDescAndFn { desc: test::TestDesc { name: test::StaticTestName("multi_thread"), ignore: false, ignore_message: ::core::option::Option::None, + source_file: "test-async-entry/tests/it-external.rs", + start_line: 40usize, + start_col: 10usize, + end_line: 40usize, + end_col: 22usize, compile_fail: false, no_run: false, should_panic: test::ShouldPanic::No, @@ -298,7 +354,8 @@ pub const multi_thread: test::TestDescAndFn = test::TestDescAndFn { }; fn multi_thread() { let body = async {}; - let rt = tokio::runtime::Builder::new_multi_thread() + #[allow(unused_mut)] + let mut rt = tokio::runtime::Builder::new_multi_thread() .enable_all() .build() .expect("Failed building the Runtime"); @@ -307,12 +364,17 @@ fn multi_thread() { } extern crate test; #[cfg(test)] -#[rustc_test_marker] +#[rustc_test_marker = "multi_thread_0"] pub const multi_thread_0: test::TestDescAndFn = test::TestDescAndFn { desc: test::TestDesc { name: test::StaticTestName("multi_thread_0"), ignore: false, ignore_message: ::core::option::Option::None, + source_file: "test-async-entry/tests/it-external.rs", + start_line: 43usize, + start_col: 10usize, + end_line: 43usize, + end_col: 24usize, compile_fail: false, no_run: false, should_panic: test::ShouldPanic::No, @@ -322,7 +384,8 @@ pub const multi_thread_0: test::TestDescAndFn = test::TestDescAndFn { }; fn multi_thread_0() { let body = async {}; - let rt = tokio::runtime::Builder::new_current_thread() + #[allow(unused_mut)] + let mut rt = tokio::runtime::Builder::new_current_thread() .enable_all() .build() .expect("Failed building the Runtime"); @@ -331,12 +394,17 @@ fn multi_thread_0() { } extern crate test; #[cfg(test)] -#[rustc_test_marker] +#[rustc_test_marker = "multi_thread_n"] pub const multi_thread_n: test::TestDescAndFn = test::TestDescAndFn { desc: test::TestDesc { name: test::StaticTestName("multi_thread_n"), ignore: false, ignore_message: ::core::option::Option::None, + source_file: "test-async-entry/tests/it-external.rs", + start_line: 46usize, + start_col: 10usize, + end_line: 46usize, + end_col: 24usize, compile_fail: false, no_run: false, should_panic: test::ShouldPanic::No, @@ -346,7 +414,8 @@ pub const multi_thread_n: test::TestDescAndFn = test::TestDescAndFn { }; fn multi_thread_n() { let body = async {}; - let rt = tokio::runtime::Builder::new_multi_thread() + #[allow(unused_mut)] + let mut rt = tokio::runtime::Builder::new_multi_thread() .worker_threads(10usize) .enable_all() .build() @@ -356,12 +425,17 @@ fn multi_thread_n() { } extern crate test; #[cfg(test)] -#[rustc_test_marker] +#[rustc_test_marker = "multi_thread_n_without_flavor"] pub const multi_thread_n_without_flavor: test::TestDescAndFn = test::TestDescAndFn { desc: test::TestDesc { name: test::StaticTestName("multi_thread_n_without_flavor"), ignore: false, ignore_message: ::core::option::Option::None, + source_file: "test-async-entry/tests/it-external.rs", + start_line: 49usize, + start_col: 10usize, + end_line: 49usize, + end_col: 39usize, compile_fail: false, no_run: false, should_panic: test::ShouldPanic::No, @@ -371,7 +445,8 @@ pub const multi_thread_n_without_flavor: test::TestDescAndFn = test::TestDescAnd }; fn multi_thread_n_without_flavor() { let body = async {}; - let rt = tokio::runtime::Builder::new_multi_thread() + #[allow(unused_mut)] + let mut rt = tokio::runtime::Builder::new_multi_thread() .worker_threads(10usize) .enable_all() .build() @@ -381,12 +456,17 @@ fn multi_thread_n_without_flavor() { } extern crate test; #[cfg(test)] -#[rustc_test_marker] +#[rustc_test_marker = "start_paused"] pub const start_paused: test::TestDescAndFn = test::TestDescAndFn { desc: test::TestDesc { name: test::StaticTestName("start_paused"), ignore: false, ignore_message: ::core::option::Option::None, + source_file: "test-async-entry/tests/it-external.rs", + start_line: 52usize, + start_col: 10usize, + end_line: 52usize, + end_col: 22usize, compile_fail: false, no_run: false, should_panic: test::ShouldPanic::No, @@ -396,7 +476,8 @@ pub const start_paused: test::TestDescAndFn = test::TestDescAndFn { }; fn start_paused() { let body = async {}; - let rt = tokio::runtime::Builder::new_current_thread() + #[allow(unused_mut)] + let mut rt = tokio::runtime::Builder::new_current_thread() .start_paused(true) .enable_all() .build() @@ -405,21 +486,22 @@ fn start_paused() { rt.block_on(body); } #[rustc_main] +#[coverage(off)] pub fn main() -> () { extern crate test; test::test_main_static(&[ + ¤t_thread, &empty, - &empty_with_parentheses, - &empty_tail_expr, &empty_return_expr, + &empty_tail_expr, &empty_trace_span, - &specify_trace_lib_to_root, - &with_init, - ¤t_thread, + &empty_with_parentheses, &multi_thread, &multi_thread_0, &multi_thread_n, &multi_thread_n_without_flavor, + &specify_trace_lib_to_root, &start_paused, + &with_init, ]) } diff --git a/test-async-entry/want-tracing-lib-monoio b/test-async-entry/want-tracing-lib-monoio new file mode 100644 index 0000000..689e4ea --- /dev/null +++ b/test-async-entry/want-tracing-lib-monoio @@ -0,0 +1,87 @@ +#![feature(prelude_import)] +#[prelude_import] +use std::prelude::rust_2021::*; +#[macro_use] +extern crate std; +#[allow(unused_imports)] +use lib_crate::monoio; +#[allow(unused_imports)] +use lib_crate::tokio; +extern crate test; +#[cfg(test)] +#[rustc_test_marker = "specify_trace_lib"] +pub const specify_trace_lib: test::TestDescAndFn = test::TestDescAndFn { + desc: test::TestDesc { + name: test::StaticTestName("specify_trace_lib"), + ignore: false, + ignore_message: ::core::option::Option::None, + source_file: "test-async-entry/tests/it-tracing-lib.rs", + start_line: 9usize, + start_col: 10usize, + end_line: 9usize, + end_col: 27usize, + compile_fail: false, + no_run: false, + should_panic: test::ShouldPanic::No, + test_type: test::TestType::IntegrationTest, + }, + testfn: test::StaticTestFn(|| test::assert_test_result(specify_trace_lib())), +}; +/// Specify where to load tracing and tracing_future. +/// Do not need to import +fn specify_trace_lib() { + let body = async {}; + use lib_crate::tracing::Instrument; + let body_span = { + use ::tracing::__macro_support::Callsite as _; + static CALLSITE: ::tracing::__macro_support::MacroCallsite = { + use ::tracing::__macro_support::MacroCallsite; + static META: ::tracing::Metadata<'static> = { + ::tracing_core::metadata::Metadata::new( + "specify_trace_lib", + "it_tracing_lib", + ::tracing::Level::INFO, + Some("test-async-entry/tests/it-tracing-lib.rs"), + Some(8u32), + Some("it_tracing_lib"), + ::tracing_core::field::FieldSet::new( + &[], + ::tracing_core::callsite::Identifier(&CALLSITE), + ), + ::tracing::metadata::Kind::SPAN, + ) + }; + MacroCallsite::new(&META) + }; + let mut interest = ::tracing::subscriber::Interest::never(); + if ::tracing::Level::INFO <= ::tracing::level_filters::STATIC_MAX_LEVEL + && ::tracing::Level::INFO <= ::tracing::level_filters::LevelFilter::current() + && { + interest = CALLSITE.interest(); + !interest.is_never() + } + && CALLSITE.is_enabled(interest) + { + let meta = CALLSITE.metadata(); + ::tracing::Span::new(meta, &{ meta.fields().value_set(&[]) }) + } else { + let span = CALLSITE.disabled_span(); + {}; + span + } + }; + let body = body.instrument(body_span); + #[allow(unused_mut)] + let mut rt = monoio::RuntimeBuilder::::new() + .enable_all() + .build() + .expect("Failed building the Runtime"); + #[allow(clippy::expect_used)] + rt.block_on(body); +} +#[rustc_main] +#[coverage(off)] +pub fn main() -> () { + extern crate test; + test::test_main_static(&[&specify_trace_lib]) +} diff --git a/test-async-entry/want-tracing-lib b/test-async-entry/want-tracing-lib-tokio similarity index 86% rename from test-async-entry/want-tracing-lib rename to test-async-entry/want-tracing-lib-tokio index d3206c7..4872a03 100644 --- a/test-async-entry/want-tracing-lib +++ b/test-async-entry/want-tracing-lib-tokio @@ -3,15 +3,23 @@ use std::prelude::rust_2021::*; #[macro_use] extern crate std; +#[allow(unused_imports)] +use lib_crate::monoio; +#[allow(unused_imports)] use lib_crate::tokio; extern crate test; #[cfg(test)] -#[rustc_test_marker] +#[rustc_test_marker = "specify_trace_lib"] pub const specify_trace_lib: test::TestDescAndFn = test::TestDescAndFn { desc: test::TestDesc { name: test::StaticTestName("specify_trace_lib"), ignore: false, ignore_message: ::core::option::Option::None, + source_file: "test-async-entry/tests/it-tracing-lib.rs", + start_line: 9usize, + start_col: 10usize, + end_line: 9usize, + end_col: 27usize, compile_fail: false, no_run: false, should_panic: test::ShouldPanic::No, @@ -34,7 +42,7 @@ fn specify_trace_lib() { "it_tracing_lib", ::tracing::Level::INFO, Some("test-async-entry/tests/it-tracing-lib.rs"), - Some(5u32), + Some(8u32), Some("it_tracing_lib"), ::tracing_core::field::FieldSet::new( &[], @@ -63,7 +71,8 @@ fn specify_trace_lib() { } }; let body = body.instrument(body_span); - let rt = tokio::runtime::Builder::new_current_thread() + #[allow(unused_mut)] + let mut rt = tokio::runtime::Builder::new_current_thread() .enable_all() .build() .expect("Failed building the Runtime"); @@ -71,6 +80,7 @@ fn specify_trace_lib() { rt.block_on(body); } #[rustc_main] +#[coverage(off)] pub fn main() -> () { extern crate test; test::test_main_static(&[&specify_trace_lib]) diff --git a/test.sh b/test.sh index aed8ffe..52b3b41 100755 --- a/test.sh +++ b/test.sh @@ -2,18 +2,36 @@ set -o errexit -echo "=== Build async-entry" -cargo expand -p async-entry --test it --color=never --tests > got -diff async-entry/want got +test_rt() { + local feat="$1" + local rt="$2" + local channel="$3" -echo "=== Build test-async-entry: it-external" -cargo expand -p test-async-entry --test it-external --color=never --tests > got -diff test-async-entry/want-external got + echo "=== Test runtime: $rt" -echo "=== Build test-async-entry: it-tracing-lib" -cargo expand -p test-async-entry --test it-tracing-lib --color=never --tests > got -diff test-async-entry/want-tracing-lib got + echo "=== Build async-entry" + cargo $channel expand --features "$feat" -p async-entry --test it --color=never --tests > got + diff async-entry/want-$rt got + + echo "=== Build test-async-entry: it-external" + cargo $channel expand --features "$feat" -p test-async-entry --test it-external --color=never --tests > got + diff test-async-entry/want-external-$rt got + + echo "=== Build test-async-entry: it-tracing-lib" + cargo $channel expand --features "$feat" -p test-async-entry --test it-tracing-lib --color=never --tests > got + diff test-async-entry/want-tracing-lib-$rt got + + echo "=== Compile" + cargo $channel test --features "$feat" -p async-entry + cargo $channel test --features "$feat" -p test-async-entry + +} + +# by default it uses tokio +test_rt "" "tokio" "+nightly" + +test_rt "tokio" "tokio" "+nightly" + +# monoio requires nightly rust +test_rt "monoio" "monoio" "+nightly" -echo "=== Compile" -cargo test -p async-entry -cargo test -p test-async-entry