Skip to main content

Module testing

Module testing 

Source
Expand description

Running futures in a unit test, with no simulator.

Most of a verification framework is not about time. The ConfigDb, the factory, port binding, the analysis broadcast and the whole sequencer handshake are built from Events and Queues, neither of which touches the simulator — so they can be tested in milliseconds under cargo test instead of minutes under Icarus.

The line is sharp and this module is where it is enforced: block_on drives a future on a bare executor, and if the future is still pending when the run queue empties, it says so and names the likely cause. A test that awaits Timer or a clock edge needs a simulator, and will fail here rather than hanging.

#[test]
fn a_queue_round_trips() {
    block_on(async {
        let q: Queue<u8> = Queue::unbounded();
        q.put(7).await;
        assert_eq!(q.get().await, 7);
    });
}

Functions§

assert_pending
Like block_on, but expects the future not to finish.
block_on
Run fut to completion on a fresh executor, with no simulator.
fresh_executor
Install a fresh executor without running anything — for tests that drive the executor by hand, or that only need spawn to be legal.