| 1 | package TAP::DOM::Waivers::Formatter; | ||||||||||||||||||||||||||||
| 2 | BEGIN { | ||||||||||||||||||||||||||||
| 3 | 1 | ▶ | $TAP::DOM::Waivers::Formatter::AUTHORITY = 'cpan:SCHWIGON'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | } # better TAP::Formatter::DOM? | ||||||||||||||||||||||||||||
| 5 | # ABSTRACT: (incomplete) 'prove' plugin support for TAP::DOM::Waivers | ||||||||||||||||||||||||||||
| 6 | 1 | $TAP::DOM::Waivers::Formatter::VERSION = '0.002'; | |||||||||||||||||||||||||||
| 7 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use TAP::DOM::Waivers::Formatter::Session; # better TAP::Formatter::DOM::Session? | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 1 | ▶ | use Data::Dumper; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 1 | ▶ | use base qw( TAP::Base ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | 1 | use accessors qw( | |||||||||||||||||||||||||||
| 15 | verbosity | ||||||||||||||||||||||||||||
| 16 | tests | ||||||||||||||||||||||||||||
| 17 | session_class | ||||||||||||||||||||||||||||
| 18 | escape_output | ||||||||||||||||||||||||||||
| 19 | stdout | ||||||||||||||||||||||||||||
| 20 | sessions | ||||||||||||||||||||||||||||
| 21 | waiver | ||||||||||||||||||||||||||||
| 22 | 1 | ▶ | ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | 1 | our @TFW_ARGS = qw( | |||||||||||||||||||||||||||
| 25 | waiver | ||||||||||||||||||||||||||||
| 26 | escape_output | ||||||||||||||||||||||||||||
| 27 | ); | ||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | # global variables | ||||||||||||||||||||||||||||
| 30 | sub _initialize { | ||||||||||||||||||||||||||||
| 31 | 0 | ▶ | my ($self, $args) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_initialize: not called CC=7 SCAR=40.3
| |||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | 0 | ▶ | $args ||= {}; | ||||||||||||||||||||||||||
|
Condition0%0/2
$args ||= {}
MC/DC0%0/1
$args ||= {}
$args
Truth table0%0/2
A
A= $args
| |||||||||||||||||||||||||||||
| 34 | 0 | $self->SUPER::_initialize($args); | |||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | 0 | ▶ | my $stdout_fh = IO::File->new_from_fd( fileno(STDOUT), 'w' ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 37 | or die "Error opening STDOUT for writing: $!"; | ||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | 0 | $self->verbosity( 0 ) | |||||||||||||||||||||||||||
| 40 | ->stdout( $stdout_fh ) | ||||||||||||||||||||||||||||
| 41 | ->escape_output( 0 ) | ||||||||||||||||||||||||||||
| 42 | ->session_class( "TAP::DOM::Waivers::Formatter::Session" ) | ||||||||||||||||||||||||||||
| 43 | ->sessions( [] ) | ||||||||||||||||||||||||||||
| 44 | ; | ||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | # Laziness... | ||||||||||||||||||||||||||||
| 47 | # trust the user knows what they're doing with the args: | ||||||||||||||||||||||||||||
| 48 | 0 | foreach my $key (keys %$args) { | |||||||||||||||||||||||||||
| 49 | 0 | ▶ | $self->info( "INIT args.$key = ", $args->{$key}, "\n") if $self->can( $key ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 50 | 0 | ▶ | $self->$key( $args->{$key} ) if ($self->can( $key )); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||
| 52 | 0 | $self->info( "KEY: $_ = ".$args->{$_} ) foreach keys %$args; | |||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | 0 | $self->check_for_overrides_in_env; | |||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | 0 | $self->info( "WAIVER FILE: ".$self->waiver ); | |||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | 0 | return $self; | |||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | sub check_for_overrides_in_env { | ||||||||||||||||||||||||||||
| 63 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
check_for_overrides_in_env: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | 0 | foreach my $arg (@TFW_ARGS) { | |||||||||||||||||||||||||||
| 66 | 0 | my $val = $ENV{"TAP_FORMATTER_WAIVERS_".uc($arg)}; | |||||||||||||||||||||||||||
| 67 | 0 | ▶ | $self->info( "arg: $arg = $val" ) if defined $val; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 68 | 0 | ▶ | $self->$arg( $val ) if defined $val; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | 0 | return $self; | |||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | # Called by Test::Harness before any test output is generated. | ||||||||||||||||||||||||||||
| 75 | sub prepare { | ||||||||||||||||||||||||||||
| 76 | 0 | ▶ | my ($self, @tests) = @_; | ||||||||||||||||||||||||||
|
Subroutine
prepare: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 77 | # warn ref($self) . "->prepare called with args:\n" . Dumper( \@tests ); | ||||||||||||||||||||||||||||
| 78 | 0 | $self->info( 'PREPARE ', scalar @tests, ' tests' ); | |||||||||||||||||||||||||||
| 79 | 0 | $self->tests( [@tests] ); | |||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | sub open_test { | ||||||||||||||||||||||||||||
| 83 | 0 | ▶ | my ($self, $test, $parser) = @_; | ||||||||||||||||||||||||||
|
Subroutine
open_test: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 84 | #warn ref($self) . "->open_test called with args: " . Dumper( [$test, $parser] ); | ||||||||||||||||||||||||||||
| 85 | 0 | $self->info( 'OPEN_TEST'); | |||||||||||||||||||||||||||
| 86 | 0 | my $session = $self->session_class->new({ test => $test, | |||||||||||||||||||||||||||
| 87 | parser => $parser, | ||||||||||||||||||||||||||||
| 88 | formatter => $self, | ||||||||||||||||||||||||||||
| 89 | }); | ||||||||||||||||||||||||||||
| 90 | 0 | push @{ $self->sessions }, $session; | |||||||||||||||||||||||||||
| 91 | 0 | return $session; | |||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | sub summary { | ||||||||||||||||||||||||||||
| 95 | 0 | ▶ | my ($self, $aggregate) = @_; | ||||||||||||||||||||||||||
|
Subroutine
summary: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||
| 97 | 0 | ▶ | if (! $self->silent) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 98 | 0 | $self->info("SUMMARY"); | |||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||
| 101 | # $self->info( "PARSER: ", Dumper($self->sessions->[0]->parser) ); | ||||||||||||||||||||||||||||
| 102 | # $self->info( "SESSIONS: ", Dumper($self->sessions) ); | ||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | 0 | return $self; | |||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||
| 107 | sub log { | ||||||||||||||||||||||||||||
| 108 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
log: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 109 | 0 | ▶ | push @_, "\n" unless grep {/\n/} @_; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 110 | 0 | $self->_output( @_ ); | |||||||||||||||||||||||||||
| 111 | 0 | return $self; | |||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||
| 114 | sub info { | ||||||||||||||||||||||||||||
| 115 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
info: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 116 | 0 | ▶ | return unless $self->verbose; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 117 | 0 | return $self->log( @_ ); | |||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||
| 120 | sub log_test { | ||||||||||||||||||||||||||||
| 121 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
log_test: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 122 | 0 | ▶ | return if $self->really_quiet; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 123 | 0 | return $self->log( @_ ); | |||||||||||||||||||||||||||
| 124 | } | ||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||
| 126 | sub log_test_info { | ||||||||||||||||||||||||||||
| 127 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
log_test_info: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 128 | 0 | ▶ | return if $self->quiet; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 129 | 0 | return $self->log( @_ ); | |||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||
| 132 | sub _output { | ||||||||||||||||||||||||||||
| 133 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
_output: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||
| 134 | 0 | ▶ | return if $self->silent; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 135 | 0 | ▶ | if (ref($_[0]) && ref( $_[0]) eq 'SCALAR') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ref $_[0] and ref $_[0] eq "SCALAR"
MC/DC0%0/2
ref $_[0] and ref $_[0] eq "SCALAR"
ref $_[0]
ref $_[0] eq "SCALAR"
Truth table0%0/3
A and B
A= ref $_[0]B= ref $_[0] eq "SCALAR"
| |||||||||||||||||||||||||||||
| 136 | # DEPRECATED: printing HTML: | ||||||||||||||||||||||||||||
| 137 | 0 | print { $self->stdout } ${ $_[0] }; | |||||||||||||||||||||||||||
| 138 | } else { | ||||||||||||||||||||||||||||
| 139 | 0 | ▶ | unshift @_, '# ' if $self->escape_output; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 140 | 0 | print { $self->stdout } @_; | |||||||||||||||||||||||||||
| 141 | } | ||||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||
| 144 | sub verbose { | ||||||||||||||||||||||||||||
| 145 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
verbose: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 146 | # emulate a classic accessor for compat w/TAP::Formatter::Console: | ||||||||||||||||||||||||||||
| 147 | 0 | ▶ | if (@_) { $self->verbosity(1) } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 148 | 0 | return $self->verbosity >= 1; | |||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||
| 151 | sub quiet { | ||||||||||||||||||||||||||||
| 152 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
quiet: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 153 | # emulate a classic accessor for compat w/TAP::Formatter::Console: | ||||||||||||||||||||||||||||
| 154 | 0 | ▶ | if (@_) { $self->verbosity(-1) } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 155 | 0 | return $self->verbosity <= -1; | |||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||
| 158 | sub really_quiet { | ||||||||||||||||||||||||||||
| 159 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
really_quiet: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 160 | # emulate a classic accessor for compat w/TAP::Formatter::Console: | ||||||||||||||||||||||||||||
| 161 | 0 | ▶ | if (@_) { $self->verbosity(-2) } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 162 | 0 | return $self->verbosity <= -2; | |||||||||||||||||||||||||||
| 163 | } | ||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||
| 165 | sub silent { | ||||||||||||||||||||||||||||
| 166 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
silent: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 167 | # emulate a classic accessor for compat w/TAP::Formatter::Console: | ||||||||||||||||||||||||||||
| 168 | 0 | ▶ | if (@_) { $self->verbosity(-3) } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 169 | 0 | return $self->verbosity <= -3; | |||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||
| 172 | 1 | 1; | |||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||
| 174 | __END__ | ||||||||||||||||||||||||||||