diff --git a/lib/TB2/Formatter/TAP/Base.pm b/lib/TB2/Formatter/TAP/Base.pm index 9c15b3296..4aabc1f8f 100644 --- a/lib/TB2/Formatter/TAP/Base.pm +++ b/lib/TB2/Formatter/TAP/Base.pm @@ -422,6 +422,13 @@ has 'directive_display' => } }; +# A result with an empty string for a name is considered to have no name. +has show_empty_result_names => + is => 'ro', + isa => 'Bool', + default => 0; + + sub handle_result { my $self = shift; my $result = shift; @@ -440,7 +447,10 @@ sub handle_result { my $name = $result->name; $self->_escape(\$name); - $out .= " - $name" if defined $name and length $name; + my $show_name = 1; + $show_name = 0 if !defined $name; + $show_name = 0 if !length $name && !$self->show_empty_result_names; + $out .= " - $name" if $show_name; my $reason = $result->reason; $self->_escape(\$reason); diff --git a/lib/TB2/Formatter/TAP/TB1.pm b/lib/TB2/Formatter/TAP/TB1.pm index a450e4157..e602abb6c 100644 --- a/lib/TB2/Formatter/TAP/TB1.pm +++ b/lib/TB2/Formatter/TAP/TB1.pm @@ -25,6 +25,12 @@ has '+directive_display' => } }; + +# ok( 1, "" ) comes out as "ok 1 - " +has "+show_empty_result_names" + default => 1; + + # Messages output as part of the ending commentary has '+diag_tests_but_no_plan' => default => "Tests were run but no plan was declared and done_testing() was not seen.";