cpanel / Test2-Harness-Renderer-JUnit

An implementation of JUnit output for Test2::Harness
https://metacpan.org/pod/Test2::Harness::Renderer::JUnit
2 stars 4 forks source link

turning off line numbering can break the renderer #16

Closed rjbs closed 1 year ago

rjbs commented 1 year ago

Here is a test from andk/PAUSE

use strict;
use warnings;
use File::Spec;
use Test::More;

if ($ENV{NO_PERL_CRITIC}) {
    plan( skip_all => '$NO_PERL_CRITIC set, skipping');
}

eval { require Test::Perl::Critic; };

if ( $@ ) {
    my $msg = 'Test::Perl::Critic required to criticise code';
    plan( skip_all => $msg );
}

my $rcfile = File::Spec->catfile( 't', 'perlcriticrc' );
Test::Perl::Critic->import( -profile => $rcfile );
all_critic_ok();

Test::Perl::Critic does $TEST->use_numbers(0). Later, in the JUnit renderer, this line fires:

my $test_num    = sprintf( "%04d", $event->{'assert_count'} || $f->{'assert'}->{'number'} || die Dumper $event);

There are no numbers, and (I think this matters), the plan runs before there's any count of asserts. We hit the die, which just blats a dump to the screen and exits.

At least the Dumper should include "can't handle assert with no number", but better, it should cope somehow.