I am building and running unit tests built with googletest inside a cmake project with ctest enabled
I run the tests with "ctest -VV"
but the test output does not color the "red" and "green"
[ RUN ] [ OK ] [ PASSSED ]
Does anyone know if there is an options to ctest to allow those colors to bleed through to the console?
In cmake you can pass environment variables like that:
add_executable(testExecutable
my_test.cpp)
target_link_libraries(testExecutable
gtest)
add_test(NAME testExecutable
COMMAND testExecutable)
add_custom_target(check
COMMAND env CTEST_OUTPUT_ON_FAILURE=1 GTEST_COLOR=1 ${CMAKE_CTEST_COMMAND}
DEPENDS testExecutable)
run $ make check
Maybe you don't want to export any variable to global scope and only have colors in one ctest call. In that case use this single command:
GTEST_COLOR=1 ctest -V
As the OP suggested, I added this line to my .bashrc and it worked:
export GTEST_COLOR=1
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With