-
-
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
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"); | ||
})); |
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 nested closure, and it took me longer time to understand, could you add a comment to describe what this test does?
// 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() { |
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.
verify that tasks queued with
JoinSet::spawn_local_on
run to completion only after theLocalSet
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 |
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?
Fixes: #7562
Motivation
Improve the test coverage of task containers on LocalRuntime
Solution
Added new tests for JoinSet, JoinMap, TaskTracer