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

No colored diff with cargo-nextest #10

Open
mlafeldt opened this issue Dec 12, 2023 · 2 comments
Open

No colored diff with cargo-nextest #10

mlafeldt opened this issue Dec 12, 2023 · 2 comments

Comments

@mlafeldt
Copy link

Hey, while giving this library a try, I noticed that it wouldn't output colored diffs when using cargo-next as a test runner (which otherwise works fine with pretty_assertions).

cargo nextest run with similar-asserts:

image

cargo nextest run with pretty_assertions:

image

cargo test works fine too (unsurprisingly):

image

Since cargo-nextest is a popular test runner, is there anything we can do to get colored output with it too?

@mlafeldt
Copy link
Author

OTOH, it works with cargo nextest run --no-capture, which has the downside of running tests serially though.

@sunshowers
Copy link

sunshowers commented Dec 13, 2023

Hi, main author of nextest here. The problem is that the output is captured, and since similar-asserts (correctly) thinks this isn't a tty so doesn't output color.

The usual way to handle this is with CLICOLOR_FORCE. Nextest could set that env var, but my concern with it being set that is that it would break tests which execute subprocesses of their own and depend on the output not containing colors (in fact, the nextest repo itself has some tests which work that way.)

Nextest could in principle set its own NEXTEST_COLOR=1 and =0 variable to indicate whether test utilities like similar-asserts should produce colored output. Would that work? @mitsuhiko's opinion would be really valuable here.

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

2 participants