mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-10 22:18:54 +01:00
test: Remove unsafe BOOST_TEST_MESSAGE
This commit is contained in:
@@ -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;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user