pub struct TestExecutor {
pub clock: Arc<VirtualClock>,
pub runtime: Arc<StepRuntime>,
/* private fields */
}Expand description
The controlled executor of one test: a single-threaded pool plus the clock and runtime handle every cache instance under test shares.
Fields§
§clock: Arc<VirtualClock>The virtual clock to share with every instance under test.
runtime: Arc<StepRuntime>The runtime handle to pass to every instance under test.
Implementations§
Source§impl TestExecutor
impl TestExecutor
Sourcepub fn new(wall_ms: i64) -> Self
pub fn new(wall_ms: i64) -> Self
A fresh pool with its clock at wall_ms; replayed histories use
WALL_EPOCH_MS.
Sourcepub fn poll_count(&self) -> u64
pub fn poll_count(&self) -> u64
Actual task polls performed by this executor. A zero-time verification drain must leave this count unchanged when every task is already blocked.
Sourcepub fn block_on<R: 'static>(
&mut self,
future: impl Future<Output = R> + 'static,
) -> R
pub fn block_on<R: 'static>( &mut self, future: impl Future<Output = R> + 'static, ) -> R
Run a future to completion on the pool, draining detached work as it is spawned. Panics if the future stays blocked once nothing is runnable: it would be waiting on a gate only the test can release.
Sourcepub fn spawn(&self, task: impl Future<Output = ()> + 'static)
pub fn spawn(&self, task: impl Future<Output = ()> + 'static)
Spawn driver-owned work onto the pool.
Sourcepub fn drain(&mut self)
pub fn drain(&mut self)
Run until every task is blocked on a gate, an undelivered timer or a scope gate and nothing is runnable, including deferred work that becomes runnable once everything else has stalled.
Sourcepub fn advance(&mut self, ms: i64, deliver: bool)
pub fn advance(&mut self, ms: i64, deliver: bool)
Advance elapsed and wall time by ms. With deliver, scheduler time
moves too and every timer due on the way fires in order, draining after
each; without it the clocks jump silently.
Sourcepub fn advance_micros(&mut self, micros: i64)
pub fn advance_micros(&mut self, micros: i64)
Advance by fractional microseconds without delivering timers (the local-clock profile’s environment ticks).