Test2::Formatter::Test2::Composer - Compose output components from event facets
This is used by Test2::Formatter::Test2 to turn events into output components.
This logic lives here instead of in the formatter because it is also used by
Test2::Harness::UI. Other tools may also find this conversion useful.
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;
...,
}
All methods are class methods, but they also work just fine on a blessed
instance. There is no benefit to a blessed instance, but you can create one
for convenience if it makes you more comfortable.
- $inst = $class->new()
- Create a blessed instance. This is here for convenience only. All methods
are class methods.
- $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.
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 are passed directly to
"render_control()" and are not used for
anything else.
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, things that
would usually be considered noise.
This is mainly useful for tools that allow deep inspection of
log files.
With exception of "render_control()" these are
all the same. These all take "\%facet_data"
as their only argument, and return a list of line-arrayrefs
"[$facet, $tag, $text_for_humans]".
- @lines = $class->render_control(\%facet_data, super_verbose =>
$bool)
- This specific one is special in that it can take an extra argument. This
argument is used to toggle between super_verbose and regular verbosity. No
other facet renderer needs this toggle. If omitted 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)
The source code repository for Test2-Harness can be found at
http://github.com/Test-More/Test2-Harness/.
- Chad Granum <exodist@cpan.org>
- Chad Granum <exodist@cpan.org>
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/