Skip to content

Commit

Permalink
Add show_empty_result_names to control how ok( 1, "" ) comes out.
Browse files Browse the repository at this point in the history
For #215 #84
  • Loading branch information
schwern committed Nov 30, 2011
1 parent c911851 commit 1f409fd
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
12 changes: 11 additions & 1 deletion lib/TB2/Formatter/TAP/Base.pm
Expand Up @@ -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;
Expand All @@ -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);
Expand Down
6 changes: 6 additions & 0 deletions lib/TB2/Formatter/TAP/TB1.pm
Expand Up @@ -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.";
Expand Down

0 comments on commit 1f409fd

Please sign in to comment.