| 1 | package TAP::Formatter::Session::TeamCity; | ||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||
| 3 | 18 | ▶ | use strict; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 4 | 18 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||
| 6 | 18 | our $VERSION = '0.08'; | |||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||
| 8 | 18 | ▶ | use TAP::Parser::Result::Test; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 9 | 18 | ▶ | use Time::HiRes qw( time ); | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||
| 11 | 18 | ▶ | use base qw(TAP::Formatter::Session); | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||
| 13 | { | ||||||||||||||||||||||||||||||||||
| 14 | 18 | my @accessors = map { '_tc_' . $_ } qw( | |||||||||||||||||||||||||||||||||
| 15 | last_test_name | ||||||||||||||||||||||||||||||||||
| 16 | last_test_result | ||||||||||||||||||||||||||||||||||
| 17 | is_last_suite_empty | ||||||||||||||||||||||||||||||||||
| 18 | suite_name_stack | ||||||||||||||||||||||||||||||||||
| 19 | test_output_buffer | ||||||||||||||||||||||||||||||||||
| 20 | suite_output_buffer | ||||||||||||||||||||||||||||||||||
| 21 | buffered_output | ||||||||||||||||||||||||||||||||||
| 22 | output_handle | ||||||||||||||||||||||||||||||||||
| 23 | ); | ||||||||||||||||||||||||||||||||||
| 24 | 18 | __PACKAGE__->mk_methods(@accessors); | |||||||||||||||||||||||||||||||||
| 25 | } | ||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||
| 27 | ## no critic (Subroutines::ProhibitUnusedPrivateSubroutines) | ||||||||||||||||||||||||||||||||||
| 28 | sub _initialize { | ||||||||||||||||||||||||||||||||||
| 29 | 48 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
_initialize: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||
| 31 | 48 | $self->SUPER::_initialize(@_); | |||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||
| 33 | 48 | $self->_tc_suite_name_stack( [] ); | |||||||||||||||||||||||||||||||||
| 34 | 48 | $self->_tc_test_output_buffer(q{}); | |||||||||||||||||||||||||||||||||
| 35 | 48 | $self->_tc_suite_output_buffer(q{}); | |||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||
| 37 | 48 | my $buffered = q{}; | |||||||||||||||||||||||||||||||||
| 38 | 48 | $self->_tc_buffered_output( \$buffered ); | |||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||
| 40 | 48 | ▶ | if ( $self->_is_parallel ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 41 | 16 | $self->_tc_message( | |||||||||||||||||||||||||||||||||
| 42 | 'progressMessage', | ||||||||||||||||||||||||||||||||||
| 43 | 'starting ' . $self->name, | ||||||||||||||||||||||||||||||||||
| 44 | 1, | ||||||||||||||||||||||||||||||||||
| 45 | ); | ||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||
| 47 | ## no critic (InputOutput::RequireCheckedOpen, InputOutput::RequireCheckedSyscalls) | ||||||||||||||||||||||||||||||||||
| 48 | 16 | open my $fh, '>', \$buffered; | |||||||||||||||||||||||||||||||||
| 49 | 16 | $self->_tc_output_handle($fh); | |||||||||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||||||||
| 51 | else { | ||||||||||||||||||||||||||||||||||
| 52 | 32 | $self->_tc_output_handle( \*STDOUT ); | |||||||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||
| 55 | 48 | $self->_start_suite( $self->name ); | |||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||
| 57 | 48 | return $self; | |||||||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||||||||
| 59 | ## use critic | ||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||
| 61 | sub _is_parallel { | ||||||||||||||||||||||||||||||||||
| 62 | 849 | ▶ | return $_[0]->formatter->jobs > 1; | ||||||||||||||||||||||||||||||||
|
Subroutine
_is_parallel: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||
| 65 | sub result { | ||||||||||||||||||||||||||||||||||
| 66 | 1119 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
result: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 67 | 1119 | my $result = shift; | |||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||
| 69 | 1119 | my $type = $result->type; | |||||||||||||||||||||||||||||||||
| 70 | 1119 | my $handler = "_handle_$type"; | |||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||
| 72 | 1119 | ▶ | die qq{Can't handle result of type=$type} | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 73 | unless $self->can($handler); | ||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||
| 75 | 1119 | $self->$handler($result); | |||||||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||
| 78 | ## no critic (Subroutines::ProhibitUnusedPrivateSubroutines) | ||||||||||||||||||||||||||||||||||
| 79 | sub _handle_test { | ||||||||||||||||||||||||||||||||||
| 80 | 48 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
_handle_test: called CC=4 SCAR=16.9
| |||||||||||||||||||||||||||||||||||
| 81 | 48 | my $result = shift; | |||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||
| 83 | 48 | ▶ | unless ( $self->_test_finished ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 84 | 36 | ▶ | if ( $result->directive eq 'SKIP' ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||
| 86 | # when tcm skips methods, we get 1st a Subtest message | ||||||||||||||||||||||||||||||||||
| 87 | # then "ok $num # skip $message" | ||||||||||||||||||||||||||||||||||
| 88 | 0 | ( my $reason ) = ( $result->raw =~ /^\s*ok \d+ # skip (.*)$/ ); | |||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||
| 90 | 0 | $self->_tc_message( | |||||||||||||||||||||||||||||||||
| 91 | 'testStarted', | ||||||||||||||||||||||||||||||||||
| 92 | { | ||||||||||||||||||||||||||||||||||
| 93 | name => 'Skipped', | ||||||||||||||||||||||||||||||||||
| 94 | captureStandardOutput => 'true' | ||||||||||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||||||||
| 96 | ); | ||||||||||||||||||||||||||||||||||
| 97 | 0 | $self->_tc_message( | |||||||||||||||||||||||||||||||||
| 98 | 'testIgnored', | ||||||||||||||||||||||||||||||||||
| 99 | { | ||||||||||||||||||||||||||||||||||
| 100 | name => 'Skipped', | ||||||||||||||||||||||||||||||||||
| 101 | message => $reason | ||||||||||||||||||||||||||||||||||
| 102 | }, | ||||||||||||||||||||||||||||||||||
| 103 | ); | ||||||||||||||||||||||||||||||||||
| 104 | 0 | $self->_finish_test('Skipped'); | |||||||||||||||||||||||||||||||||
| 105 | 0 | $self->_finish_suite; | |||||||||||||||||||||||||||||||||
| 106 | 0 | return; | |||||||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||
| 110 | 48 | my $test_name = $self->_compute_test_name($result); | |||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||
| 112 | 48 | ▶ | $self->_test_started($result) unless $self->_finish_suite($test_name); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||
| 115 | ## no critic (Subroutines::ProhibitUnusedPrivateSubroutines) | ||||||||||||||||||||||||||||||||||
| 116 | sub _handle_comment { | ||||||||||||||||||||||||||||||||||
| 117 | 60 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
_handle_comment: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||
| 118 | 60 | my $result = shift; | |||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||
| 120 | 60 | my $comment = $result->raw; | |||||||||||||||||||||||||||||||||
| 121 | 60 | ▶ | if ( $comment =~ /^\s*# Looks like you failed \d+/ ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 122 | 9 | $self->_test_finished; | |||||||||||||||||||||||||||||||||
| 123 | 9 | return; | |||||||||||||||||||||||||||||||||
| 124 | } | ||||||||||||||||||||||||||||||||||
| 125 | 51 | $comment =~ s/^\s*#\s?//; | |||||||||||||||||||||||||||||||||
| 126 | 51 | $comment =~ s/\s+$//; | |||||||||||||||||||||||||||||||||
| 127 | 51 | ▶ | return if $comment =~ /^\s*$/; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 128 | 51 | $self->_tc_test_output_buffer( | |||||||||||||||||||||||||||||||||
| 129 | $self->_tc_test_output_buffer . "$comment\n" ); | ||||||||||||||||||||||||||||||||||
| 130 | 51 | $self->_maybe_print_raw( $result->raw ); | |||||||||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||
| 133 | ## no critic (Subroutines::ProhibitUnusedPrivateSubroutines, Subroutines::ProhibitExcessComplexity) | ||||||||||||||||||||||||||||||||||
| 134 | sub _handle_unknown { | ||||||||||||||||||||||||||||||||||
| 135 | 975 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
_handle_unknown: called CC=22 SCAR=37.9
| |||||||||||||||||||||||||||||||||||
| 136 | 975 | my $result = shift; | |||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||
| 138 | 975 | my $raw = $result->raw; | |||||||||||||||||||||||||||||||||
| 139 | 975 | ▶ | if ( $raw =~ /^\s*# Subtest: (.*)$/ ) { | ||||||||||||||||||||||||||||||||
|
Branch: 7 branches
| |||||||||||||||||||||||||||||||||||
| 140 | 0 | $self->_test_finished; | |||||||||||||||||||||||||||||||||
| 141 | 0 | $self->_start_suite($1); | |||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||
| 143 | # We want progress messages for each top-level subtest, but not for | ||||||||||||||||||||||||||||||||||
| 144 | # any subtests they might contain. | ||||||||||||||||||||||||||||||||||
| 145 | 0 | ▶ | if ( $self->_is_parallel && @{ $self->_tc_suite_name_stack } == 2 ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->_is_parallel and @{$self->_tc_suite_name_stack;} == 2
MC/DC0%0/2
$self->_is_parallel and @{$self->_tc_suite_name_stack;} == 2
$self->_is_parallel
@{$self->_tc_suite_name_stack;} == 2
Truth table0%0/3
A and B
A= $self->_is_parallelB= @{$self->_tc_suite_name_stack;} == 2
| |||||||||||||||||||||||||||||||||||
| 146 | 0 | my $name = join q{ - }, @{ $self->_tc_suite_name_stack }; | |||||||||||||||||||||||||||||||||
| 147 | 0 | $self->_tc_message( | |||||||||||||||||||||||||||||||||
| 148 | 'progressMessage', | ||||||||||||||||||||||||||||||||||
| 149 | "starting $name", | ||||||||||||||||||||||||||||||||||
| 150 | 1, | ||||||||||||||||||||||||||||||||||
| 151 | ); | ||||||||||||||||||||||||||||||||||
| 152 | } | ||||||||||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||||||||
| 154 | elsif ( $raw =~ /^\s*(not )?ok (\d+)( - (.*))?$/ ) { | ||||||||||||||||||||||||||||||||||
| 155 | 102 | my $is_ok = !$1; | |||||||||||||||||||||||||||||||||
| 156 | 102 | my $test_num = $2; | |||||||||||||||||||||||||||||||||
| 157 | 102 | my $test_name = $4; | |||||||||||||||||||||||||||||||||
| 158 | 102 | $self->_test_finished; | |||||||||||||||||||||||||||||||||
| 159 | 102 | ▶ | $test_name = 'NO TEST NAME' unless defined $test_name; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||
| 161 | 102 | my $todo; | |||||||||||||||||||||||||||||||||
| 162 | 102 | ▶ | if ( $test_name =~ s/ # TODO (.+)$// ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 163 | 6 | $todo = $1; | |||||||||||||||||||||||||||||||||
| 164 | } | ||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||
| 166 | 102 | my $f = $self->_finish_suite($test_name); | |||||||||||||||||||||||||||||||||
| 167 | 102 | ▶ | unless ($f) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 168 | 102 | ▶ | my $ok = $is_ok || $todo ? 'ok' : 'not ok'; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$is_ok or $todo
MC/DC100%2/2
$is_ok or $todo
$is_ok
$todo
Truth table100%3/3
A or B
A= $is_okB= $todo
| |||||||||||||||||||||||||||||||||||
| 169 | 102 | ▶ | my $actual_result = TAP::Parser::Result::Test->new( | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
$todo // ""
MC/DC100%1/1
$todo // ""
$todo
Truth table100%2/2
A
A= $todo
| |||||||||||||||||||||||||||||||||||
| 170 | { | ||||||||||||||||||||||||||||||||||
| 171 | 'ok' => $ok, | ||||||||||||||||||||||||||||||||||
| 172 | 'explanation' => $todo // q{}, | ||||||||||||||||||||||||||||||||||
| 173 | 'directive' => $todo ? 'TODO' : q{}, | ||||||||||||||||||||||||||||||||||
| 174 | 'type' => 'test', | ||||||||||||||||||||||||||||||||||
| 175 | 'test_num' => $test_num, | ||||||||||||||||||||||||||||||||||
| 176 | 'description' => "- $test_name", | ||||||||||||||||||||||||||||||||||
| 177 | 'raw' => "$ok $test_num - $test_name", | ||||||||||||||||||||||||||||||||||
| 178 | } | ||||||||||||||||||||||||||||||||||
| 179 | ); | ||||||||||||||||||||||||||||||||||
| 180 | 102 | $self->_test_started($actual_result); | |||||||||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||||||||
| 183 | elsif ( $raw =~ /^\s*# Looks like you failed \d+/ ) { | ||||||||||||||||||||||||||||||||||
| 184 | 0 | $self->_test_finished; | |||||||||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||||||||
| 186 | ▶ | elsif ( $raw =~ /^\s+ok \d+ # skip (.*)$/ | |||||||||||||||||||||||||||||||||
|
Condition33%1/3
$raw =~ /^\s+ok \d+ # skip (.*)$/ and not $self->_tc_last_test_result
MC/DC0%0/2
$raw =~ /^\s+ok \d+ # skip (.*)$/ and not $self->_tc_last_test_result
$raw =~ /^\s+ok \d+ # skip (.*)$/
not $self->_tc_last_test_result
Truth table33%1/3
A and not(B)
A= $raw =~ /^\s+ok \d+ # skip (.*)$/B= not $self->_tc_last_test_result
| |||||||||||||||||||||||||||||||||||
| 187 | && !$self->_tc_last_test_result ) { | ||||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||||
| 189 | # when tcm skips methods, we get 1st a Subtest message | ||||||||||||||||||||||||||||||||||
| 190 | # then "ok $num # skip $message" | ||||||||||||||||||||||||||||||||||
| 191 | 0 | my $reason = $1; | |||||||||||||||||||||||||||||||||
| 192 | 0 | $self->_tc_message( | |||||||||||||||||||||||||||||||||
| 193 | 'testStarted', | ||||||||||||||||||||||||||||||||||
| 194 | { | ||||||||||||||||||||||||||||||||||
| 195 | name => 'Skipped', | ||||||||||||||||||||||||||||||||||
| 196 | captureStandardOutput => 'true' | ||||||||||||||||||||||||||||||||||
| 197 | }, | ||||||||||||||||||||||||||||||||||
| 198 | ); | ||||||||||||||||||||||||||||||||||
| 199 | 0 | $self->_tc_message( | |||||||||||||||||||||||||||||||||
| 200 | 'testIgnored', | ||||||||||||||||||||||||||||||||||
| 201 | { | ||||||||||||||||||||||||||||||||||
| 202 | name => 'Skipped', | ||||||||||||||||||||||||||||||||||
| 203 | message => $reason, | ||||||||||||||||||||||||||||||||||
| 204 | }, | ||||||||||||||||||||||||||||||||||
| 205 | ); | ||||||||||||||||||||||||||||||||||
| 206 | 0 | $self->_finish_test('Skipped'); | |||||||||||||||||||||||||||||||||
| 207 | 0 | $self->_finish_suite; | |||||||||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||||||||
| 209 | elsif ( $raw =~ /^\s*#/ ) { | ||||||||||||||||||||||||||||||||||
| 210 | 36 | ( my $clean_raw = $raw ) =~ s/^\s*#\s?//; | |||||||||||||||||||||||||||||||||
| 211 | 36 | $clean_raw =~ s/\s+$//; | |||||||||||||||||||||||||||||||||
| 212 | 36 | ▶ | return if $clean_raw =~ /^\s*$/; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 213 | 36 | ▶ | $self->_tc_test_output_buffer( | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 214 | $self->_tc_test_output_buffer . "$clean_raw\n" ) | ||||||||||||||||||||||||||||||||||
| 215 | if $self->_tc_last_test_result; | ||||||||||||||||||||||||||||||||||
| 216 | 36 | $self->_maybe_print_raw( $result->raw ); | |||||||||||||||||||||||||||||||||
| 217 | } | ||||||||||||||||||||||||||||||||||
| 218 | ▶ | elsif ($raw =~ qr{\[checked\] .+$} | |||||||||||||||||||||||||||||||||
|
Condition33%1/3
$raw =~ qr/\[checked\] .+$/ or $raw =~ qr/Deep recursion on subroutine "B::Deparse/
MC/DC0%0/2
$raw =~ qr/\[checked\] .+$/ or $raw =~ qr/Deep recursion on subroutine "B::Deparse/
$raw =~ qr/\[checked\] .+$/
$raw =~ qr/Deep recursion on subroutine "B::Deparse/
Truth table33%1/3
A or B
A= $raw =~ qr/\[checked\] .+$/B= $raw =~ qr/Deep recursion on subroutine "B::Deparse/
| |||||||||||||||||||||||||||||||||||
| 219 | or $raw =~ qr{Deep recursion on subroutine "B::Deparse} ) { | ||||||||||||||||||||||||||||||||||
| 220 | 0 | $self->_maybe_print_raw("# $raw\n"); | |||||||||||||||||||||||||||||||||
| 221 | } | ||||||||||||||||||||||||||||||||||
| 222 | elsif ( $raw !~ /^\s*$/ ) { | ||||||||||||||||||||||||||||||||||
| 223 | 723 | $self->_tc_suite_output_buffer( | |||||||||||||||||||||||||||||||||
| 224 | $self->_tc_suite_output_buffer . $raw ); | ||||||||||||||||||||||||||||||||||
| 225 | 723 | ▶ | $self->_maybe_print_raw( $result->raw ) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 226 | unless $raw =~ /^\s*\d+\.\.\d+(?: # SKIP.*)?$/; | ||||||||||||||||||||||||||||||||||
| 227 | } | ||||||||||||||||||||||||||||||||||
| 228 | } | ||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||
| 230 | ## no critic (Subroutines::ProhibitUnusedPrivateSubroutines) | ||||||||||||||||||||||||||||||||||
| 231 | sub _handle_plan { | ||||||||||||||||||||||||||||||||||
| 232 | 36 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
_handle_plan: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||
| 233 | 36 | my $result = shift; | |||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||||
| 235 | 36 | ▶ | unless ( $self->_test_finished ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 236 | 18 | ▶ | if ( $result->directive eq 'SKIP' ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 237 | 3 | $self->_tc_message( | |||||||||||||||||||||||||||||||||
| 238 | 'testStarted', | ||||||||||||||||||||||||||||||||||
| 239 | { | ||||||||||||||||||||||||||||||||||
| 240 | name => 'Skipped', | ||||||||||||||||||||||||||||||||||
| 241 | captureStandardOutput => 'true', | ||||||||||||||||||||||||||||||||||
| 242 | }, | ||||||||||||||||||||||||||||||||||
| 243 | ); | ||||||||||||||||||||||||||||||||||
| 244 | 3 | $self->_tc_message( | |||||||||||||||||||||||||||||||||
| 245 | 'testIgnored', | ||||||||||||||||||||||||||||||||||
| 246 | { | ||||||||||||||||||||||||||||||||||
| 247 | name => 'Skipped', | ||||||||||||||||||||||||||||||||||
| 248 | message => $result->explanation, | ||||||||||||||||||||||||||||||||||
| 249 | }, | ||||||||||||||||||||||||||||||||||
| 250 | ); | ||||||||||||||||||||||||||||||||||
| 251 | 3 | $self->_finish_test('Skipped'); | |||||||||||||||||||||||||||||||||
| 252 | } | ||||||||||||||||||||||||||||||||||
| 253 | } | ||||||||||||||||||||||||||||||||||
| 254 | } | ||||||||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||||||||
| 256 | sub _test_started { | ||||||||||||||||||||||||||||||||||
| 257 | 168 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
_test_started: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 258 | 168 | my $result = shift; | |||||||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||||||||
| 260 | 168 | my $test_name = $self->_compute_test_name($result); | |||||||||||||||||||||||||||||||||
| 261 | 168 | $self->_tc_message( | |||||||||||||||||||||||||||||||||
| 262 | 'testStarted', | ||||||||||||||||||||||||||||||||||
| 263 | { | ||||||||||||||||||||||||||||||||||
| 264 | name => $test_name, | ||||||||||||||||||||||||||||||||||
| 265 | captureStandardOutput => 'true', | ||||||||||||||||||||||||||||||||||
| 266 | }, | ||||||||||||||||||||||||||||||||||
| 267 | ); | ||||||||||||||||||||||||||||||||||
| 268 | 168 | $self->_tc_last_test_name($test_name); | |||||||||||||||||||||||||||||||||
| 269 | 168 | $self->_tc_last_test_result($result); | |||||||||||||||||||||||||||||||||
| 270 | } | ||||||||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||||||||
| 272 | sub _test_finished { | ||||||||||||||||||||||||||||||||||
| 273 | 261 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
_test_finished: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||||
| 275 | 261 | ▶ | return unless $self->_tc_last_test_result; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 276 | 168 | $self->_emit_teamcity_test_results( | |||||||||||||||||||||||||||||||||
| 277 | $self->_tc_last_test_name, | ||||||||||||||||||||||||||||||||||
| 278 | $self->_tc_last_test_result | ||||||||||||||||||||||||||||||||||
| 279 | ); | ||||||||||||||||||||||||||||||||||
| 280 | 168 | $self->_finish_test( $self->_tc_last_test_name ); | |||||||||||||||||||||||||||||||||
| 281 | 168 | return 1; | |||||||||||||||||||||||||||||||||
| 282 | } | ||||||||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||||||||
| 284 | sub _emit_teamcity_test_results { | ||||||||||||||||||||||||||||||||||
| 285 | 168 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
_emit_teamcity_test_results: called CC=6 SCAR=18.0
| |||||||||||||||||||||||||||||||||||
| 286 | 168 | my $test_name = shift; | |||||||||||||||||||||||||||||||||
| 287 | 168 | my $result = shift; | |||||||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||||||||
| 289 | 168 | my $buffer = $self->_tc_test_output_buffer; | |||||||||||||||||||||||||||||||||
| 290 | 168 | $self->_tc_test_output_buffer(q{}); | |||||||||||||||||||||||||||||||||
| 291 | 168 | chomp $buffer; | |||||||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||||||||
| 293 | 168 | ▶ | if ( $result->has_todo || $result->has_skip ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$result->has_todo or $result->has_skip
MC/DC50%1/2
$result->has_todo or $result->has_skip
$result->has_todo
$result->has_skip
Truth table66%2/3
A or B
A= $result->has_todoB= $result->has_skip
| |||||||||||||||||||||||||||||||||||
| 294 | 6 | $self->_tc_message( | |||||||||||||||||||||||||||||||||
| 295 | 'testIgnored', | ||||||||||||||||||||||||||||||||||
| 296 | { | ||||||||||||||||||||||||||||||||||
| 297 | name => $test_name, | ||||||||||||||||||||||||||||||||||
| 298 | message => $result->explanation, | ||||||||||||||||||||||||||||||||||
| 299 | }, | ||||||||||||||||||||||||||||||||||
| 300 | ); | ||||||||||||||||||||||||||||||||||
| 301 | 6 | return; | |||||||||||||||||||||||||||||||||
| 302 | } | ||||||||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||||||||
| 304 | 162 | ▶ | unless ( $result->is_ok ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 305 | 45 | ▶ | $self->_tc_message( | ||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||
| 306 | 'testFailed', | ||||||||||||||||||||||||||||||||||
| 307 | { | ||||||||||||||||||||||||||||||||||
| 308 | name => $test_name, | ||||||||||||||||||||||||||||||||||
| 309 | message => ( $result->is_ok ? 'ok' : 'not ok' ), | ||||||||||||||||||||||||||||||||||
| 310 | ( $buffer ? ( details => $buffer ) : () ), | ||||||||||||||||||||||||||||||||||
| 311 | }, | ||||||||||||||||||||||||||||||||||
| 312 | ); | ||||||||||||||||||||||||||||||||||
| 313 | } | ||||||||||||||||||||||||||||||||||
| 314 | } | ||||||||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||||||||
| 316 | sub _compute_test_name { | ||||||||||||||||||||||||||||||||||
| 317 | 216 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
_compute_test_name: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||
| 318 | 216 | my $result = shift; | |||||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||||||
| 320 | 216 | my $description = $result->description; | |||||||||||||||||||||||||||||||||
| 321 | 216 | ▶ | my $test_name = $description eq q{} ? $result->explanation : $description; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 322 | 216 | $test_name =~ s/^-\s//; | |||||||||||||||||||||||||||||||||
| 323 | 216 | ▶ | $test_name = 'NO TEST NAME' if $test_name eq q{}; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 324 | 216 | return $test_name; | |||||||||||||||||||||||||||||||||
| 325 | } | ||||||||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||||||||
| 327 | sub _maybe_print_raw { | ||||||||||||||||||||||||||||||||||
| 328 | 753 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
_maybe_print_raw: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||
| 329 | 753 | my $raw = shift; | |||||||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||||||||
| 331 | 753 | ▶ | if ( $self->_is_parallel ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 332 | 251 | $self->_tc_test_output_buffer( | |||||||||||||||||||||||||||||||||
| 333 | $self->_tc_test_output_buffer . "$raw\n" ); | ||||||||||||||||||||||||||||||||||
| 334 | } | ||||||||||||||||||||||||||||||||||
| 335 | else { | ||||||||||||||||||||||||||||||||||
| 336 | 502 | ▶ | print "$raw\n" or die "Can't print to STDOUT: $!"; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 337 | } | ||||||||||||||||||||||||||||||||||
| 338 | } | ||||||||||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||||||||
| 340 | sub _finish_test { | ||||||||||||||||||||||||||||||||||
| 341 | 171 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
_finish_test: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 342 | 171 | my $test_name = shift; | |||||||||||||||||||||||||||||||||
| 343 | |||||||||||||||||||||||||||||||||||
| 344 | 171 | $self->_tc_message( 'testFinished', { name => $test_name } ); | |||||||||||||||||||||||||||||||||
| 345 | 171 | $self->_tc_last_test_name(undef); | |||||||||||||||||||||||||||||||||
| 346 | 171 | $self->_tc_last_test_result(undef); | |||||||||||||||||||||||||||||||||
| 347 | 171 | $self->_tc_is_last_suite_empty(0); | |||||||||||||||||||||||||||||||||
| 348 | } | ||||||||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||||||||
| 350 | sub _start_suite { | ||||||||||||||||||||||||||||||||||
| 351 | 48 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
_start_suite: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 352 | 48 | my $suite_name = shift; | |||||||||||||||||||||||||||||||||
| 353 | |||||||||||||||||||||||||||||||||||
| 354 | 48 | push @{ $self->_tc_suite_name_stack }, $suite_name; | |||||||||||||||||||||||||||||||||
| 355 | 48 | $self->_tc_is_last_suite_empty(1); | |||||||||||||||||||||||||||||||||
| 356 | 48 | $self->_tc_message( 'testSuiteStarted', { name => $suite_name } ); | |||||||||||||||||||||||||||||||||
| 357 | } | ||||||||||||||||||||||||||||||||||
| 358 | |||||||||||||||||||||||||||||||||||
| 359 | sub close_test { | ||||||||||||||||||||||||||||||||||
| 360 | 48 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
close_test: called CC=8 SCAR=20.8
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||||||||
| 362 | 48 | my $no_tests_message | |||||||||||||||||||||||||||||||||
| 363 | = 'Tests were run but no plan was declared and done_testing'; | ||||||||||||||||||||||||||||||||||
| 364 | 48 | ▶ | if ( $self->_tc_test_output_buffer | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 365 | =~ /^$no_tests_message\(\) was not seen\.$/m ) { | ||||||||||||||||||||||||||||||||||
| 366 | 6 | $self->_recover_from_catastrophic_death; | |||||||||||||||||||||||||||||||||
| 367 | } | ||||||||||||||||||||||||||||||||||
| 368 | else { | ||||||||||||||||||||||||||||||||||
| 369 | 42 | ▶ | if ( !$self->_test_finished && $self->_tc_suite_output_buffer ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not $self->_test_finished and $self->_tc_suite_output_buffer
MC/DC100%2/2
not $self->_test_finished and $self->_tc_suite_output_buffer
not $self->_test_finished
$self->_tc_suite_output_buffer
Truth table100%3/3
not(A) and B
A= not $self->_test_finishedB= $self->_tc_suite_output_buffer
| |||||||||||||||||||||||||||||||||||
| 370 | my $suite_type | ||||||||||||||||||||||||||||||||||
| 371 | 15 | ▶ | = @{ $self->_tc_suite_name_stack } == 1 | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 372 | ? 'file' | ||||||||||||||||||||||||||||||||||
| 373 | : 'subtest'; | ||||||||||||||||||||||||||||||||||
| 374 | 15 | my $test_name = "Test died before reaching end of $suite_type"; | |||||||||||||||||||||||||||||||||
| 375 | 15 | my $test_result = TAP::Parser::Result::Test->new( | |||||||||||||||||||||||||||||||||
| 376 | { | ||||||||||||||||||||||||||||||||||
| 377 | 'ok' => 'not ok', | ||||||||||||||||||||||||||||||||||
| 378 | 'explanation' => q{}, | ||||||||||||||||||||||||||||||||||
| 379 | 'directive' => q{}, | ||||||||||||||||||||||||||||||||||
| 380 | 'type' => 'test', | ||||||||||||||||||||||||||||||||||
| 381 | 'test_num' => 1, | ||||||||||||||||||||||||||||||||||
| 382 | 'description' => "- $test_name", | ||||||||||||||||||||||||||||||||||
| 383 | 'raw' => "not ok 1 - $test_name", | ||||||||||||||||||||||||||||||||||
| 384 | } | ||||||||||||||||||||||||||||||||||
| 385 | ); | ||||||||||||||||||||||||||||||||||
| 386 | 15 | $self->_test_started($test_result); | |||||||||||||||||||||||||||||||||
| 387 | 15 | $self->_tc_test_output_buffer( $self->_tc_suite_output_buffer ); | |||||||||||||||||||||||||||||||||
| 388 | 15 | $self->_tc_suite_output_buffer(q{}); | |||||||||||||||||||||||||||||||||
| 389 | 15 | $self->_test_finished; | |||||||||||||||||||||||||||||||||
| 390 | } | ||||||||||||||||||||||||||||||||||
| 391 | { | ||||||||||||||||||||||||||||||||||
| 392 | 42 | my @copy = @{ $self->_tc_suite_name_stack }; | |||||||||||||||||||||||||||||||||
| 393 | 42 | $self->_finish_suite for @copy; | |||||||||||||||||||||||||||||||||
| 394 | } | ||||||||||||||||||||||||||||||||||
| 395 | } | ||||||||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||||||||
| 397 | 48 | ▶ | if ( $self->_is_parallel ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 398 | 16 | ▶ | print ${ $self->_tc_buffered_output } | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 399 | or die $!; | ||||||||||||||||||||||||||||||||||
| 400 | } | ||||||||||||||||||||||||||||||||||
| 401 | } | ||||||||||||||||||||||||||||||||||
| 402 | |||||||||||||||||||||||||||||||||||
| 403 | sub _recover_from_catastrophic_death { | ||||||||||||||||||||||||||||||||||
| 404 | 6 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
_recover_from_catastrophic_death: called CC=4 SCAR=16.5
| |||||||||||||||||||||||||||||||||||
| 405 | |||||||||||||||||||||||||||||||||||
| 406 | 6 | ▶ | if ( $self->_tc_last_test_result ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 407 | 6 | my $test_num = $self->_tc_last_test_result->number; | |||||||||||||||||||||||||||||||||
| 408 | 6 | my $description = $self->_tc_last_test_result->description; | |||||||||||||||||||||||||||||||||
| 409 | 6 | $self->_tc_last_test_result( | |||||||||||||||||||||||||||||||||
| 410 | TAP::Parser::Result::Test->new( | ||||||||||||||||||||||||||||||||||
| 411 | { | ||||||||||||||||||||||||||||||||||
| 412 | 'ok' => 'not ok', | ||||||||||||||||||||||||||||||||||
| 413 | 'explanation' => q{}, | ||||||||||||||||||||||||||||||||||
| 414 | 'directive' => q{}, | ||||||||||||||||||||||||||||||||||
| 415 | 'type' => 'test', | ||||||||||||||||||||||||||||||||||
| 416 | 'test_num' => $test_num, | ||||||||||||||||||||||||||||||||||
| 417 | 'description' => "- $description", | ||||||||||||||||||||||||||||||||||
| 418 | 'raw' => "not ok $test_num - $description", | ||||||||||||||||||||||||||||||||||
| 419 | } | ||||||||||||||||||||||||||||||||||
| 420 | ) | ||||||||||||||||||||||||||||||||||
| 421 | ); | ||||||||||||||||||||||||||||||||||
| 422 | } | ||||||||||||||||||||||||||||||||||
| 423 | else { | ||||||||||||||||||||||||||||||||||
| 424 | my $suite_type | ||||||||||||||||||||||||||||||||||
| 425 | 0 | ▶ | = @{ $self->_tc_suite_name_stack } == 1 ? 'file' : 'subtest'; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 426 | 0 | my $test_name = "Test died before reaching end of $suite_type"; | |||||||||||||||||||||||||||||||||
| 427 | 0 | my $test_result = TAP::Parser::Result::Test->new( | |||||||||||||||||||||||||||||||||
| 428 | { | ||||||||||||||||||||||||||||||||||
| 429 | 'ok' => 'not ok', | ||||||||||||||||||||||||||||||||||
| 430 | 'explanation' => q{}, | ||||||||||||||||||||||||||||||||||
| 431 | 'directive' => q{}, | ||||||||||||||||||||||||||||||||||
| 432 | 'type' => 'test', | ||||||||||||||||||||||||||||||||||
| 433 | 'test_num' => 1, | ||||||||||||||||||||||||||||||||||
| 434 | 'description' => "- $test_name", | ||||||||||||||||||||||||||||||||||
| 435 | 'raw' => "not ok 1 - $test_name", | ||||||||||||||||||||||||||||||||||
| 436 | } | ||||||||||||||||||||||||||||||||||
| 437 | ); | ||||||||||||||||||||||||||||||||||
| 438 | 0 | $self->_test_started($test_result); | |||||||||||||||||||||||||||||||||
| 439 | } | ||||||||||||||||||||||||||||||||||
| 440 | 6 | $self->_test_finished; | |||||||||||||||||||||||||||||||||
| 441 | { | ||||||||||||||||||||||||||||||||||
| 442 | 6 | my @copy = @{ $self->_tc_suite_name_stack }; | |||||||||||||||||||||||||||||||||
| 443 | 6 | $self->_finish_suite for @copy; | |||||||||||||||||||||||||||||||||
| 444 | } | ||||||||||||||||||||||||||||||||||
| 445 | } | ||||||||||||||||||||||||||||||||||
| 446 | |||||||||||||||||||||||||||||||||||
| 447 | sub _finish_suite { | ||||||||||||||||||||||||||||||||||
| 448 | 198 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
_finish_suite: called CC=6 SCAR=18.0
| |||||||||||||||||||||||||||||||||||
| 449 | 198 | my $name = shift; | |||||||||||||||||||||||||||||||||
| 450 | |||||||||||||||||||||||||||||||||||
| 451 | 198 | ▶ | return 0 unless @{ $self->_tc_suite_name_stack }; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 452 | |||||||||||||||||||||||||||||||||||
| 453 | 198 | ▶ | $name //= $self->_tc_suite_name_stack->[-1]; | ||||||||||||||||||||||||||||||||
|
Condition66%2/3
$name //= $self->_tc_suite_name_stack->[-1]
MC/DC0%0/2
$name //= $self->_tc_suite_name_stack->[-1]
$name
$self->_tc_suite_name_stack->[-1]
Truth table66%2/3
A //= B
A= $nameB= $self->_tc_suite_name_stack->[-1]
| |||||||||||||||||||||||||||||||||||
| 454 | |||||||||||||||||||||||||||||||||||
| 455 | 198 | my $result = $name eq $self->_tc_suite_name_stack->[-1]; | |||||||||||||||||||||||||||||||||
| 456 | 198 | ▶ | if ($result) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 457 | 48 | ▶ | if ( $self->_tc_is_last_suite_empty ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 458 | my $suite_type | ||||||||||||||||||||||||||||||||||
| 459 | 3 | ▶ | = @{ $self->_tc_suite_name_stack } == 1 ? 'file' : 'subtest'; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 460 | 3 | my $test_name = "Test died before reaching end of $suite_type"; | |||||||||||||||||||||||||||||||||
| 461 | 3 | my $test_result = TAP::Parser::Result::Test->new( | |||||||||||||||||||||||||||||||||
| 462 | { | ||||||||||||||||||||||||||||||||||
| 463 | 'ok' => 'not ok', | ||||||||||||||||||||||||||||||||||
| 464 | 'explanation' => q{}, | ||||||||||||||||||||||||||||||||||
| 465 | 'directive' => q{}, | ||||||||||||||||||||||||||||||||||
| 466 | 'type' => 'test', | ||||||||||||||||||||||||||||||||||
| 467 | 'test_num' => 1, | ||||||||||||||||||||||||||||||||||
| 468 | 'description' => "- $test_name", | ||||||||||||||||||||||||||||||||||
| 469 | 'raw' => "not ok 1 - $test_name", | ||||||||||||||||||||||||||||||||||
| 470 | } | ||||||||||||||||||||||||||||||||||
| 471 | ); | ||||||||||||||||||||||||||||||||||
| 472 | 3 | $self->_test_started($test_result); | |||||||||||||||||||||||||||||||||
| 473 | 3 | $self->_tc_test_output_buffer( $self->_tc_suite_output_buffer ); | |||||||||||||||||||||||||||||||||
| 474 | 3 | $self->_tc_suite_output_buffer(q{}); | |||||||||||||||||||||||||||||||||
| 475 | 3 | $self->_test_finished; | |||||||||||||||||||||||||||||||||
| 476 | } | ||||||||||||||||||||||||||||||||||
| 477 | 48 | pop @{ $self->_tc_suite_name_stack }; | |||||||||||||||||||||||||||||||||
| 478 | 48 | $self->_tc_suite_output_buffer(q{}); | |||||||||||||||||||||||||||||||||
| 479 | 48 | $self->_tc_is_last_suite_empty(0); | |||||||||||||||||||||||||||||||||
| 480 | 48 | $self->_tc_message( 'testSuiteFinished', { name => $name } ); | |||||||||||||||||||||||||||||||||
| 481 | } | ||||||||||||||||||||||||||||||||||
| 482 | 198 | return $result; | |||||||||||||||||||||||||||||||||
| 483 | } | ||||||||||||||||||||||||||||||||||
| 484 | |||||||||||||||||||||||||||||||||||
| 485 | sub _tc_message { | ||||||||||||||||||||||||||||||||||
| 486 | 508 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
_tc_message: called CC=8 SCAR=21.2
| |||||||||||||||||||||||||||||||||||
| 487 | 508 | my $message = shift; | |||||||||||||||||||||||||||||||||
| 488 | 508 | my $values = shift; | |||||||||||||||||||||||||||||||||
| 489 | 508 | my $force_stdout = shift; | |||||||||||||||||||||||||||||||||
| 490 | |||||||||||||||||||||||||||||||||||
| 491 | 508 | ▶ | my $handle = $force_stdout ? \*STDOUT : $self->_tc_output_handle; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 492 | |||||||||||||||||||||||||||||||||||
| 493 | 508 | my $tc_msg = "##teamcity[$message"; | |||||||||||||||||||||||||||||||||
| 494 | |||||||||||||||||||||||||||||||||||
| 495 | 508 | ▶ | if ( ref $values ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 496 | 492 | for my $name ( sort keys %{$values} ) { | |||||||||||||||||||||||||||||||||
| 497 | 750 | my $value = $values->{$name}; | |||||||||||||||||||||||||||||||||
| 498 | 750 | $tc_msg .= qq{ $name='} . _tc_escape($value) . q{'}; | |||||||||||||||||||||||||||||||||
| 499 | } | ||||||||||||||||||||||||||||||||||
| 500 | |||||||||||||||||||||||||||||||||||
| 501 | $tc_msg .= $self->_tc_message_timestamp | ||||||||||||||||||||||||||||||||||
| 502 | 492 | ▶ | unless ref $values && $values->{timestamp}; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
ref $values and $values->{"timestamp"}
MC/DC0%0/2
ref $values and $values->{"timestamp"}
ref $values
$values->{"timestamp"}
Truth table33%1/3
A and B
A= ref $valuesB= $values->{"timestamp"}
| |||||||||||||||||||||||||||||||||||
| 503 | } | ||||||||||||||||||||||||||||||||||
| 504 | else { | ||||||||||||||||||||||||||||||||||
| 505 | 16 | ▶ | $tc_msg .= q{ '} . _tc_escape($values) . q{'} or die $!; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 506 | } | ||||||||||||||||||||||||||||||||||
| 507 | |||||||||||||||||||||||||||||||||||
| 508 | 508 | $tc_msg .= "]\n"; | |||||||||||||||||||||||||||||||||
| 509 | |||||||||||||||||||||||||||||||||||
| 510 | 508 | ▶ | print {$handle} $tc_msg or die $!; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 511 | |||||||||||||||||||||||||||||||||||
| 512 | 508 | return; | |||||||||||||||||||||||||||||||||
| 513 | } | ||||||||||||||||||||||||||||||||||
| 514 | |||||||||||||||||||||||||||||||||||
| 515 | sub _tc_message_timestamp { | ||||||||||||||||||||||||||||||||||
| 516 | 492 | ▶ | my $now = time; | ||||||||||||||||||||||||||||||||
|
Subroutine
_tc_message_timestamp: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 517 | |||||||||||||||||||||||||||||||||||
| 518 | 492 | my ( $s, $mi, $h, $d, $mo, $y ) = ( gmtime($now) )[ 0 .. 5 ]; | |||||||||||||||||||||||||||||||||
| 519 | |||||||||||||||||||||||||||||||||||
| 520 | 492 | my $float = ( $now - int($now) ); | |||||||||||||||||||||||||||||||||
| 521 | 492 | return sprintf( | |||||||||||||||||||||||||||||||||
| 522 | q{ timestamp='%4d-%02d-%02dT%02d:%02d:%02d.%03d'}, | ||||||||||||||||||||||||||||||||||
| 523 | $y + 1900, $mo + 1, $d, | ||||||||||||||||||||||||||||||||||
| 524 | $h, $mi, $s, | ||||||||||||||||||||||||||||||||||
| 525 | |||||||||||||||||||||||||||||||||||
| 526 | # We only need 3 places of precision so if we multiply it be 1,000 we | ||||||||||||||||||||||||||||||||||
| 527 | # can just treat it as an integer. | ||||||||||||||||||||||||||||||||||
| 528 | $float * 1000, | ||||||||||||||||||||||||||||||||||
| 529 | ); | ||||||||||||||||||||||||||||||||||
| 530 | } | ||||||||||||||||||||||||||||||||||
| 531 | |||||||||||||||||||||||||||||||||||
| 532 | sub _tc_escape { | ||||||||||||||||||||||||||||||||||
| 533 | 766 | ▶ | my $str = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
_tc_escape: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 534 | |||||||||||||||||||||||||||||||||||
| 535 | 766 | ( my $esc = $str ) =~ s{(['|\]])}{|$1}g; | |||||||||||||||||||||||||||||||||
| 536 | 766 | $esc =~ s{\n}{|n}g; | |||||||||||||||||||||||||||||||||
| 537 | 766 | $esc =~ s{\r}{|r}g; | |||||||||||||||||||||||||||||||||
| 538 | |||||||||||||||||||||||||||||||||||
| 539 | 766 | return $esc; | |||||||||||||||||||||||||||||||||
| 540 | } | ||||||||||||||||||||||||||||||||||
| 541 | |||||||||||||||||||||||||||||||||||
| 542 | 18 | 1; | |||||||||||||||||||||||||||||||||
| 543 | |||||||||||||||||||||||||||||||||||
| 544 | __END__ | ||||||||||||||||||||||||||||||||||
| 545 | |||||||||||||||||||||||||||||||||||
| 546 | =pod | ||||||||||||||||||||||||||||||||||
| 547 | |||||||||||||||||||||||||||||||||||
| 548 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||
| 549 | |||||||||||||||||||||||||||||||||||
| 550 | This module provides the core internals for turning TAP into TeamCity | ||||||||||||||||||||||||||||||||||
| 551 | messages. There are no user-serviceable parts in here. | ||||||||||||||||||||||||||||||||||
| 552 | |||||||||||||||||||||||||||||||||||
| 553 | =cut | ||||||||||||||||||||||||||||||||||