You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Cargo doesn't seem to output colors to TTY in test report with --color=always
Steps
Running:
CARGO_TERM_COLOR=always cargo test --color=always -p prql-compiler --lib
...yields colors in the terminal...
but when piped to a file, only the header uses colors, not the ok:
�[0m�[0m�[1m�[32m Finished�[0m test [unoptimized + debuginfo] target(s) in 0.20s
�[0m�[0m�[1m�[32m Running�[0m unittests src/lib.rs (target/debug/deps/prql_compiler-04315f547d0d4fc4)
running 169 tests
test ast::pl::ident::test_starts_with ... ok
test parser::test::test_case ... ok
test parser::test::test_coalesce ... ok
test parser::test::test_assign ... ok
Note the escape code in the first two lines, but not around ok.
I found this by trying to get https://github.com/Canop/bacon to work with Insta. Weirdly Insta does give color codes around ok when piped to a TTY (depending on how exactly --color=always is specified):
cargo insta test -p prql-compiler --lib --color=always -- --color=always
�[0m�[0m�[1m�[32m Finished�[0m test [unoptimized + debuginfo] target(s) in 0.22s
�[0m�[0m�[1m�[32m Running�[0m unittests src/lib.rs (target/debug/deps/prql_compiler-04315f547d0d4fc4)
running 169 tests
test ast::pl::ident::test_starts_with ... �[32mok�(B�[m
test parser::test::test_assign ... �[32mok�(B�[m
test parser::test::test_array ... �[32mok�(B�[m
test parser::test::test_backticks ... �[32mok�(B�[m
I think the difference in color output confuses Bacon, and so it can't parse the errors when tests are run through insta. I haven't dug in more, but there does seem to be an issue with Cargo.
Version
cargo version --verbose
cargo 1.68.2 (6feb7c9cf 2023-03-26)
release: 1.68.2
commit-hash: 6feb7c9cfc0c5604732dba75e4c3b2dbea38e8d8
commit-date: 2023-03-26
host: aarch64-apple-darwin
libgit2: 1.5.0 (sys:0.16.0 vendored)
libcurl: 7.87.0 (sys:0.4.59+curl-7.86.0 system ssl:(SecureTransport) LibreSSL/3.3.6)
os: Mac OS 13.3.1 [64-bit]
The text was updated successfully, but these errors were encountered:
Thanks for the report! The issue is that the tests are handled by a separate process with its own CLI and environment variables. To force color for the tests, too, you need to pass the color option to the test harness as in:
Problem
Cargo doesn't seem to output colors to TTY in test report with
--color=always
Steps
Running:
...yields colors in the terminal...
but when piped to a file, only the header uses colors, not the
ok
:Note the escape code in the first two lines, but not around
ok
.Possible Solution(s)
rust-cli/team#15 might be relevant
And #11211 is tangential
Notes
I found this by trying to get https://github.com/Canop/bacon to work with Insta. Weirdly Insta does give color codes around
ok
when piped to a TTY (depending on how exactly--color=always
is specified):cargo insta test -p prql-compiler --lib --color=always -- --color=always
I think the difference in color output confuses Bacon, and so it can't parse the errors when tests are run through
insta
. I haven't dug in more, but there does seem to be an issue with Cargo.Version
The text was updated successfully, but these errors were encountered: