Skip to content

Conversation

FrancescoV1985
Copy link

Fixes: #7562

Motivation

Improve the test coverage of task containers on LocalRuntime

Solution

Added new tests for JoinSet, JoinMap, TaskTracer

@ADD-SP ADD-SP added A-tokio-util Area: The tokio-util crate C-maintenance Category: PRs that clean code up or issues documenting cleanup. A-tokio Area: The main tokio crate M-task Module: tokio/task labels Sep 15, 2025
Comment on lines +122 to +133
rt.block_on(local.run_until(async {
let thread_result = std::thread::spawn(|| {
let panic_result = panic::catch_unwind(|| {
let _jh = tokio::task::spawn_local(async {
println!("you will never see this line");
});
});
assert!(panic_result.is_err(), "Expected panic, but none occurred");
})
.join();
assert!(thread_result.is_ok(), "Thread itself panicked unexpectedly");
}));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are many nested closure, and it took me longer time to understand, could you add a comment to describe what this test does?

Comment on lines +383 to +388
// Drive a `LocalSet` on top of a `LocalRuntime` and verify that tasks
// queued with `JoinSet::spawn_local_on` run to completion only after the
// `LocalSet` starts.
#[cfg(tokio_unstable)]
#[test]
fn spawn_local_on_local_runtime() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

verify that tasks queued with JoinSet::spawn_local_on run to completion only after the LocalSet starts.

Why do we need to verify this behavior?

}

// Dropping a `JoinSet` created inside a **LocalRuntime**
// must abort every still-running `!Send` task that was
Copy link
Member

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?

@ADD-SP ADD-SP added the S-waiting-on-author Status: awaiting some action (such as code changes) from the PR or issue author. label Sep 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-tokio Area: The main tokio crate A-tokio-util Area: The tokio-util crate C-maintenance Category: PRs that clean code up or issues documenting cleanup. M-task Module: tokio/task S-waiting-on-author Status: awaiting some action (such as code changes) from the PR or issue author.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve the test coverage of task containers on LocalRuntime
2 participants