From 8aa6ab4d29df80adde0d512244d43d38264bf32e Mon Sep 17 00:00:00 2001 From: Dimitri Staessens Date: Wed, 14 Jan 2026 01:07:53 +0100 Subject: build: Add option to toggle Ouroboros logging in tests The test output is a bit polluted with logs originating fomr the logging system, e.g.: 23: test_bind_prog started. 23: ==16636== reg/name(DB): Add prog reg_test to name testname. 23: ==16636== reg(EE): Removing from names. 23: test_bind_prog succeeded. This adds a flag DISABLE_TEST_LOGGING that suppresses log_* output in tests to keep them clean: 23: test_bind_prog started. 23: test_bind_prog succeeded. The status is printed in CMake output: -- Ouroboros logging in test output disabled -- Ouroboros logging in test output enabled By default the flag is ON (clean test output). Signed-off-by: Dimitri Staessens Signed-off-by: Sander Vrijders --- cmake/tests.cmake | 2 ++ cmake/utils/DisableTestLogging.cmake | 12 ++++++++++++ 2 files changed, 14 insertions(+) create mode 100644 cmake/utils/DisableTestLogging.cmake (limited to 'cmake') diff --git a/cmake/tests.cmake b/cmake/tests.cmake index 01dd2ecd..4c16171c 100644 --- a/cmake/tests.cmake +++ b/cmake/tests.cmake @@ -1,5 +1,7 @@ include(CTest) # Sets BUILD_TESTING by default to on. +include(utils/DisableTestLogging) + if (CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING) set(BUILD_TESTS ON) else () diff --git a/cmake/utils/DisableTestLogging.cmake b/cmake/utils/DisableTestLogging.cmake new file mode 100644 index 00000000..730b0bc0 --- /dev/null +++ b/cmake/utils/DisableTestLogging.cmake @@ -0,0 +1,12 @@ +set(DISABLE_TESTS_LOGGING TRUE CACHE BOOL "Disable Ouroboros log output in tests") +if (DISABLE_TESTS_LOGGING) + message(STATUS "Ouroboros logging in test output disabled") +else () + message(STATUS "Ouroboros logging in test output enabled") +endif () + +macro(disable_test_logging_for_target target) + if (DISABLE_TESTS_LOGGING) + target_compile_definitions(${target} PRIVATE OUROBOROS_DISABLE_LOGGING) + endif () +endmacro() -- cgit v1.2.3