diff options
| author | manuel <manuel.bott@eps.ch> | 2026-10-31 09:54:17 +0000 |
|---|---|---|
| committer | manuel <manuel.bott@eps.ch> | 2026-10-31 09:55:53 +0000 |
| commit | 5361b78771fb6605b5df78aa2dbff560cb1ce44e (patch) | |
| tree | 4befb75c000a0b703828c257e28784827f4816b9 | |
| parent | 3f2146d368f012a6f1aa87c706a857f5f782cfce (diff) | |
| download | kernel-5361b78771fb6605b5df78aa2dbff560cb1ce44e.tar.xz kernel-5361b78771fb6605b5df78aa2dbff560cb1ce44e.zip | |
doc: require StringMaker instead of formatter for test printingfeature/catch2-string-makers
| -rw-r--r-- | CONTRIBUTING.rst | 7 | ||||
| -rw-r--r-- | libs/kstd/kstd/test_support/string_makers.hpp | 6 |
2 files changed, 6 insertions, 7 deletions
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 ~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/libs/kstd/kstd/test_support/string_makers.hpp b/libs/kstd/kstd/test_support/string_makers.hpp index c2c6a38a..46d270f9 100644 --- a/libs/kstd/kstd/test_support/string_makers.hpp +++ b/libs/kstd/kstd/test_support/string_makers.hpp @@ -7,9 +7,9 @@ //! so that failed assertions show the actual values. It is force-included into every test translation unit by the //! build system and must therefore never be included by kernel code. //! -//! Any type with a kstd::formatter specialization is printed via kstd::format, so the easiest way to make a type -//! printable in tests is to give it a formatter. Types without a formatter can get a Catch::StringMaker specialization -//! here, or in the test support header of the library they belong to. +//! Types that already have a kstd::formatter specialization are printed via kstd::format. All other types get a +//! Catch::StringMaker specialization here, or in the test support header of the library they belong to. Kernel code +//! must never be changed just to make a type printable in tests. #include <kstd/format.hpp> #include <kstd/memory.hpp> |
