diff --git a/crates/executor/src/task/tests.rs b/crates/executor/src/task/tests.rs index dfba2af..a9c1699 100644 --- a/crates/executor/src/task/tests.rs +++ b/crates/executor/src/task/tests.rs @@ -3,7 +3,7 @@ use super::{Completion, Task, TaskError, TaskState, UNASSIGNED_WORKER}; use crate::owner::Owner; -use std::future::{Future, ready}; +use std::future::Future; use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering}; use std::sync::{Arc, Weak}; use std::task::{Context, Poll, Waker}; @@ -64,11 +64,11 @@ fn completion_marks_finished_after_its_scheduler_is_gone() { #[test] fn dropping_a_task_handle_detaches_without_cancelling_the_task() { let scheduler = crate::scheduler::Scheduler::with_workers(1).unwrap(); - let handle = scheduler.spawn(ready(42)).unwrap(); + let handle = scheduler.spawn(std::future::pending::<()>()).unwrap(); let task = handle.task(); drop(handle); - assert!(!task.is_finished()); + assert!(task.cancel()); scheduler.run(); diff --git a/crates/executor/tests/io.rs b/crates/executor/tests/io.rs index fe3d958..2c0575f 100644 --- a/crates/executor/tests/io.rs +++ b/crates/executor/tests/io.rs @@ -262,13 +262,15 @@ mod native { let task = scheduler .spawn(async move { let mut read = pin!(handle.io_read(&socket, vec![0; 1024])); - poll_fn(|context| { + let mut started = Some(started); + poll_fn(|context| -> Poll<()> { assert!(read.as_mut().poll(context).is_pending()); - started.send(()).unwrap(); - Poll::Ready(()) + if let Some(started) = started.take() { + started.send(()).unwrap(); + } + Poll::Pending }) - .await; - read.await + .await }) .unwrap(); support::receive(&waiting);