| 1 | #!/usr/bin/perl | ||
| 2 | |||
| 3 | package Test::TAP::Model::File::Visual; | ||
| 4 | 1 | ▶ | use base qw/Test::TAP::Model::File/; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | |||
| 6 | 1 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 7 | 1 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 8 | |||
| 9 | 0 | ▶ | use Test::TAP::Model::Colorful; |
|
Subroutine
BEGIN: called CC=1 SCAR=2.6
| |||
| 10 | use Test::TAP::Model::Subtest::Visual; | ||
| 11 | use URI::file; | ||
| 12 | |||
| 13 | sub subtest_class { "Test::TAP::Model::Subtest::Visual" } | ||
| 14 | |||
| 15 | sub desc_string { | ||
| 16 | my $self = shift; | ||
| 17 | $self->{_desc_string} = shift if @_; | ||
| 18 | $self->{_desc_string} ||= ""; | ||
| 19 | } | ||
| 20 | |||
| 21 | sub cases { | ||
| 22 | my $self = shift; | ||
| 23 | return $self->SUPER::cases(@_) unless wantarray; | ||
| 24 | |||
| 25 | my @ret = $self->SUPER::cases(@_); | ||
| 26 | return @ret if @ret; | ||
| 27 | |||
| 28 | # if there are no tests, return a stub that represents the whole file | ||
| 29 | return $self->subtest_class->new({ | ||
| 30 | type => "test", | ||
| 31 | ok => $self->ok, | ||
| 32 | skip => $self->skipped, | ||
| 33 | line => "stub" | ||
| 34 | }); | ||
| 35 | } | ||
| 36 | |||
| 37 | sub str_status { | ||
| 38 | my $self = shift; | ||
| 39 | return "SKIPPED" if $self->skipped; | ||
| 40 | return "BAILED OUT" if $self->bailed_out; | ||
| 41 | |||
| 42 | return "OK" | ||
| 43 | if $self->ok | ||
| 44 | and $self->actual_cases == $self->planned | ||
| 45 | and $self->actual_cases > 0; | ||
| 46 | |||
| 47 | return "FAILED"; | ||
| 48 | } | ||
| 49 | |||
| 50 | sub link { URI::file->new($_[0]->name) } | ||
| 51 | |||
| 52 | sub case_rows { | ||
| 53 | my $self = shift; | ||
| 54 | my @cases = $self->cases; | ||
| 55 | my @ret; | ||
| 56 | |||
| 57 | my $rows = int(.9 + @cases / 50) || 1; | ||
| 58 | my $per_row = int(.9 + @cases / $rows); | ||
| 59 | |||
| 60 | push @ret, { cases => [ splice(@cases, 0, $per_row) ] } while @cases; | ||
| 61 | |||
| 62 | \@ret; | ||
| 63 | } | ||
| 64 | |||
| 65 | __PACKAGE__ | ||
| 66 | |||
| 67 | __END__ | ||