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

Use anyhow::Error in end-to-end tests #1878

Merged
merged 3 commits into from
Apr 6, 2024

Conversation

jvff
Copy link
Contributor

@jvff jvff commented Apr 6, 2024

Motivation

Many of the async tests panic when an error occurs instead of propagating the error using the try operator (?). The reasoning for this was that panics preserve the backtrace. However, if anyhow::Error is used, it automatically captures and displays a backtrace as well.

If the try operator (?) is used instead of panics, the code becomes slightly less noisy.

Proposal

Change the end-to-end tests to return anyhow::Result<()> and replace Result::unwrap calls with the try operator.

Test Plan

Two tests were temporarily changed to fail, to test if CI shows the backtrace even if the try operator is used.

Release Plan

Only affects tests, so nothing needed.

Links

jvff added 3 commits April 6, 2024 13:47
Reduce the visual noise a bit.
Prepare to use the try operator `?` inside the test functions.
@jvff jvff requested review from Twey, ma2bd and afck April 6, 2024 13:58
@jvff jvff self-assigned this Apr 6, 2024
@jvff jvff force-pushed the use-errors-in-end-to-end-tests branch from fdf0cc7 to a80e655 Compare April 6, 2024 14:38
@jvff jvff merged commit 1e0339f into linera-io:main Apr 6, 2024
3 checks passed
@jvff jvff deleted the use-errors-in-end-to-end-tests branch April 6, 2024 18:25
Copy link
Contributor

@afck afck left a comment

Choose a reason for hiding this comment

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

This is not specific to the end-to-end tests, is it? We could do the same for other tests at some point?

linera-service/tests/end_to_end_tests.rs Show resolved Hide resolved
linera-service/tests/end_to_end_tests.rs Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants