9 releases

0.3.3 Feb 19, 2024
0.3.2 Feb 19, 2024
0.3.1 Jun 1, 2022
0.2.2 Jun 1, 2022
0.1.1 Mar 30, 2022

#18 in #tracing-spans

Download history 1309/week @ 2025-10-13 1715/week @ 2025-10-20 1867/week @ 2025-10-27 1002/week @ 2025-11-03 665/week @ 2025-11-10 1581/week @ 2025-11-17 822/week @ 2025-11-24 742/week @ 2025-12-01 654/week @ 2025-12-08 724/week @ 2025-12-15 761/week @ 2025-12-22 193/week @ 2025-12-29 258/week @ 2026-01-05 117/week @ 2026-01-12 230/week @ 2026-01-19 247/week @ 2026-01-26

923 downloads per month
Used in openraft

MIT license

26KB
463 lines

async-entry

Entry macro for tokio based async test.

It does the same as #[tokio::test], with two additional feature:

  • Wrap a testing fn with a span with tracing_span="<log_level>".

  • Add an initializing statement with init="<expr>". The value returned from the initializing expr will be held until test quit. Thus, it can be used to initialize logging or else.

#[async_entry::test(init="g()", tracing_span="info")]
async fn foo() {
    assert!(true);
}
// Will build a test fn:
// #[test]
// fn foo() {
//     let _g = g();
//     let body = async {
//         assert!(true);
//     };
//     use tracing::Instrument;
//     let body = body.instrument(tracing::info_span("foo");
//     let rt = tokio::runtime::Builder::new_current_thread()
//         .enable_all()
//         .build()
//         .expect("Failed building the Runtime");
//     #[allow(clippy::expect_used)]
//     rt.block_on(body);
// }

Development

Test

Run test.sh to check the expanded macro and compile them.

Dependencies

~1.5MB
~39K SLoC