Expand description
Task related testing utilities.
This module provides utilities for creating test
Contexts,
Wakers and
Spawn implementations.
Test contexts:
noop_contextcreates a context that ignores calls tocx.waker().wake_by_ref().panic_contextcreates a context that panics whencx.waker().wake_by_ref()is called.
Test wakers:
noop_wakercreates a waker that ignores calls towake.panic_wakercreates a waker that panics whenwakeis called.new_count_wakercreates a waker that increments a counter wheneverwakeis called.
Test spawners:
NoopSpawnerignores calls tospawnPanicSpawnerpanics ifspawnis called.RecordSpawnerrecords the spawned futures.
For convenience there additionally exist various functions that directly
return waker/spawner references: noop_waker_ref, panic_waker_ref,
noop_spawner_mut and panic_spawner_mut.
Structs§
- Awoken
Count - Number of times the waker was awoken.
- Noop
Spawner - An implementation of
Spawnthat discards spawned futures when used. - Panic
Spawner - An implementation of
Spawnthat panics when used. - Record
Spawner - An implementation of
Spawnthat records anyFutures spawned on it.
Functions§
- new_
count_ waker - Create a new
Wakerthat counts the number of times it’s awoken. - noop_
context - Create a new
Contextwhere the waker will ignore any uses. - noop_
spawner_ mut - Get a reference to a singleton instance of
NoopSpawner. - noop_
waker - Create a new
Wakerwhich does nothing whenwake()is called on it. - noop_
waker_ ref - Get a static reference to a
Wakerwhich does nothing whenwake()is called on it. - panic_
context - Create a new
Contextwhere the waker will panic if used. - panic_
spawner_ mut - Get a reference to a singleton instance of
PanicSpawner. - panic_
waker - Create a new
Wakerwhich will panic whenwake()is called on it. TheWakercan be converted into aWakerwhich will behave the same way. - panic_
waker_ ref - Get a global reference to a
Wakerreferencing a singleton instance of aWakerwhich panics when woken.