test: Remove unsafe BOOST_TEST_MESSAGE

This commit is contained in:
MarcoFalke
2020-03-30 13:59:13 -04:00
parent 5f9cd62f33
commit fa3cc0bfc4
3 changed files with 12 additions and 16 deletions

View File

@@ -11,12 +11,16 @@
#include <test/util/setup_common.h>
/** Redirect debug log to boost log */
#include <iostream>
/** Redirect debug log to unit_test.log files */
const std::function<void(const std::string&)> G_TEST_LOG_FUN = [](const std::string& s) {
if (s.back() == '\n') {
// boost will insert the new line
BOOST_TEST_MESSAGE(s.substr(0, s.size() - 1));
} else {
BOOST_TEST_MESSAGE(s);
}
static const bool should_log{std::any_of(
&boost::unit_test::framework::master_test_suite().argv[1],
&boost::unit_test::framework::master_test_suite().argv[boost::unit_test::framework::master_test_suite().argc],
[](const char* arg) {
return std::string{"DEBUG_LOG_OUT"} == arg;
})};
if (!should_log) return;
std::cout << s;
};