From 9f8376981c6749b9420e3d319b29e9e78de49423 Mon Sep 17 00:00:00 2001 From: manuel Date: Thu, 29 Oct 2026 09:24:10 +0000 Subject: doc: describe how to make types printable in test failures Co-Authored-By: Claude Opus 5.5 --- CONTRIBUTING.rst | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'CONTRIBUTING.rst') diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index 2dbd613c..1ea69ee6 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -54,6 +54,16 @@ For thread-safety and race condition analysis under ThreadSanitizer: cmake --build --preset bht-stress-dbg ctest --preset bht-stress-dbg +Printing Values in Test Failures +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Catch2 prints values it cannot convert as ``{?}``. +To avoid that, every test translation unit force-includes ``kstd/test_support/string_makers.hpp`` (kstd tests) or ``kernel/test_support/string_makers.hpp`` (kernel tests), which teach Catch2 how to print our types without touching kernel code. +To make a new type printable in tests, either: + +* give it a ``kstd::formatter`` specialization, which is picked up automatically, or +* add a ``Catch::StringMaker`` specialization to the ``string_makers.hpp`` of the library the type belongs to. + Bootable Kernel Targets ~~~~~~~~~~~~~~~~~~~~~~~ -- cgit v1.2.3 From cb05568db24efc9fd0b33e9d0094256e1b678e69 Mon Sep 17 00:00:00 2001 From: manuel Date: Sat, 31 Oct 2026 09:54:17 +0000 Subject: doc: require StringMaker instead of formatter for test printing --- CONTRIBUTING.rst | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'CONTRIBUTING.rst') diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index 1ea69ee6..dabc2552 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -59,10 +59,9 @@ Printing Values in Test Failures Catch2 prints values it cannot convert as ``{?}``. To avoid that, every test translation unit force-includes ``kstd/test_support/string_makers.hpp`` (kstd tests) or ``kernel/test_support/string_makers.hpp`` (kernel tests), which teach Catch2 how to print our types without touching kernel code. -To make a new type printable in tests, either: - -* give it a ``kstd::formatter`` specialization, which is picked up automatically, or -* add a ``Catch::StringMaker`` specialization to the ``string_makers.hpp`` of the library the type belongs to. +To make a new type printable in tests, add a ``Catch::StringMaker`` specialization to the ``string_makers.hpp`` of the library the type belongs to. +Do not add or change anything in kernel code (e.g. a ``kstd::formatter``) just to make a type printable in tests. +Types that already have a ``kstd::formatter`` are printed through it automatically. Bootable Kernel Targets ~~~~~~~~~~~~~~~~~~~~~~~ -- cgit v1.2.3