Skip to content
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

Allow setting unhandled_panic behavior as option on tokio::test #6527

Open
xortive opened this issue May 2, 2024 · 1 comment
Open

Allow setting unhandled_panic behavior as option on tokio::test #6527

xortive opened this issue May 2, 2024 · 1 comment
Labels
A-tokio Area: The main tokio crate A-tokio-macros Area: The tokio-macros crate C-feature-request Category: A feature request.

Comments

@xortive
Copy link

xortive commented May 2, 2024

Is your feature request related to a problem? Please describe.
I have several unit tests that run some handler code that is under test in a tokio::spawned task, and sends/receives bytes to/from that handler code from the main task. My AsyncRead + AsyncWrite mock will panic if it sees unexpected bytes, and if this happens in the background task the test will hang. I'd prefer the test to shut down in this scenario, and so I'm using the unhandled_panic option introduced by #4516.

Describe the solution you'd like
#[tokio::test(unhandled_panic = ShutdownRuntime)

Describe alternatives you've considered
Currently I manually set up a tokio runtime for my tests that require this behavior.

@xortive xortive added A-tokio Area: The main tokio crate C-feature-request Category: A feature request. labels May 2, 2024
@mox692 mox692 added the A-tokio-macros Area: The tokio-macros crate label May 3, 2024
@carllerche
Copy link
Member

I’m fine adding this feature.

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-macros Area: The tokio-macros crate C-feature-request Category: A feature request.
Projects
None yet
Development

No branches or pull requests

3 participants