aboutsummaryrefslogtreecommitdiff
path: root/src/test/main.cpp
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2020-03-30 13:59:13 -0400
committerMarcoFalke <falke.marco@gmail.com>2020-03-30 15:18:42 -0400
commitfa3cc0bfc4c4fc13a384fc291403c9fd41082f18 (patch)
treea28305955fc23be7669f3e7eb83ca68900a3aa69 /src/test/main.cpp
parent5f9cd62f33fb4d440173b9c376cadf4887e81e9d (diff)
downloadbitcoin-fa3cc0bfc4c4fc13a384fc291403c9fd41082f18.tar.xz
test: Remove unsafe BOOST_TEST_MESSAGE
Diffstat (limited to 'src/test/main.cpp')
-rw-r--r--src/test/main.cpp18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/test/main.cpp b/src/test/main.cpp
index e6529949e2..f32243d1d3 100644
--- a/src/test/main.cpp
+++ b/src/test/main.cpp
@@ -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;
};