-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Add new tests for JoinSet, JoinMap, TaskTracer and LocalRuntime #7609
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
tokio/tests/task_join_set.rs
Outdated
} | ||
|
||
// Dropping a `JoinSet` created inside a **LocalRuntime** | ||
// must abort every still-running `!Send` task that was |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
must abort every still-running
!Send
task that was
Does Send
or not matter?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, it doesn't. I will modify the comment removing " !Send
"
Hi @FrancescoV1985 , any update on this PR? |
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you try to reduce the duplicated code from test code? Also, Are the tests for TaskTracker
in the scope of this PR?
set.spawn_local_on(async move { *rc }, &local); | ||
} | ||
|
||
assert!(set.try_join_next().is_none()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, since we are using the single thread runtime and there is no yield point here, the set.try_join_next()
is always None
, we should rewrite this test.
// Tasks are queued with `spawn_local_on` **before** the `LocalSet` is | ||
// running, then executed once the `LocalSet` is started. | ||
#[tokio::test(flavor = "current_thread")] | ||
async fn spawn_local_on_on_started_localset() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the difference between this test and spawn_local_on_local_runtime
?
for _ in 0..N { | ||
let (tx, rx) = oneshot::channel::<()>(); | ||
receivers.push(rx); | ||
set.spawn_local(async move { | ||
pending::<()>().await; | ||
drop(tx); | ||
}); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are many duplicated code like this, could you try to improve this de-dup it?
for rx in receivers { | ||
assert!( | ||
rx.await.is_err(), | ||
"the task should have been aborted and the sender dropped" | ||
); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you try to de-dup this kind of code?
I committed the tests for TaskTracker. I still need to add comments and double check. I will pm you for some clarifications.. |
Fixes: #7562
Motivation
Improve the test coverage of task containers on LocalRuntime
Solution
Added new tests for JoinSet, JoinMap, TaskTracer