Skip to content

Commit

Permalink
Add comment if table it too small, fixes #931
Browse files Browse the repository at this point in the history
  • Loading branch information
exodist committed Sep 2, 2024
1 parent 8e284ae commit b6de65c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
2 changes: 2 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

{{$NEXT}}

- Add comment on how to make tables bigger, #931

1.302201 2024-08-13 08:19:01-07:00 America/Los_Angeles

- Fix bug found by new warnings in blead (Thanks Mauke)
Expand Down
8 changes: 7 additions & 1 deletion lib/Test2/Formatter/TAP.pm
Original file line number Diff line number Diff line change
Expand Up @@ -384,15 +384,21 @@ sub info_tap {

my $msg;
if ($table && $self->supports_tables) {
my $size = $self->calc_table_size($f);

$msg = join "\n" => map { "# $_" } Term::Table->new(
header => $table->{header},
rows => $table->{rows},
collapse => $table->{collapse},
no_collapse => $table->{no_collapse},
sanitize => 1,
mark_tail => 1,
max_width => $self->calc_table_size($f),
max_width => $size,
)->render();

$msg .= "\n(If this table is too small, you can use the TABLE_TERM_SIZE=### env var to set a larger size, detected size is '$size')\n"
if $size <= 80
&& !$ENV{TABLE_TERM_SIZE};
}
elsif (ref($details)) {
require Data::Dumper;
Expand Down
2 changes: 2 additions & 0 deletions t/Test2/modules/Formatter/TAP.t
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ use warnings;
my $CLASS;
my %BEFORE_LOAD;

local $ENV{TABLE_TERM_SIZE} = 80;

BEGIN {
my $old = select STDOUT;
$BEFORE_LOAD{STDOUT} = $|;
Expand Down

0 comments on commit b6de65c

Please sign in to comment.