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
Add support for using is_terminal and environment variables to determine whether to output ANSI colour sequences.
This makes use of the trait [`IsTerminal`](https://doc.rust-lang.org/stable/std/io/trait.IsTerminal.html), stabilised in Rust 1.70. If the Rust version is at least 1.70, then the library uses this trait to detect whether stdout is a terminal and only outputs colours by default if that is the case. When used on prior Rust versions, the library does not detect whether the output is a terminal and defaults to not outputing colours.
This also introduces support for two environment variables to override the default behaviour defined above:
* `NO_COLOR`, described in <http://no-color.org>.
* `FORCE_COLOR`, which is supported by a range of tools such as [Node.js](https://nodejs.org/api/cli.html#force_color1-2-3).
The environment variable `GTEST_RUST_NO_COLOR` is hereby no longer supported.
This also removes the ANSI colour sequences from nearly all tests. It creates two integration tests which specifically test the colourised output respectively the behaviour of the environment variable `NO_COLOR`. Otherwise, it globally sets `NO_COLOR` to suppress colourised output. This greatly reduces the noise in the existing test assertions and makes sure the tests continue to be compatible with all environments.
Since the use of `IsTerminal` is optional and conditional on the Rust version, this does not change the minimum supported Rust version.
| GTEST_RUST_NO_COLOR | If set to any value, disables ANSI output from the failure message. This is useful when the failure description is piped to a file or another process. |
0 commit comments