coverage: Use Waker::noop
in async tests
This commit is contained in:
parent
604f185fae
commit
5764ccc5e8
9 changed files with 134 additions and 353 deletions
|
@ -1,5 +1,6 @@
|
|||
// compile-flags: --edition=2018
|
||||
#![feature(coverage_attribute)]
|
||||
#![feature(noop_waker)]
|
||||
// edition: 2018
|
||||
|
||||
macro_rules! bail {
|
||||
($msg:literal $(,)?) => {
|
||||
|
@ -45,27 +46,14 @@ fn main() {
|
|||
}
|
||||
|
||||
mod executor {
|
||||
use core::{
|
||||
future::Future,
|
||||
pin::Pin,
|
||||
task::{Context, Poll, RawWaker, RawWakerVTable, Waker},
|
||||
};
|
||||
use core::future::Future;
|
||||
use core::pin::pin;
|
||||
use core::task::{Context, Poll, Waker};
|
||||
|
||||
#[coverage(off)]
|
||||
pub fn block_on<F: Future>(mut future: F) -> F::Output {
|
||||
let mut future = unsafe { Pin::new_unchecked(&mut future) };
|
||||
use std::hint::unreachable_unchecked;
|
||||
static VTABLE: RawWakerVTable = RawWakerVTable::new(
|
||||
#[coverage(off)]
|
||||
|_| unsafe { unreachable_unchecked() }, // clone
|
||||
#[coverage(off)]
|
||||
|_| unsafe { unreachable_unchecked() }, // wake
|
||||
#[coverage(off)]
|
||||
|_| unsafe { unreachable_unchecked() }, // wake_by_ref
|
||||
#[coverage(off)]
|
||||
|_| (),
|
||||
);
|
||||
let waker = unsafe { Waker::from_raw(RawWaker::new(core::ptr::null(), &VTABLE)) };
|
||||
let mut future = pin!(future);
|
||||
let waker = Waker::noop();
|
||||
let mut context = Context::from_waker(&waker);
|
||||
|
||||
loop {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue