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

TestError::display is hard to use #119

Closed
xxchan opened this issue Dec 8, 2022 · 3 comments
Closed

TestError::display is hard to use #119

xxchan opened this issue Dec 8, 2022 · 3 comments

Comments

@xxchan
Copy link
Member

xxchan commented Dec 8, 2022

Because users generally will return Result in tests, and there's no chance to call display(true) to get colorful error message. If it's printed, it will be duplicate with the Err.

Maybe we can refer to https://docs.rs/pretty_assertions/latest/pretty_assertions/ about how can we opt-in colorful message in library usage.

@xxchan
Copy link
Member Author

xxchan commented Jan 4, 2024

pretty-assertions also suffer from this rust-pretty-assertions/rust-pretty-assertions#31

@xxchan
Copy link
Member Author

xxchan commented Jan 4, 2024

can we detect ANSI-colour support automatically?

In general, no.

@xxchan
Copy link
Member Author

xxchan commented Jan 4, 2024

runner
.run_async(record)
.await
.map_err(|e| anyhow!("{}", e.display(console::colors_enabled())))
.context(format!(
"failed to run `{}`",
style(filename.to_string_lossy()).bold()
))?;
}

I think this is actually acceptable 🤣

@xxchan xxchan closed this as not planned Won't fix, can't repro, duplicate, stale Jan 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant