Reputation: 161
I'm using Boost Unit Test and I have the following simple program:
#include <iostream>
#include <boost/test/included/unit_test.hpp>
void test1()
{
std::cout << "Here's test 1" << std::endl;
BOOST_CHECK_EQUAL(1, 2);
}
void test2()
{
std::cout << "Here's test 2" << std::endl;
BOOST_CHECK_EQUAL(1, 1);
}
boost::unit_test::test_suite*
init_unit_test_suite(int argc, char* argv[])
{
using namespace boost::unit_test;
test_suite* ts1 = BOOST_TEST_SUITE("test_suite1");
ts1->add(BOOST_TEST_CASE(&test1));
ts1->add(BOOST_TEST_CASE(&test2));
framework::master_test_suite().add(ts1);
return 0;
}
As you can see, the first test should fail and the second test should pass. Upon running this program with no arguments, everything works as expected, except that after the first test finishes, all console text becomes permanently red forever. This is the console output I'm seeing:
Running 2 test cases...
Here's test 1
c:/users/<redacted>/code/utils/cppscripts/testbed/testbed.cpp(8): error: in "test_suite1/test1": check 1 == 2 has failed [1 != 2]
Here's test 2
*** 1 failure is detected in the test module "Master Test Suite"
Not only is the Here's test 2
text red, the console text color is still red even after the program has finished. I would prefer that only text pertaining to the particular test that failed is red, and I would most certainly prefer that Boost clean itself up and not force me to restart my commandline in order to get white text again. (Red on black is hard to read.)
Also, please do not suggest using the --color_output
argument to turn off all color completely. That's not the answer I'm looking for.
I'm on Windows using Boost 1.67 with Visual Studio 2017. I notice the issue when running the test executable on both Windows command prompt and Windows powershell. How can I accomplish this?
Upvotes: 3
Views: 229
Reputation: 393969
This is likely due to a buggy terminal emulator OR a mismatch between the terminal emulation and the reported capabilities (termcap).
You can try
If you're using this inside an IDE, e.g. VsCode or Clion, report a bug at their trackers.
At least on linux, there is no such issue:
Retest with full outputs:
Upvotes: 2