-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
After smol-rs/async-task#37 I meant to add this to the executor. This commit makes it so all panics are surfaced in the tasks that the user calls. Hopefully this improves ergonomics. Signed-off-by: John Nunley <dev@notgull.net> Signed-off-by: Alain Zscheile <fogti+devel@ytrizja.de>
- Loading branch information
Showing
2 changed files
with
25 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
use async_executor::Executor; | ||
use futures_lite::{future, prelude::*}; | ||
|
||
#[test] | ||
fn test_panic_propagation() { | ||
let ex = Executor::new(); | ||
let task = ex.spawn(async { panic!("should be caught by the task") }); | ||
|
||
// Running the executor should not panic. | ||
assert!(ex.try_tick()); | ||
|
||
// Polling the task should. | ||
assert!(future::block_on(task.catch_unwind()).is_err()); | ||
} |