doc: Explain new test logging #18486

pull MarcoFalke wants to merge 1 commits into bitcoin:master from MarcoFalke:2004-docTestLogging changing 1 files +19 −10
  1. MarcoFalke commented at 8:27 pm on March 31, 2020: member
    Explain logging added in #18472 and #16975
  2. MarcoFalke force-pushed on Mar 31, 2020
  3. MarcoFalke commented at 8:33 pm on March 31, 2020: member

    Just as a note, if we wanted to remove boost, BOOST_TEST_MESSAGE can be replaced by a simple TEST_MESSAGE macro with this diff:

     0diff --git a/src/test/main.cpp b/src/test/main.cpp
     1index f32243d1d3..9bccbef805 100644
     2--- a/src/test/main.cpp
     3+++ b/src/test/main.cpp
     4@@ -13,14 +13,19 @@
     5 
     6 #include <iostream>
     7 
     8-/** Redirect debug log to unit_test.log files */
     9-const std::function<void(const std::string&)> G_TEST_LOG_FUN = [](const std::string& s) {
    10+bool IsTestLoggingEnabled()
    11+{
    12     static const bool should_log{std::any_of(
    13         &boost::unit_test::framework::master_test_suite().argv[1],
    14         &boost::unit_test::framework::master_test_suite().argv[boost::unit_test::framework::master_test_suite().argc],
    15         [](const char* arg) {
    16             return std::string{"DEBUG_LOG_OUT"} == arg;
    17         })};
    18-    if (!should_log) return;
    19+    return should_log;
    20+}
    21+
    22+/** Redirect debug log to unit_test.cpp.log files */
    23+const std::function<void(const std::string&)> G_TEST_LOG_FUN = [](const std::string& s) {
    24+    if (!IsTestLoggingEnabled()) return;
    25     std::cout << s;
    26 };
    27diff --git a/src/test/util/logging.h b/src/test/util/logging.h
    28index 45ec44173c..f4ad232c6e 100644
    29--- a/src/test/util/logging.h
    30+++ b/src/test/util/logging.h
    31@@ -11,6 +11,13 @@
    32 #include <list>
    33 #include <string>
    34 
    35+bool IsTestLoggingEnabled();
    36+
    37+#define TEST_MESSAGE(blob)              \
    38+    if (IsTestLoggingEnabled()) {       \
    39+        std::cout << blob << std::endl; \
    40+    }
    41+
    42 class DebugLogHelper
    43 {
    44     const std::string m_message;
    
  4. in src/test/README.md:44 in faabce8c31 outdated
    47+    test_bitcoin --log_level=all --run_test=getarg_tests -- DEBUG_LOG_OUT
    48+
    49+`log_level` controls the verbosity of the test framework, which logs when a
    50+test case is entered, for example. The `DEBUG_LOG_OUT` after the two dashes
    51+redirects the debug log, which would normally go to a file in the test datadir
    52+(`BasicTestingSetup::m_path_root`), to the stdandard terminal output.
    


    jonatack commented at 9:09 pm on March 31, 2020:
    standard

    jonatack commented at 9:10 pm on March 31, 2020:
    or maybe it’s a mix of stdout and standard :)

    MarcoFalke commented at 9:15 pm on March 31, 2020:

    or maybe it’s a mix of stdout and standard :)

    Yes, in my brain I wanted to write stdout, but then decided to write the longer form after I started :)


    MarcoFalke commented at 9:16 pm on March 31, 2020:
    Fixed in commit 77777
  5. jonatack commented at 9:09 pm on March 31, 2020: member
    ACK modulo nit
  6. doc: Explain new test logging 7777703958
  7. MarcoFalke force-pushed on Mar 31, 2020
  8. jonatack commented at 9:25 pm on March 31, 2020: member
    ACK 7777703
  9. DrahtBot added the label Docs on Mar 31, 2020
  10. DrahtBot added the label Tests on Mar 31, 2020
  11. DrahtBot commented at 11:27 pm on March 31, 2020: member

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #18102 (doc: add src/test/ prefix to test_bitcoin in test README by yancyribbens)

    If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

  12. MarcoFalke merged this on Apr 1, 2020
  13. MarcoFalke closed this on Apr 1, 2020

  14. MarcoFalke deleted the branch on Apr 1, 2020
  15. DrahtBot locked this on Feb 15, 2022

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-12-22 18:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me