macro_rules! assert_ok {
( $future:expr ) => {
match timeout(Duration::from_secs(3), $future).await {
Ok(timeout_result) => match timeout_result {
Ok(result) => result,
Err(error) => {
panic!(
"Operation '{}' should be successful but it failed with: {}",
stringify!($future),
error
);
}
},
Err(_) => {
panic!(
"Operation '{}' should be successful but it timeout out",
stringify!($future),
);
}
}
};
}
pub(crate) use assert_ok;
macro_rules! assert_timeout {
( $future:expr ) => {
match timeout(Duration::from_millis(500), $future).await {
Ok(timeout_result) => panic!(
"Operation '{}' should block but returned with: {:?}",
stringify!($future),
timeout_result
),
Err(_) => {
}
}
};
}
pub(crate) use assert_timeout;
macro_rules! assert_input_end {
( $put:expr ) => {
assert_ok!($put.read_stdout_timestamp());
assert_ok!($put.read_stdout(": ⏱ End\n"));
};
}
pub(crate) use assert_input_end;
macro_rules! assert_command_output_end {
( $put:expr ) => {
assert_ok!($put.read_stdout_timestamp());
assert_ok!($put.read_stdout(" ------: ⏱ End\n"));
};
}
pub(crate) use assert_command_output_end;
macro_rules! assert_near {
( $expected:expr, $actual:expr, $delta:expr ) => {
assert!($expected + $delta >= $actual);
assert!($expected <= $actual + $delta);
};
}
pub(crate) use assert_near;