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

panic in tests #78

Closed
akshayknarayan opened this issue Dec 14, 2020 · 2 comments
Closed

panic in tests #78

akshayknarayan opened this issue Dec 14, 2020 · 2 comments
Labels
documentation Improvements or additions to documentation good first issue Good for newcomers help wanted Extra attention is needed

Comments

@akshayknarayan
Copy link

➜ cargo tree | grep eyre
├── color-eyre v0.5.10
│   ├── eyre v0.6.3

I have the following at the top of multiple tests:

color_eyre::install().unwrap_or_else(|_| ());

This causes a panic here: https://github.com/yaahc/color-eyre/blob/master/src/config.rs#L736 because all tests after the first test trigger the panic. Looks like this behavior was introduced in #69.

Is there either a better recommended way to use color-eyre in tests, or could the .expect be changed to fail gracefully?

@yaahc
Copy link
Collaborator

yaahc commented Dec 14, 2020

For right now there's not any particularly better way to handle this in tests built into color-eyre. We have this same problem in our crate at work and I fixed it by adding a std::sync::Once to govern the call to color_eyre::install().

https://github.com/ZcashFoundation/zebra/blob/main/zebra-test/src/lib.rs#L25

As for the panic in from that expect. I already have another plan for how I want to fix that. Basically, I'm going to change color-spantrace so that its theme can be passed in while printing the specific spantrace, rather than requiring it be set via a global. Then the color-eyre handler will have a theme stored locally so when it goes to print it it can just convert its theme and pass it in.

@yaahc yaahc added documentation Improvements or additions to documentation good first issue Good for newcomers help wanted Extra attention is needed labels Feb 4, 2022
@akshayknarayan
Copy link
Author

closing after reading conversation in #114.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants