Test2:...omposer(3pm)
π Test2::Formatter::Test2::Composer β the Test2:...omposer(3pm) page, but make it cute β¨
okay so bestie, welcome to the perl manual for Test2::Formatter::Test2::Composer, and no cap, this one is lowkey the glue that holds your pretty test output together π«Ά
β¨ NAME β¨
Test2::Formatter::Test2::Composer β compose output components from event facets π
πΈ DESCRIPTION πΈ
So here's the vibe: this module is what Test2::Formatter::Test2 uses to turn events into output components. The way that this logic lives here instead of inside the formatter itself?? iconic. It's here because Test2::Harness::UI uses it too, and honestly other tools might find this whole conversion thing useful as well π
π¦ SYNOPSIS π¦
use Test2::Formatter::Test2::Composer;
# Note, all methods are class methods, this is just here for convenience.
my $comp = Test2::Formatter::Test2::Composer->new();
my $out = $comp->render_one_line($event);
my ($facet_name, $tag_string, $text_for_humans) = @$out;
...
for my $line ($comp->render_verbose($event)) {
my ($facet_name, $tag_string, $text_for_humans) = @$line;
...,
}
π METHODS π
fr fr, every single method here is a class method β but they also work perfectly fine on a blessed instance. There is genuinely no benefit to a blessed instance, like zero, none, nada. But if creating one makes you feel more comfortable, you can absolutely do it for convenience. main character energy, honestly π
$inst = $class->new()β Creates a blessed instance. This is here for convenience only. All methods are class methods. that's the whole tea β$arrayref = $class->render_one_line($event)$arrayref = $class->render_one_line(\%facet_data)
my $out = $comp->render_one_line($event);
my ($facet_name, $tag_string, $text_for_humans) = @$out;
This will return a single line of output from the event, even if the event would normally return multiple lines. slay.
In order of priority:
- Custom
'render'facet - Control
'halt'facet (bail-out) - Assertion (pass/fail)
- Error message
- Plan
- Info (note/diag)
- Timing data
- About
@lines = $class->render_verbose($event, %control_params)@lines = $class->render_verbose(\%facet_data, %control_params)
This will verbosely render any event. The %control_params get passed directly to render_control() and are not used for anything else, periodt.
for my $line ($comp->render_verbose($event)) {
my ($facet_name, $tag_string, $text_for_humans) = @$line;
...,
}
@lines = $class->render_super_verbose($event)@lines = $class->render_super_verbose(\%facet_data)
This is even more verbose than render_verbose() π because it produces output lines even for facets that should normally not be seen β like, things that would usually be considered noise.
This is mainly useful for tools that allow deep inspection of log files. iykyk π
π FACET RENDERERS π
okay so with the exception of render_control(), these are all the same. They all take \%facet_data as their only argument, and they return a list of line-arrayrefs [$facet, $tag, $text_for_humans]. adorable, consistent, we love that for them π
@lines = $class->render_control(\%facet_data, super_verbose => $bool)β This specific one is special because it can take an extra argument. That argument toggles between super_verbose and regular verbosity. No other facet renderer needs this toggle. If you omit it, it defaults to not being super verbose.@lines = $class->render_launch(\%facet_data)@lines = $class->render_start(\%facet_data)@lines = $class->render_exit(\%facet_data)@lines = $class->render_end(\%facet_data)@lines = $class->render_brief(\%facet_data)@lines = $class->render_plan(\%facet_data)@lines = $class->render_assert(\%facet_data)@lines = $class->render_amnesty(\%facet_data)@lines = $class->render_debug(\%facet_data)@lines = $class->render_info(\%facet_data)@lines = $class->render_about(\%facet_data)@lines = $class->render_errors(\%facet_data)
π₯ SOURCE π₯
The source code repository for Test2-Harness can be found at http://github.com/Test-More/Test2-Harness/ π
π MAINTAINERS π
Chad Granum <exodist@cpan.org>
π AUTHORS π
Chad Granum <exodist@cpan.org>
π COPYRIGHT π
Copyright 2020 Chad Granum <exodist7@gmail.com>.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
See http://dev.perl.org/licenses/
and that's the whole page bestie, you ate it up π
β¨ this one's from the perl v5.40.1 era, dated 2026-05-10, and it's the Test2:...omposer(3pm) page from User Contributed Perl Documentation β go forth and compose those output components, queen ππ¦
π¦ where this page comes from
- ubuntu stonking: libtest2-harness-perl 1.000172-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms