Skip to content

Commit

Permalink
test: add timeouts to async tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mlegner committed May 17, 2024
1 parent 6334f25 commit c05ae55
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions crates/scion/src/socket/udp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -427,12 +427,15 @@ mod tests {
}

macro_rules! async_test_case {
($name:ident: $func:ident($($arg:expr),*)) => {
($name:ident($timeout:expr): $func:ident($($arg:expr),*)) => {
#[tokio::test]
async fn $name() -> TestResult {
$func($($arg,)*).await
tokio::time::timeout(std::time::Duration::from_secs($timeout),$func($($arg,)*)).await.unwrap()
}
};
($name:ident: $($tail:tt)*) => {
async_test_case!($name(1): $($tail)*);
};
}

const MESSAGE: &[u8] = b"Hello World! Hello World! Hello World!";
Expand Down

0 comments on commit c05ae55

Please sign in to comment.