Skip to content

Commit

Permalink
Test report macro with tokio and async-std
Browse files Browse the repository at this point in the history
  • Loading branch information
shepmaster committed Mar 11, 2024
1 parent 752e2f7 commit c74192b
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 0 deletions.
2 changes: 2 additions & 0 deletions compatibility-tests/futures/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ edition = "2018"

[dependencies]
snafu = { path = "../..", features = ["futures"] }
async-std = { version = "1.12.0", features = ["attributes"] }
futures = "0.3.0"
tokio = { version = "1.0", features = ["macros", "rt"] }
1 change: 1 addition & 0 deletions compatibility-tests/futures/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#![cfg(test)]

mod location;
mod report;

mod api {
use futures::{stream, StreamExt, TryStream};
Expand Down
58 changes: 58 additions & 0 deletions compatibility-tests/futures/src/report.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
use snafu::{prelude::*, Report};

#[derive(Debug, Snafu)]
struct Error;

#[test]
fn tokio_main_attribute_first() {
#[tokio::main(flavor = "current_thread")]
#[snafu::report]
async fn mainlike() -> Result<(), Error> {
Snafu.fail()
}

let _: Report<_> = mainlike();
}

#[test]
fn tokio_main_attribute_last() {
#[snafu::report]
#[tokio::main(flavor = "current_thread")]
async fn mainlike() -> Result<(), Error> {
Snafu.fail()
}

let _: Report<_> = mainlike();
}

#[tokio::test]
#[snafu::report]
async fn tokio_test_attribute_first() -> Result<(), Error> {
Ok(())
}

#[snafu::report]
#[tokio::test]
async fn tokio_test_attribute_last() -> Result<(), Error> {
Ok(())
}

#[test]
fn async_std_main_attribute_last() {
#[derive(Debug, Snafu)]
struct Error;

#[snafu::report]
#[async_std::main]
async fn main() -> Result<(), Error> {
Snafu.fail()
}

let _: Report<_> = main();
}

#[snafu::report]
#[async_std::test]
async fn async_std_test_attribute_last() -> Result<(), Error> {
Ok(())
}

0 comments on commit c74192b

Please sign in to comment.