1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
pub use ;
pub use SourceType;
/// Returns the version of the framework.
/// A macro that waits for a condition to be met, polling at a regular interval.
///
/// This macro is useful for testing asynchronous operations where you need to wait for a state change.
/// It will repeatedly execute the provided `$condition` closure until it returns `Some(value)` or the `$timeout` is reached.
///
/// # Arguments
///
/// * `$condition`: A closure that returns `Option<T>`. When it returns `Some(T)`, the macro returns that value.
/// * `$timeout`: A `std::time::Duration` specifying the maximum time to wait.
/// * `$poll_interval`: A `std::time::Duration` specifying how often to poll the condition.
/// * `$msg`: A message to include in the panic if the macro times out.
///
/// # Panics
///
/// Panics if the `$timeout` is reached before the `$condition` returns `Some(T)`.
/// The panic message includes the total elapsed time, the number of checks performed, the poll interval, and the provided `$msg`.
///
/// # Example
///
/// ```rust
/// use rust_test_framework::wait_for;
/// use std::time::Duration;
///
/// let result = wait_for!(
/// || Some(42),
/// Duration::from_secs(1),
/// Duration::from_millis(10),
/// "should not time out"
/// );
/// assert_eq!(result, 42);
/// ```