Skip to content

Commit

Permalink
test: add timeouts to async tests (#149)
Browse files Browse the repository at this point in the history
  • Loading branch information
mlegner authored May 21, 2024
1 parent 72e8f0a commit a9f8f70
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 a9f8f70

Please sign in to comment.