Skip to main content

TestExecutor

Struct TestExecutor 

Source
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

Source

pub fn new(wall_ms: i64) -> Self

A fresh pool with its clock at wall_ms; replayed histories use WALL_EPOCH_MS.

Source

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.

Source

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.

Source

pub fn spawn(&self, task: impl Future<Output = ()> + 'static)

Spawn driver-owned work onto the pool.

Source

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.

Source

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.

Source

pub fn advance_micros(&mut self, micros: i64)

Advance by fractional microseconds without delivering timers (the local-clock profile’s environment ticks).

Trait Implementations§

Source§

impl Debug for TestExecutor

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.