test_utils/container_ostream: delegate to fmt::print#30426
Open
travisdowns wants to merge 1 commit intoredpanda-data:devfrom
Open
test_utils/container_ostream: delegate to fmt::print#30426travisdowns wants to merge 1 commit intoredpanda-data:devfrom
travisdowns wants to merge 1 commit intoredpanda-data:devfrom
Conversation
Replace the hand-rolled element iteration in the std::vector and std::unordered_map operator<< overloads with fmt::print, which already knows how to format ranges. This requires elements to be fmt-formattable, so the two test-local types that previously had only operator<< — test_struct in field_parser_test and serialization_format in httpd — are converted to the format_to convention; they pick up the auto-generated fmt::formatter from base/format_to.h and the existing operator<< call sites still work via Stephan's blanket overload.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the test-only container streaming utilities to use {fmt}’s built-in range formatting instead of manually iterating container elements, and adjusts a couple of test-local types to be {fmt}-formattable so existing assertion streaming continues to work.
Changes:
- Switch
std::vectorandstd::unordered_mapoperator<<overloads intest_utils/container_ostream.hto delegate tofmt::print. - Update expected strings in
container_ostream_test.ccto match {fmt}’s default range/map formatting (e.g.,[]for vectors, quoted strings in ranges). - Convert two test-local types (Kafka
test_struct, Pandaproxyserialization_format) fromoperator<<toformat_toso they participate inbase/format_to.h’s autofmt::formatter/operator<<bridging.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
src/v/test_utils/tests/container_ostream_test.cc |
Updates golden outputs to match {fmt} range/map formatting and removes the “stream-only element” test case. |
src/v/test_utils/container_ostream.h |
Implements test-only operator<< for std::vector/std::unordered_map via fmt::print and adds required {fmt} includes. |
src/v/test_utils/BUILD |
Adds @fmt dependency for the container_ostream test library. |
src/v/pandaproxy/parsing/test/httpd.cc |
Replaces operator<< for serialization_format with an ADL format_to free function. |
src/v/pandaproxy/parsing/test/BUILD |
Adds dependencies needed for the new format_to usage (//src/v/base, @fmt). |
src/v/kafka/protocol/tests/field_parser_test.cc |
Replaces operator<< for test_struct with a format_to member method. |
src/v/kafka/protocol/tests/BUILD |
Adds dependencies needed for the new format_to usage (//src/v/base, @fmt). |
Collaborator
CI test resultstest results on build#84239
|
StephanDollberg
approved these changes
May 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #30415 addressing review feedback.
Replace the hand-rolled element iteration in the std::vector and
std::unordered_map operator<< overloads in test_utils/container_ostream.h
with fmt::print, which already knows how to format ranges. This requires
elements to be fmt-formattable, so the two test-local types that
previously had only operator<< — test_struct in field_parser_test and
serialization_format in httpd — are converted to the format_to
convention; they pick up the auto-generated fmt::formatter from
base/format_to.h, and the existing operator<< call sites still work via
the blanket overload there.
This changes the logging format because fmt does things differently but this is test-only so I think it's OK.
Backports Required
Release notes