When building GoogleTest with no filesystem support (primarily for bare-metal targets), the command line argument --gtest_color=yes has no effect and the output is not colored. Even if the output stream is not a TTY, when I explicitly require colors in the output using --gtest_color=yes I would expect to see the ANSI color codes emitted.
Steps to reproduce the problem
The following example was tested on Ubuntu 22.04 but should have the same behavior on any Linux system.
1- Clone googletest repo in a directory
git clone https://github.com/google/googletest
2- Create the following files next to the googletest folder
Describe the issue
When building GoogleTest with no filesystem support (primarily for bare-metal targets), the command line argument
--gtest_color=yes
has no effect and the output is not colored. Even if the output stream is not a TTY, when I explicitly require colors in the output using--gtest_color=yes
I would expect to see the ANSI color codes emitted.Steps to reproduce the problem
The following example was tested on Ubuntu 22.04 but should have the same behavior on any Linux system.
1- Clone googletest repo in a directory
2- Create the following files next to the googletest folder
add_subdirectory(googletest) target_compile_definitions(gtest PUBLIC GTEST_HAS_FILE_SYSTEM=0)
add_executable(GoogleTestNoFilesystem main.cpp) target_link_libraries(GoogleTestNoFilesystem PRIVATE gtest)
3- Build the code
4- Execute the generated binary
will output the following message (no color is OK in this case as the default mode 'auto' is used):
will output the same message as above without color, but as colored output was explicitly required the following output was expected:
What version of GoogleTest are you using?
dddb219c3eb96d7f9200f09b0a381f016e6b4562
What operating system and version are you using?
Ubuntu 22.04
What compiler and version are you using?
What build system are you using?
cmake version 3.27.0
Additional context
This issue could be fixed by using ShouldUseColor() either a filesystem is supported or not:
Would it be an acceptable solution? I can create a PR for this patch if it is ok.