blib/lib/Test/Harness.pm

filter: Statementstmt 55.9% 188 / 336 Branchbran 40.3% 50 / 124 Conditioncond 42.7% 50 / 117 MC/DCmcdc 27.8% 17 / 61 Subroutinesub 65.1% 28 / 43 Podpod 100% 4 / 4 totaltotal 49.2% 337 / 685 CC 111 SCAR 37.2
CC
111
Cov
50%
_new_harness
84.8
_new_harness
84.8
execute_tests
73.5
CRAP 41.4
« blib/lib/TAP/Harness/Env.pm ↑ Summary blib/lib/TAP/Formatter/Console/ParallelSession.pm »
1 package Test::Harness;
2  
3 11 ▶use 5.006;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 11 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 11 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 11 ▶use constant IS_WIN32 => ( $^O =~ /^(MS)?Win32$/ );
Subroutine BEGIN: called CC=1 SCAR=0.0
9 11 ▶use constant IS_VMS => ( $^O eq 'VMS' );
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 11 ▶use TAP::Harness ();
Subroutine BEGIN: called CC=1 SCAR=0.0
12 11 ▶use TAP::Parser::Aggregator ();
Subroutine BEGIN: called CC=1 SCAR=0.0
13 11 ▶use TAP::Parser::Source ();
Subroutine BEGIN: called CC=1 SCAR=0.0
14 11 ▶use TAP::Parser::SourceHandler::Perl ();
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 11 ▶use Text::ParseWords qw(shellwords);
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 11 ▶use Config;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 11 ▶use base 'Exporter';
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 # $ML $Last_ML_Print
22  
23 11 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
24 11 ▶ eval q{use Time::HiRes 'time'};
Subroutine BEGIN: called CC=1 SCAR=0.0
25 11 our $has_time_hires = !$@;
26 }
27  
28 =head1 NAME
29  
30 Test::Harness - Run Perl standard test scripts with statistics
31  
32 =head1 VERSION
33  
34 Version 3.52
35  
36 =cut
37  
38 11 our $VERSION = '3.52';
39  
40 # Backwards compatibility for exportable variable names.
41 11 *verbose = *Verbose;
42 11 *switches = *Switches;
43 11 *debug = *Debug;
44  
45 11 $ENV{HARNESS_ACTIVE} = 1;
46 11 $ENV{HARNESS_VERSION} = $VERSION;
47  
48 10 ▶END {
Subroutine END: called CC=1 SCAR=1.2
49  
50 # For VMS.
51 0 ▶ delete $ENV{HARNESS_ACTIVE};
Subroutine END: not called CC=1 SCAR=1.2
52 0 delete $ENV{HARNESS_VERSION};
53 }
54  
55 11 our @EXPORT = qw(&runtests);
56 11 our @EXPORT_OK = qw(&execute_tests $verbose $switches);
57  
58 11 ▶our $Verbose = $ENV{HARNESS_VERBOSE} || 0;
Condition50%1/2
$ENV{'HARNESS_VERBOSE'} || 0
l!l
011
MC/DC0%0/1
$ENV{'HARNESS_VERBOSE'} || 0
$ENV{'HARNESS_VERBOSE'}
Truth table50%1/2
A
A= $ENV{'HARNESS_VERBOSE'}
Aresult
11
00
59 11 ▶our $Debug = $ENV{HARNESS_DEBUG} || 0;
Condition50%1/2
$ENV{'HARNESS_DEBUG'} || 0
l!l
011
MC/DC0%0/1
$ENV{'HARNESS_DEBUG'} || 0
$ENV{'HARNESS_DEBUG'}
Truth table50%1/2
A
A= $ENV{'HARNESS_DEBUG'}
Aresult
11
00
60 11 our $Switches = '-w';
61 11 ▶our $Columns = $ENV{HARNESS_COLUMNS} || $ENV{COLUMNS} || 80;
Condition40%2/5
$ENV{'HARNESS_COLUMNS'} || $ENV{'COLUMNS'} || 80
l!l
011
$ENV{"HARNESS_COLUMNS"} or $ENV{"COLUMNS"}
l!l&&r!l&&!r
0011
MC/DC0%0/2
$ENV{'HARNESS_COLUMNS'} || $ENV{'COLUMNS'} || 80
$ENV{"HARNESS_COLUMNS"} $ENV{"COLUMNS"}
Truth table33%1/3
A or B
A= $ENV{"HARNESS_COLUMNS"}B= $ENV{"COLUMNS"}
ABresult
1X1
011
000
62 11 $Columns--; # Some shells have trouble with a full line of text.
63 11 ▶our $Timer = $ENV{HARNESS_TIMER} || 0;
Condition50%1/2
$ENV{'HARNESS_TIMER'} || 0
l!l
011
MC/DC0%0/1
$ENV{'HARNESS_TIMER'} || 0
$ENV{'HARNESS_TIMER'}
Truth table50%1/2
A
A= $ENV{'HARNESS_TIMER'}
Aresult
11
00
64 11 ▶our $Color = $ENV{HARNESS_COLOR} || 0;
Condition50%1/2
$ENV{'HARNESS_COLOR'} || 0
l!l
011
MC/DC0%0/1
$ENV{'HARNESS_COLOR'} || 0
$ENV{'HARNESS_COLOR'}
Truth table50%1/2
A
A= $ENV{'HARNESS_COLOR'}
Aresult
11
00
65 11 ▶our $IgnoreExit = $ENV{HARNESS_IGNORE_EXIT} || 0;
Condition50%1/2
$ENV{'HARNESS_IGNORE_EXIT'} || 0
l!l
011
MC/DC0%0/1
$ENV{'HARNESS_IGNORE_EXIT'} || 0
$ENV{'HARNESS_IGNORE_EXIT'}
Truth table50%1/2
A
A= $ENV{'HARNESS_IGNORE_EXIT'}
Aresult
11
00
66  
67 =head1 SYNOPSIS
68  
69 use Test::Harness;
70  
71 runtests(@test_files);
72  
73 =head1 DESCRIPTION
74  
75 Although, for historical reasons, the L<Test::Harness> distribution
76 takes its name from this module it now exists only to provide
77 L<TAP::Harness> with an interface that is somewhat backwards compatible
78 with L<Test::Harness> 2.xx. If you're writing new code consider using
79 L<TAP::Harness> directly instead.
80  
81 Emulation is provided for C<runtests> and C<execute_tests> but the
82 pluggable 'Straps' interface that previous versions of L<Test::Harness>
83 supported is not reproduced here. Straps is now available as a stand
84 alone module: L<Test::Harness::Straps>.
85  
86 See L<TAP::Parser>, L<TAP::Harness> for the main documentation for this
87 distribution.
88  
89 =head1 FUNCTIONS
90  
91 The following functions are available.
92  
93 =head2 runtests( @test_files )
94  
95 This runs all the given I<@test_files> and divines whether they passed
96 or failed based on their output to STDOUT (details above). It prints
97 out each individual test which failed along with a summary report and
98 a how long it all took.
99  
100 It returns true if everything was ok. Otherwise it will C<die()> with
101 one of the messages in the DIAGNOSTICS section.
102  
103 =cut
104  
105 0 ▶sub _has_taint {
Subroutine _has_taint: not called CC=1 SCAR=6.9
106 0 ▶ my $test = shift;
Subroutine _has_taint: not called CC=1 SCAR=6.9
107 0 return TAP::Parser::SourceHandler::Perl->get_taint(
108 TAP::Parser::Source->shebang($test) );
109 }
110  
111 31 ▶sub _aggregate {
Subroutine _aggregate: called CC=1 SCAR=1.2
112 0 ▶ my ( $harness, $aggregate, @tests ) = @_;
Subroutine _aggregate: not called CC=1 SCAR=1.2
113  
114 # Don't propagate to our children
115 0 local $ENV{HARNESS_OPTIONS};
116  
117 0 _apply_extra_INC($harness);
118 0 _aggregate_tests( $harness, $aggregate, @tests );
119 }
120  
121 # Make sure the child sees all the extra junk in @INC
122 31 ▶sub _apply_extra_INC {
Subroutine _apply_extra_INC: called CC=1 SCAR=1.2
123 0 ▶ my $harness = shift;
Subroutine _apply_extra_INC: not called CC=1 SCAR=1.2
124  
125 $harness->callback(
126 56 ▶ parser_args => sub {
Subroutine __ANON__: called CC=1 SCAR=1.2
127 0 ▶ my ( $args, $test ) = @_;
Subroutine __ANON__: not called CC=1 SCAR=1.2
128 0 push @{ $args->{switches} }, map {"-I$_"} _filtered_inc();
129 }
130 0 );
131 }
132  
133 31 ▶sub _aggregate_tests {
Subroutine _aggregate_tests: called CC=1 SCAR=1.2
134 0 ▶ my ( $harness, $aggregate, @tests ) = @_;
Subroutine _aggregate_tests: not called CC=1 SCAR=1.2
135 0 $aggregate->start();
136 0 $harness->aggregate_tests( $aggregate, @tests );
137 0 $aggregate->stop();
138  
139 }
140  
141 2 ▶sub runtests {
Subroutine runtests: called CC=4 SCAR=19.5
Pod documented
142 0 ▶ my @tests = @_;
Subroutine runtests: not called CC=4 SCAR=19.5
Pod documented
143  
144 # shield against -l
145 0 local ( $\, $, );
146  
147 0 my $harness = _new_harness();
148 0 ▶ local $ENV{PERL_USE_UNSAFE_INC} = 1 if not exists $ENV{PERL_USE_UNSAFE_INC};
Branch: 2 branches
BranchTrueFalseTotal
unless exists $ENV{"PERL_USE_UNSAFE_INC"} 0 2 2
unless exists $ENV{"PERL_USE_UNSAFE_INC"} 0 0 0
149  
150 # Don't propagate to our children
151 0 local $ENV{HARNESS_OPTIONS};
152 0 my $aggregate = $harness->runtests(@tests);
153  
154 0 my $total = $aggregate->total;
155 0 my $passed = $aggregate->passed;
156 0 my $failed = $aggregate->failed;
157 0 my $total_files = $aggregate->total_files;
158 0 my $failed_files = $aggregate->failed_files;
159  
160 0 ▶ die(sprintf(
Branch: 2 branches
BranchTrueFalseTotal
if $failed_files 1 1 2
if $failed_files 0 0 0
161 "Failed %d/%d test programs. %d/%d subtests failed.\n",
162 $failed_files, $total_files, $failed, $total
163 )
164 ) if $failed_files;
165  
166 0 ▶ return $total && $total == $passed;
Condition16%1/6
$total && $total == $passed
!ll&&!rl&&r
010
$total && $total == $passed
!ll&&!rl&&r
000
MC/DC0%0/2
$total && $total == $passed
$total $total == $passed
MC/DC0%0/2
$total && $total == $passed
$total $total == $passed
Truth table33%1/3
A && B
A= $totalB= $total == $passed
ABresult
0X0
100
111
Truth table0%0/3
A && B
A= $totalB= $total == $passed
ABresult
0X0
100
111
167 }
168  
169 16 ▶sub _canon {
Subroutine _canon: called CC=5 SCAR=20.7
170 0 ▶ my @list = sort { $a <=> $b } @_;
Subroutine _canon: not called CC=5 SCAR=20.7
171 0 my @ranges = ();
172 0 my $count = scalar @list;
173 0 my $pos = 0;
174  
175 0 ▶ while ( $pos < $count ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($pos < $count) 16 16 32
if ($pos < $count) 0 0 0
176 0 my $end = $pos + 1;
177 0 ▶ $end++ while $end < $count && $list[$end] <= $list[ $end - 1 ] + 1;
Branch: 2 branches
BranchTrueFalseTotal
$end < $count and $list[$end] <= $list[$end - 1] + 1 and do { ++$end } 6 16 22
$end < $count and $list[$end] <= $list[$end - 1] + 1 and do { ++$end } 0 0 0
Condition50%3/6
$end < $count and $list[$end] <= $list[$end - 1] + 1
!ll&&!rl&&r
1426
$end < $count and $list[$end] <= $list[$end - 1] + 1
!ll&&!rl&&r
000
MC/DC100%2/2
$end < $count and $list[$end] <= $list[$end - 1] + 1
$end < $count $list[$end] <= $list[$end - 1] + 1
MC/DC0%0/2
$end < $count and $list[$end] <= $list[$end - 1] + 1
$end < $count $list[$end] <= $list[$end - 1] + 1
Truth table100%3/3
A and B
A= $end < $countB= $list[$end] <= $list[$end - 1] + 1
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= $end < $countB= $list[$end] <= $list[$end - 1] + 1
ABresult
0X0
100
111
178 0 ▶ push @ranges, ( $end == $pos + 1 )
Branch: 2 branches
BranchTrueFalseTotal
$end == $pos + 1 ? : 14 2 16
$end == $pos + 1 ? : 0 0 0
179 ? $list[$pos]
180 : join( '-', $list[$pos], $list[ $end - 1 ] );
181 0 $pos = $end;
182 }
183  
184 0 return join( ' ', @ranges );
185 }
186  
187 36 ▶sub _new_harness {
Subroutine _new_harness: called CC=16 SCAR=44.4
188 0 ▶ my $sub_args = shift || {};
Subroutine _new_harness: not called CC=16 SCAR=44.4
Condition50%2/4
shift() || {}
l!l
315
shift() || {}
l!l
00
MC/DC100%1/1
shift() || {}
shift()
MC/DC0%0/1
shift() || {}
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
Truth table0%0/2
A
A= shift()
Aresult
11
00
189  
190 0 my ( @lib, @switches );
191 0 my @opt = map { shellwords($_) } grep { defined } $Switches, $ENV{HARNESS_PERL_SWITCHES};
192 0 ▶ while ( my $opt = shift @opt ) {
Branch: 2 branches
BranchTrueFalseTotal
if (my $opt = shift @opt) 44 36 80
if (my $opt = shift @opt) 0 0 0
193 0 ▶ if ( $opt =~ /^ -I (.*) $ /x ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($opt =~ /^ -I (.*) $ /x) { } 2 42 44
if ($opt =~ /^ -I (.*) $ /x) { } 0 0 0
194 0 ▶ push @lib, length($1) ? $1 : shift @opt;
Branch: 2 branches
BranchTrueFalseTotal
length $1 ? : 1 1 2
length $1 ? : 0 0 0
195 }
196 else {
197 0 push @switches, $opt;
198 }
199 }
200  
201 0 push @lib, _filtered_inc();
202  
203 # If $Verbose isn't numeric default to 1. This helps core.
204 0 ▶ my $verbosity = ( $Verbose ? ( $Verbose !~ /\d/ ) ? 1 : $Verbose : 0 );
Branch: 4 branches
BranchTrueFalseTotal
$Test::Harness::Verbose ? : 3 33 36
!($Test::Harness::Verbose =~ /\d/) ? : 0 3 3
$Test::Harness::Verbose ? : 0 0 0
!($Test::Harness::Verbose =~ /\d/) ? : 0 0 0
205  
206 0 my $args = {
207 timer => $Timer,
208 directives => our $Directives,
209 lib => \@lib,
210 switches => \@switches,
211 color => $Color,
212 verbosity => $verbosity,
213 ignore_exit => $IgnoreExit,
214 };
215  
216 $args->{stdout} = $sub_args->{out}
217 0 ▶ if exists $sub_args->{out};
Branch: 2 branches
BranchTrueFalseTotal
if exists $sub_args->{"out"} 0 36 36
if exists $sub_args->{"out"} 0 0 0
218  
219 0 ▶ my $class = $ENV{HARNESS_SUBCLASS} || 'TAP::Harness';
Condition50%2/4
$ENV{'HARNESS_SUBCLASS'} || 'TAP::Harness'
l!l
135
$ENV{'HARNESS_SUBCLASS'} || 'TAP::Harness'
l!l
00
MC/DC100%1/1
$ENV{'HARNESS_SUBCLASS'} || 'TAP::Harness'
$ENV{'HARNESS_SUBCLASS'}
MC/DC0%0/1
$ENV{'HARNESS_SUBCLASS'} || 'TAP::Harness'
$ENV{'HARNESS_SUBCLASS'}
Truth table100%2/2
A
A= $ENV{'HARNESS_SUBCLASS'}
Aresult
11
00
Truth table0%0/2
A
A= $ENV{'HARNESS_SUBCLASS'}
Aresult
11
00
220 0 ▶ if ( defined( my $env_opt = $ENV{HARNESS_OPTIONS} ) ) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined(my $env_opt = $ENV{"HARNESS_OPTIONS"})) 36 0 36
if (defined(my $env_opt = $ENV{"HARNESS_OPTIONS"})) 0 0 0
221 0 for my $opt ( split /:/, $env_opt ) {
222 0 ▶ if ( $opt =~ /^j(\d*)$/ ) {
Branch: 8 branches
BranchTrueFalseTotal
if ($opt =~ /^j(\d*)$/) { } 1 1 2
elsif ($opt eq 'c') { } 1 0 1
elsif ($opt =~ /^f(.*)$/) { } 0 0 0
elsif ($opt =~ /^a(.*)$/) { } 0 0 0
if ($opt =~ /^j(\d*)$/) { } 0 0 0
elsif ($opt eq 'c') { } 0 0 0
elsif ($opt =~ /^f(.*)$/) { } 0 0 0
elsif ($opt =~ /^a(.*)$/) { } 0 0 0
223 0 ▶ $args->{jobs} = $1 || 9;
Condition25%1/4
$1 || 9
l!l
10
$1 || 9
l!l
00
MC/DC0%0/1
$1 || 9
$1
MC/DC0%0/1
$1 || 9
$1
Truth table50%1/2
A
A= $1
Aresult
11
00
Truth table0%0/2
A
A= $1
Aresult
11
00
224 }
225 elsif ( $opt eq 'c' ) {
226 0 $args->{color} = 1;
227 }
228 elsif ( $opt =~ m/^f(.*)$/ ) {
229 0 my $fmt = $1;
230 0 $fmt =~ s/-/::/g;
231 0 $args->{formatter_class} = $fmt;
232 }
233 elsif ( $opt =~ m/^a(.*)$/ ) {
234 0 my $archive = $1;
235 0 $class = "TAP::Harness::Archive";
236 0 $args->{archive} = $archive;
237 }
238 else {
239 0 die "Unknown HARNESS_OPTIONS item: $opt\n";
240 }
241 }
242 }
243  
244 0 return TAP::Harness->_construct( $class, $args );
245 }
246  
247 # Get the parts of @INC which are changed from the stock list AND
248 # preserve reordering of stock directories.
249 94 ▶sub _filtered_inc {
Subroutine _filtered_inc: called CC=9 SCAR=32.5
250 0 ▶ my @inc = grep { !ref } @INC; #28567
Subroutine _filtered_inc: not called CC=9 SCAR=32.5
251  
252 0 ▶ if (IS_VMS) {
Branch: 2 branches
BranchTrueFalseTotal
if (do { &IS_WIN32() }) 0 94 94
if (do { &IS_WIN32() }) 0 0 0
253  
254 # VMS has a 255-byte limit on the length of %ENV entries, so
255 # toss the ones that involve perl_root, the install location
256 @inc = grep !/perl_root/i, @inc;
257  
258 }
259 0 elsif (IS_WIN32) {
260  
261 # Lose any trailing backslashes in the Win32 paths
262 0 s/[\\\/]+$// for @inc;
263 }
264  
265 0 my @default_inc = _default_inc();
266  
267 0 my @new_inc;
268 my %seen;
269 0 for my $dir (@inc) {
270 0 ▶ next if $seen{$dir}++;
Branch: 2 branches
BranchTrueFalseTotal
if $seen{$dir}++ 85 921 1006
if $seen{$dir}++ 0 0 0
271  
272 0 ▶ if ( $dir eq ( $default_inc[0] || '' ) ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($dir eq ($default_inc[0] || '')) { } 644 277 921
if ($dir eq ($default_inc[0] || '')) { } 0 0 0
Condition50%2/4
$default_inc[0] || ''
l!l
9192
$default_inc[0] || ''
l!l
00
MC/DC100%1/1
$default_inc[0] || ''
$default_inc[0]
MC/DC0%0/1
$default_inc[0] || ''
$default_inc[0]
Truth table100%2/2
A
A= $default_inc[0]
Aresult
11
00
Truth table0%0/2
A
A= $default_inc[0]
Aresult
11
00
273 0 shift @default_inc;
274 }
275 else {
276 0 push @new_inc, $dir;
277 }
278  
279 0 ▶ shift @default_inc while @default_inc and $seen{ $default_inc[0] };
Branch: 2 branches
BranchTrueFalseTotal
@default_inc and $seen{$default_inc[0]} and do { shift @default_inc } 0 921 921
@default_inc and $seen{$default_inc[0]} and do { shift @default_inc } 0 0 0
Condition33%2/6
@default_inc and $seen{$default_inc[0]}
!ll&&!rl&&r
948270
@default_inc and $seen{$default_inc[0]}
!ll&&!rl&&r
000
MC/DC0%0/2
@default_inc and $seen{$default_inc[0]}
@default_inc $seen{$default_inc[0]}
MC/DC0%0/2
@default_inc and $seen{$default_inc[0]}
@default_inc $seen{$default_inc[0]}
Truth table66%2/3
A and B
A= @default_incB= $seen{$default_inc[0]}
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= @default_incB= $seen{$default_inc[0]}
ABresult
0X0
100
111
280 }
281  
282 0 return @new_inc;
283 }
284  
285 {
286  
287 # Cache this to avoid repeatedly shelling out to Perl.
288 11 my @inc;
289  
290 94 ▶ sub _default_inc {
Subroutine _default_inc: called CC=3 SCAR=15.8
291 0 ▶ return @inc if @inc;
Subroutine _default_inc: not called CC=3 SCAR=15.8
Branch: 2 branches
BranchTrueFalseTotal
if @inc 86 8 94
if @inc 0 0 0
292  
293 0 local $ENV{PERL5LIB};
294 0 local $ENV{PERLLIB};
295  
296 0 ▶ my $perl = $ENV{HARNESS_PERL} || $^X;
Condition16%1/6
$ENV{'HARNESS_PERL'} || $^X
l!l&&r!l&&!r
080
$ENV{'HARNESS_PERL'} || $^X
l!l&&r!l&&!r
000
MC/DC0%0/2
$ENV{'HARNESS_PERL'} || $^X
$ENV{'HARNESS_PERL'} $^X
MC/DC0%0/2
$ENV{'HARNESS_PERL'} || $^X
$ENV{'HARNESS_PERL'} $^X
Truth table33%1/3
A || B
A= $ENV{'HARNESS_PERL'}B= $^X
ABresult
1X1
011
000
Truth table0%0/3
A || B
A= $ENV{'HARNESS_PERL'}B= $^X
ABresult
1X1
011
000
297  
298 # Avoid using -l for the benefit of Perl 6
299 0 chomp( @inc = `"$perl" -e "print join qq[\\n], \@INC, q[]"` );
300 0 return @inc;
301 }
302 }
303  
304 11 ▶sub _check_sequence {
Subroutine _check_sequence: called CC=4 SCAR=17.6
305 0 ▶ my @list = @_;
Subroutine _check_sequence: not called CC=4 SCAR=17.9
306 0 my $prev;
307 0 ▶ while ( my $next = shift @list ) {
Branch: 2 branches
BranchTrueFalseTotal
if (my $next = shift @list) 145 54 199
if (my $next = shift @list) 0 0 0
308 0 ▶ return if defined $prev && $next <= $prev;
Branch: 2 branches
BranchTrueFalseTotal
if defined $prev and $next <= $prev 2 143 145
if defined $prev and $next <= $prev 0 0 0
Condition50%3/6
defined $prev and $next <= $prev
!ll&&!rl&&r
44992
defined $prev and $next <= $prev
!ll&&!rl&&r
000
MC/DC100%2/2
defined $prev and $next <= $prev
defined $prev $next <= $prev
MC/DC0%0/2
defined $prev and $next <= $prev
defined $prev $next <= $prev
Truth table100%3/3
A and B
A= defined $prevB= $next <= $prev
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= defined $prevB= $next <= $prev
ABresult
0X0
100
111
309 0 $prev = $next;
310 }
311  
312 0 return 1;
313 }
314  
315 31 ▶sub execute_tests {
Subroutine execute_tests: called CC=20 SCAR=43.0
Pod documented
316 0 ▶ my %args = @_;
Subroutine execute_tests: not called CC=20 SCAR=43.0
Pod documented
317  
318 0 my $harness = _new_harness( \%args );
319 0 my $aggregate = TAP::Parser::Aggregator->new();
320  
321 0 my %tot = (
322 bonus => 0,
323 max => 0,
324 ok => 0,
325 bad => 0,
326 good => 0,
327 files => 0,
328 tests => 0,
329 sub_skipped => 0,
330 todo => 0,
331 skipped => 0,
332 bench => undef,
333 );
334  
335 # Install a callback so we get to see any plans the
336 # harness executes.
337 $harness->callback(
338 56 ▶ made_parser => sub {
Subroutine __ANON__: called CC=1 SCAR=0.7
339 0 ▶ my $parser = shift;
Subroutine __ANON__: not called CC=1 SCAR=0.7
340 $parser->callback(
341 50 ▶ plan => sub {
Subroutine __ANON__: called CC=2 SCAR=7.9
342 0 my $plan = shift;
343 50 ▶ if ( $plan->directive eq 'SKIP' ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($plan->directive eq "SKIP") 4 46 50
if ($plan->directive eq "SKIP") 0 0 0
344 4 $tot{skipped}++;
345 }
346 }
347 0 );
348 }
349 0 );
350  
351 0 ▶ local $ENV{PERL_USE_UNSAFE_INC} = 1 if not exists $ENV{PERL_USE_UNSAFE_INC};
Branch: 2 branches
BranchTrueFalseTotal
unless exists $ENV{"PERL_USE_UNSAFE_INC"} 0 31 31
unless exists $ENV{"PERL_USE_UNSAFE_INC"} 0 0 0
352 0 _aggregate( $harness, $aggregate, @{ $args{tests} } );
353  
354 0 $tot{bench} = $aggregate->elapsed;
355 0 my @tests = $aggregate->descriptions;
356  
357 # TODO: Work out the circumstances under which the files
358 # and tests totals can differ.
359 0 $tot{files} = $tot{tests} = scalar @tests;
360  
361 0 my %failedtests = ();
362 0 my %todo_passed = ();
363  
364 0 for my $test (@tests) {
365 0 my ($parser) = $aggregate->parsers($test);
366  
367 0 my @failed = $parser->failed;
368  
369 0 my $wstat = $parser->wait;
370 0 my $estat = $parser->exit;
371 0 my $planned = $parser->tests_planned;
372 0 my @errors = $parser->parse_errors;
373 0 my $passed = $parser->passed;
374 0 my $actual_passed = $parser->actual_passed;
375  
376 0 my $ok_seq = _check_sequence( $parser->actual_passed );
377  
378 # Duplicate exit, wait status semantics of old version
379 0 ▶ $estat ||= '' unless $wstat;
Branch: 2 branches
BranchTrueFalseTotal
unless $wstat 46 10 56
unless $wstat 0 0 0
Condition25%1/4
$estat ||= ""
l!l
046
$estat ||= ""
l!l
00
MC/DC0%0/1
$estat ||= ""
$estat
MC/DC0%0/1
$estat ||= ""
$estat
Truth table50%1/2
A
A= $estat
Aresult
11
00
Truth table0%0/2
A
A= $estat
Aresult
11
00
380 0 ▶ $wstat ||= '';
Condition50%2/4
$wstat ||= ""
l!l
1046
$wstat ||= ""
l!l
00
MC/DC100%1/1
$wstat ||= ""
$wstat
MC/DC0%0/1
$wstat ||= ""
$wstat
Truth table100%2/2
A
A= $wstat
Aresult
11
00
Truth table0%0/2
A
A= $wstat
Aresult
11
00
381  
382 0 ▶ $tot{max} += ( $planned || 0 );
Condition50%2/4
$planned || 0
l!l
4610
$planned || 0
l!l
00
MC/DC100%1/1
$planned || 0
$planned
MC/DC0%0/1
$planned || 0
$planned
Truth table100%2/2
A
A= $planned
Aresult
11
00
Truth table0%0/2
A
A= $planned
Aresult
11
00
383 0 $tot{bonus} += $parser->todo_passed;
384 0 ▶ $tot{ok} += $passed > $actual_passed ? $passed : $actual_passed;
Branch: 2 branches
BranchTrueFalseTotal
$passed > $actual_passed ? : 2 54 56
$passed > $actual_passed ? : 0 0 0
385 0 $tot{sub_skipped} += $parser->skipped;
386 0 $tot{todo} += $parser->todo;
387  
388 0 ▶ if ( @failed || $estat || @errors ) {
Branch: 2 branches
BranchTrueFalseTotal
if (@failed or $estat or @errors) { } 22 34 56
if (@failed or $estat or @errors) { } 0 0 0
Condition50%6/12
@failed or $estat or @errors
l!l&&r!l&&!r
20234
@failed or $estat
l!l&&r!l&&!r
14636
@failed or $estat or @errors
l!l&&r!l&&!r
000
@failed or $estat
l!l&&r!l&&!r
000
MC/DC100%3/3
@failed or $estat or @errors
@failed $estat @errors
MC/DC0%0/3
@failed or $estat or @errors
@failed $estat @errors
Truth table100%4/4
A or B or C
A= @failedB= $estatC= @errors
ABCresult
1XX1
01X1
0011
0000
Truth table0%0/4
A or B or C
A= @failedB= $estatC= @errors
ABCresult
1XX1
01X1
0011
0000
389 0 $tot{bad}++;
390  
391 0 ▶ my $huh_planned = $planned ? undef : '??';
Branch: 2 branches
BranchTrueFalseTotal
$planned ? : 16 6 22
$planned ? : 0 0 0
392 0 ▶ my $huh_errors = $ok_seq ? undef : '??';
Branch: 2 branches
BranchTrueFalseTotal
$ok_seq ? : 20 2 22
$ok_seq ? : 0 0 0
393  
394 0 ▶ $failedtests{$test} = {
Condition46%15/32
$huh_planned || $huh_errors || _canon(@failed) || '??'
l!l
202
$huh_planned or $huh_errors or _canon(@failed)
l!l&&r!l&&!r
8122
$huh_planned or $huh_errors
l!l&&r!l&&!r
6214
$huh_planned || $huh_errors || scalar @failed
l!l
814
$huh_planned or $huh_errors
l!l&&r!l&&!r
6214
$huh_planned || $planned
l!l&&r!l&&!r
6160
$huh_planned || $huh_errors || _canon(@failed) || '??'
l!l
00
$huh_planned or $huh_errors or _canon(@failed)
l!l&&r!l&&!r
000
$huh_planned or $huh_errors
l!l&&r!l&&!r
000
$huh_planned || $huh_errors || scalar @failed
l!l
00
$huh_planned or $huh_errors
l!l&&r!l&&!r
000
$huh_planned || $planned
l!l&&r!l&&!r
000
MC/DC100%3/3
$huh_planned || $huh_errors || _canon(@failed) || '??'
$huh_planned $huh_errors _canon(@failed)
MC/DC100%2/2
$huh_planned || $huh_errors || scalar @failed
$huh_planned $huh_errors
MC/DC0%0/2
$huh_planned || $planned
$huh_planned $planned
MC/DC0%0/3
$huh_planned || $huh_errors || _canon(@failed) || '??'
$huh_planned $huh_errors _canon(@failed)
MC/DC0%0/2
$huh_planned || $huh_errors || scalar @failed
$huh_planned $huh_errors
MC/DC0%0/2
$huh_planned || $planned
$huh_planned $planned
Truth table100%4/4
A or B or C
A= $huh_plannedB= $huh_errorsC= _canon(@failed)
ABCresult
1XX1
01X1
0011
0000
Truth table100%3/3
A or B
A= $huh_plannedB= $huh_errors
ABresult
1X1
011
000
Truth table66%2/3
A || B
A= $huh_plannedB= $planned
ABresult
1X1
011
000
Truth table0%0/4
A or B or C
A= $huh_plannedB= $huh_errorsC= _canon(@failed)
ABCresult
1XX1
01X1
0011
0000
Truth table0%0/3
A or B
A= $huh_plannedB= $huh_errors
ABresult
1X1
011
000
Truth table0%0/3
A || B
A= $huh_plannedB= $planned
ABresult
1X1
011
000
395 'canon' => $huh_planned
396 || $huh_errors
397 || _canon(@failed)
398 || '??',
399 'estat' => $estat,
400 'failed' => $huh_planned
401 || $huh_errors
402 || scalar @failed,
403 'max' => $huh_planned || $planned,
404 'name' => $test,
405 'wstat' => $wstat
406 };
407 }
408 else {
409 0 $tot{good}++;
410 }
411  
412 0 my @todo = $parser->todo_passed;
413 0 ▶ if (@todo) {
Branch: 2 branches
BranchTrueFalseTotal
if (@todo) 2 54 56
if (@todo) 0 0 0
414 0 $todo_passed{$test} = {
415 'canon' => _canon(@todo),
416 'estat' => $estat,
417 'failed' => scalar @todo,
418 'max' => scalar $parser->todo,
419 'name' => $test,
420 'wstat' => $wstat
421 };
422 }
423 }
424  
425 0 return ( \%tot, \%failedtests, \%todo_passed );
426 }
427  
428 =head2 execute_tests( tests => \@test_files, out => \*FH )
429  
430 Runs all the given C<@test_files> (just like C<runtests()>) but
431 doesn't generate the final report. During testing, progress
432 information will be written to the currently selected output
433 filehandle (usually C<STDOUT>), or to the filehandle given by the
434 C<out> parameter. The I<out> is optional.
435  
436 Returns a list of two values, C<$total> and C<$failed>, describing the
437 results. C<$total> is a hash ref summary of all the tests run. Its
438 keys and values are this:
439  
440 bonus Number of individual todo tests unexpectedly passed
441 max Number of individual tests ran
442 ok Number of individual tests passed
443 sub_skipped Number of individual tests skipped
444 todo Number of individual todo tests
445  
446 files Number of test files ran
447 good Number of test files passed
448 bad Number of test files failed
449 tests Number of test files originally given
450 skipped Number of test files skipped
451  
452 If C<< $total->{bad} == 0 >> and C<< $total->{max} > 0 >>, you've
453 got a successful test.
454  
455 C<$failed> is a hash ref of all the test scripts that failed. Each key
456 is the name of a test script, each value is another hash representing
457 how that script failed. Its keys are these:
458  
459 name Name of the test which failed
460 estat Script's exit value
461 wstat Script's wait status
462 max Number of individual tests
463 failed Number which failed
464 canon List of tests which failed (as string).
465  
466 C<$failed> should be empty if everything passed.
467  
468 =cut
469  
470 11 1;
471 __END__
« blib/lib/TAP/Harness/Env.pm ↑ Summary blib/lib/TAP/Formatter/Console/ParallelSession.pm »