Open sidey79 opened 2 years ago
@exodist
I'am still struggeling with grouping the output.
I was able to extend the TAP formatter, which is a good point to start.
package Test2::Formatter::gha;
use strict;
use warnings;
use strict;
use parent 'Test2::Formatter::TAP';
use Test2::Util::HashBase qw{
no_numbers handles _encoding _last_fh
-made_assertion
};
my $groupOpen = 0;
sub terminate {
$groupOpen ? _closeGroup() : undef;
return shift->SUPER::terminate(@_);
}
sub finalize {
$groupOpen ? _closeGroup() : undef;
return shift->SUPER::finalize(@_);
}
sub write {
my ($self, $e, $num, $f) = @_;
$f ||= $e->facet_data;
use Data::Dumper;
print Dumper ($e);
$groupOpen ? undef : _openGroup() ;
my $handles = $self->{+HANDLES};
# call the original write method
return shift->SUPER::write(@_);
}
sub _closeGroup
{
print q[::endgroup::] . "\n";
$groupOpen = 0;
}
sub _openGroup
{
$groupOpen = 1 ;
print q[::group::<groupname>] . "\n"
}
1;
Overall this adds ::group::<groupname>
at the beginning of the tests.
At the end, it brings in ::endgroup::
.
What i sill need, is a name of a group. I have some ideas, but don't know how to solve them:
1) get the name of a testfile and use this as the groupname 2) Introduce some new event type or similar, to specify the grouping. This needs modifications for all tests :( 3) similar as one but extended with informations from the summary. So we need to store all output and print it, as soon we have the summary.
I have a question with the formatter.
Because my tests are getting big and are running in a github action workflow, i was thinking about to optimise the way, they are displayed in github actions.
One thing i was thinking, is using github actions workflow commands to optimise output. Even subtests are a good option for grouping:
https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#example-setting-a-value
But till now, i was not realy able to extend the existing formater to extend the output.
The other thing i was thinking about is, having the error message in the review section linked to the line where the error occured. There is a tool, named reviewdog which is capable of doing this. I think it shoud be possible to define the
errorformat
correctly to the tap output, but till now i had no luck specifying a multiline error format which captures the relevant things.https://github.com/reviewdog/reviewdog
I found no other aproaches, which confuses me. Are there any other ways to go.