blib/lib/Test/Smoke/Smoker.pm

filter: Statementstmt 35.8% 216 / 602 Branchbran 22.8% 74 / 324 Conditioncond 15.3% 12 / 78 MC/DCmcdc 8.0% 4 / 50 Subroutinesub 44.6% 21 / 47 Podpod 100% 22 / 22 totaltotal 31.0% 349 / 1123 CC 195 SCAR 47.6
CC
195
Cov
30%
make_test
380.0
_run_harness3_target
342.0
make_
306.0
CRAP 116.8
« blib/lib/Test/Smoke/Mailer/Mail_X.pm ↑ Summary blib/lib/Test/Smoke/Mailer/Sendmail.pm »
1 package Test::Smoke::Smoker;
2 13 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 13 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 13 our $VERSION = '0.047';
6  
7 13 ▶use Config;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 13 ▶use Cwd;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 13 ▶use File::Spec::Functions qw( :DEFAULT abs2rel rel2abs );
Subroutine BEGIN: called CC=1 SCAR=0.0
10 13 ▶use Capture::Tiny 'capture';
Subroutine BEGIN: called CC=1 SCAR=0.0
11 13 ▶use Test::Smoke::LogMixin;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 13 ▶use Test::Smoke::Util qw( get_smoked_Config skip_filter );
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 13 ▶BEGIN { eval q{ use Time::HiRes qw( time ) } }
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
15 13 { my $_orig_dft = select(STDERR); $|++; select(STDOUT); $|++; select($_orig_dft); $|++ }
16  
17 13 my %CONFIG = (
18 df_ddir => curdir(),
19 df_v => 0,
20 df_run => 1,
21 df_fdir => undef,
22 df_is56x => 0,
23 df_locale => '',
24 df_force_c_locale => 0,
25 df_defaultenv => 0,
26 df_perlio_only => 0,
27 df_harness_destruct => 2,
28  
29 df_is_vms => $^O eq 'VMS',
30 df_vmsmake => 'MMK',
31 df_harnessonly => scalar ($^O =~ /VMS/),
32 df_hasharness3 => 0,
33 df_harness3opts => '',
34  
35 df_is_win32 => $^O eq 'MSWin32',
36 df_w32cc => 'MSVC60',
37 df_w32make => 'nmake',
38 df_w32args => [ ],
39  
40 df_makeopt => "",
41 df_testmake => undef,
42  
43 df_skip_tests => undef,
44 );
45  
46 # Define some constants that we can use for
47 # specifying how far "make" got.
48 sub BUILD_MINIPERL() { -1 } # but no perl
49 sub BUILD_PERL () { 1 } # ok
50 sub BUILD_NOTHING () { 0 } # not ok
51  
52 sub HARNESS_RE1 () {
53 '(\S+\.t)(?:\s+[\d?]+){0,4}(?:\s+[\d?.]*%)?\s+([\d?]+(?:[-\s]+\d+-?)*)$'
54 }
55 sub HARNESS_RE2() { '^\s+(\d+(?:[-\s]+\d+)*-?)$' }
56  
57  
58 sub HARNESS3_RE_EXTRA() {
59 '^\s+(\d[0-9, -]*)'
60 }
61  
62 sub HARNESS3_RE_FAILED() {
63 '^(?:
64 (?:\ \ Failed\ tests?(?:\ number\(s\))?:\ \ )
65 )
66 (\d[0-9, -]*)'
67 }
68  
69 sub HARNESS3_RE_TODO() {
70 '^(?:
71 (?:\ \ TODO\ passed(?:\ number\(s\))?:\ \ \ )
72 )
73 (\d[0-9, -]*)'
74 }
75  
76  
77 =head1 NAME
78  
79 Test::Smoke::Smoker - OO interface to do one smoke cycle.
80  
81 =head1 SYNOPSIS
82  
83 use Test::Smoke;
84 use Test::Smoke::Smoker;
85  
86 open LOGFILE, "> mktest.out" or die "Cannot create 'mktest.out': $!";
87 my $buildcfg = Test::SmokeBuildCFG->new( $conf->{cfg} );
88 my $policy = Test::Smoke::Policy->new( '../', $conf->{v} );
89 my $smoker = Test::Smoke::Smoker->new( \*LOGFILE, $conf );
90  
91 foreach my $config ( $buildcfg->configurations ) {
92 $smoker->smoke( $config, $policy );
93 }
94  
95 =head1 DESCRIPTION
96  
97 The Test::Smoke::Smoker module, an OO interface to do one smoke cycle.
98  
99 =head1 CONSTANTS
100  
101 =over
102  
103 =item BUILD_MINIPERL
104  
105 =item BUILD_NOTHING
106  
107 =item BUILD_PERL
108  
109 =item HARNESS3_RE_EXTRA
110  
111 =item HARNESS3_RE_FAILED
112  
113 =item HARNESS3_RE_TODO
114  
115 =item HARNESS_RE1
116  
117 =item HARNESS_RE2
118  
119 =back
120  
121 =head1 METHODS
122  
123 =head2 Test::Smoke::Smoker->new( \*GLOB, %args )
124  
125 C<new()> takes a mandatory (opened) filehandle and some other options:
126  
127 ddir build directory
128 fdir The forest source
129 v verbose level: 0..2
130 defaultenv 'make test' without $ENV{PERLIO}
131 is56x skip the PerlIO stuff?
132 locale do another testrun with $ENV{LC_ALL}
133 force_c_locale set $ENV{LC_ALL} = 'C' for all smoke runs
134  
135 is_win32 is this MSWin32?
136 w32cc the CCTYPE for MSWin32 (MSVCxx BORLAND GCC)
137 w32make the maker to use for CCTYPE
138  
139 =cut
140  
141 20 ▶sub new {
Subroutine new: called CC=11 SCAR=25.7
Pod documented
142 20 my $proto = shift;
143 20 ▶ my $class = ref $proto || $proto;
Condition33%1/3
ref $proto || $proto
l!l&&r!l&&!r
0200
MC/DC0%0/2
ref $proto || $proto
ref $proto $proto
Truth table33%1/3
A || B
A= ref $protoB= $proto
ABresult
1X1
011
000
144  
145 20 my $fh = shift;
146  
147 20 ▶ unless ( ref $fh eq 'GLOB' ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $fh eq "GLOB") 0 20 20
148 0 require Carp;
149 0 Carp::croak(sprintf "Usage: %s->new( \\*FH, %%args )", __PACKAGE__);
150 }
151  
152 0 ▶ my %args_raw = @_ ? UNIVERSAL::isa( $_[0], 'HASH' ) ? %{ $_[0] } : @_ : ();
Branch: 2 branches
BranchTrueFalseTotal
@_ ? : 20 0 20
UNIVERSAL::isa($_[0], 'HASH') ? : 0 20 20
153  
154 my %args = map {
155 20 ( my $key = $_ ) =~ s/^-?(.+)$/lc $1/e;
156 28 ( $key => $args_raw{ $_ } );
157 } keys %args_raw;
158  
159 my %fields = map {
160 440 ▶ my $value = exists $args{$_} ? $args{ $_ } : $CONFIG{ "df_$_" };
Branch: 1 branch
BranchTrueFalseTotal
exists $args{$_} ? : 28 412 440
161 440 ( $_ => $value )
162 20 } keys %{ Test::Smoke::Smoker->config( 'all_defaults' ) };
163  
164 20 $fields{logfh} = $fh;
165 20 select( ( select( $fh ), $|++ )[0] );
166 20 ▶ $fields{defaultenv} = 1 if $fields{is56x};
Branch: 1 branch
BranchTrueFalseTotal
if $fields{"is56x"} 0 20 20
167 20 ▶ $^O =~ /VMS/i and $fields{is_vms} = 1;
Branch: 1 branch
BranchTrueFalseTotal
$^O =~ /VMS/i and $fields{"is_vms"} = 1 0 20 20
168  
169 20 ▶ unless ( defined $fields{testmake} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $fields{"testmake"}) 18 2 20
170 18 $fields{testmake} = 'make';
171 18 ▶ $fields{is_win32} and $fields{testmake} = $fields{w32make};
Branch: 1 branch
BranchTrueFalseTotal
$fields{"is_win32"} and $fields{"testmake"} = $fields{"w32make"} 0 18 18
172 18 ▶ $fields{is_vms} and $fields{testmake} = $fields{vmsmake};
Branch: 1 branch
BranchTrueFalseTotal
$fields{"is_vms"} and $fields{"testmake"} = $fields{"vmsmake"} 0 18 18
173 }
174 20 my $self = bless { %fields }, $class;
175  
176 20 return $self;
177 }
178  
179 =head2 $smoker->verbose
180  
181 Get verbosity.
182  
183 =cut
184  
185 332 ▶sub verbose { $_[0]->{v} }
Subroutine verbose: called CC=1 SCAR=0.0
Pod documented
186  
187 =head2 $smoker->mark_in()
188  
189 Write the current timestamp with 'Start' marker to the logfile.
190  
191 =cut
192  
193 0 ▶sub mark_in {
Subroutine mark_in: not called CC=1 SCAR=6.9
Pod documented
194 0 my $self = shift;
195 0 $self->log( sprintf "Started smoke at %d\n", time() );
196 }
197  
198 =head2 $smoker->mark_out()
199  
200 Write the current timestamp with 'Stopped' marker to the logfile.
201  
202 =cut
203  
204 0 ▶sub mark_out {
Subroutine mark_out: not called CC=1 SCAR=6.9
Pod documented
205 0 my $self = shift;
206 0 $self->log( sprintf "Stopped smoke at %d\n", time() );
207 }
208  
209 =head2 Test::Smoke::Smoker->config( $key[, $value] )
210  
211 C<config()> is an interface to the package lexical C<%CONFIG>,
212 which holds all the default values for the C<new()> arguments.
213  
214 With the special key B<all_defaults> this returns a reference
215 to a hash holding all the default values.
216  
217 =cut
218  
219 39 ▶sub config {
Subroutine config: called CC=4 SCAR=13.9
Pod documented
220 39 my $dummy = shift;
221  
222 39 my $key = lc shift;
223  
224 39 ▶ if ( $key eq 'all_defaults' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($key eq "all_defaults") 21 18 39
225 my %default = map {
226 21 my( $pass_key ) = $_ =~ /^df_(.+)/;
227 462 ( $pass_key => $CONFIG{ $_ } );
228 } grep /^df_/ => keys %CONFIG;
229 21 return \%default;
230 }
231  
232 18 ▶ return undef unless exists $CONFIG{ "df_$key" };
Branch: 1 branch
BranchTrueFalseTotal
unless exists $CONFIG{"df_$key"} 0 18 18
233  
234 18 ▶ $CONFIG{ "df_$key" } = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 18 18
235  
236 18 return $CONFIG{ "df_$key" };
237 }
238  
239 =head2 $smoker->tty( $message )
240  
241 Prints a message to the default filehandle.
242  
243 =cut
244  
245 0 ▶sub tty {
Subroutine tty: not called CC=1 SCAR=6.9
Pod documented
246 0 my $self = shift;
247 0 my $message = join "", @_;
248 0 $self->log_warn($message);
249 }
250  
251 =head2 $smoker->log( $message )
252  
253 Prints a message to the logfile, filehandle.
254  
255 =cut
256  
257 0 ▶sub log {
Subroutine log: not called CC=1 SCAR=6.9
Pod documented
258 0 my $self = shift;
259 0 my $message = join "", @_;
260 0 print { $self->{logfh} } $message;
261 }
262  
263 =head2 $smoker->ttylog( $message )
264  
265 Prints a message to both the default and the logfile filehandles.
266  
267 =cut
268  
269 0 ▶sub ttylog {
Subroutine ttylog: not called CC=1 SCAR=6.9
Pod documented
270 0 my $self = shift;
271 0 $self->log( @_ );
272 0 $self->tty( @_ );
273 }
274  
275 =head2 $smoker->smoke( $config[, $policy] )
276  
277 C<smoke()> takes a B<Test::Smoke::BuildCFG::Config> object and runs all
278 the basic steps as (private) object methods.
279  
280 =cut
281  
282 0 ▶sub smoke {
Subroutine smoke: not called CC=12 SCAR=50.5
Pod documented
283 0 my( $self, $config, $policy ) = @_;
284  
285 0 ▶ $self->{is_vms} and $self->_vms_rooted_logical;
Branch: 1 branch
BranchTrueFalseTotal
$self->{"is_vms"} and $self->_vms_rooted_logical 0 0 0
286  
287 0 $self->make_distclean;
288  
289 0 ▶ $self->{v} > 1 and $self->extra_manicheck;
Branch: 1 branch
BranchTrueFalseTotal
$self->{"v"} > 1 and $self->extra_manicheck 0 0 0
290  
291 0 $self->handle_policy( $policy, $config->policy );
292  
293 0 my $c_result = $self->Configure( $config );
294 # Log the compiler info now, the last config could fail
295 { # can we config.sh without Configure success?
296 0 my %cinfo = get_smoked_Config( $self->{ddir} => qw(
297 cc ccversion gccversion
298 ));
299 0 ▶ my $version = $cinfo{gccversion} || $cinfo{ccversion};
Condition0%0/3
$cinfo{'gccversion'} || $cinfo{'ccversion'}
l!l&&r!l&&!r
000
MC/DC0%0/2
$cinfo{'gccversion'} || $cinfo{'ccversion'}
$cinfo{'gccversion'} $cinfo{'ccversion'}
Truth table0%0/3
A || B
A= $cinfo{'gccversion'}B= $cinfo{'ccversion'}
ABresult
1X1
011
000
300 $self->log( "\nCompiler info: $cinfo{cc} version $version\n" )
301 0 ▶ if $cinfo{cc};
Branch: 1 branch
BranchTrueFalseTotal
if $cinfo{"cc"} 0 0 0
302 }
303  
304 0 ▶ $c_result or do {
Branch: 1 branch
BranchTrueFalseTotal
$c_result or do { $self->ttylog("Unable to configure perl in this configuration\n"); return 0 } 0 0 0
305 0 $self->ttylog( "Unable to configure perl in this configuration\n" );
306 0 return 0;
307 };
308  
309 0 my %sconf = get_smoked_Config( $self->{ddir} => 'ldlibpthname' );
310 0 ▶ exists $sconf{ldlibpthname} or $sconf{ldlibpthname} = "";
Branch: 1 branch
BranchTrueFalseTotal
exists $sconf{"ldlibpthname"} or $sconf{"ldlibpthname"} = "" 0 0 0
311 $sconf{ldlibpthname} and
312 local $ENV{ $sconf{ldlibpthname} } = $ENV{ $sconf{ldlibpthname} } || '',
313 0 ▶ substr( $ENV{ $sconf{ldlibpthname} }, 0, 0) =
Branch: 1 branch
BranchTrueFalseTotal
$sconf{"ldlibpthname"} and local $ENV{$sconf{"ldlibpthname"}} = $ENV{$sconf{"ldlibpthname"}} || "", substr($ENV{$sconf{"ldlibpthname"}}, 0, 0) = qq[$self->{"ddir"}$Test::Smoke::Smoker::Config{"path_sep"}] 0 0 0
Condition0%0/2
$ENV{$sconf{'ldlibpthname'}} || ''
l!l
00
MC/DC0%0/1
$ENV{$sconf{'ldlibpthname'}} || ''
$ENV{$sconf{'ldlibpthname'}}
Truth table0%0/2
A
A= $ENV{$sconf{'ldlibpthname'}}
Aresult
11
00
314 "$self->{ddir}$Config{path_sep}";
315  
316 0 my $build_stat = $self->make_( $config );
317  
318 0 ▶ $build_stat == BUILD_MINIPERL and do {
Branch: 1 branch
BranchTrueFalseTotal
$build_stat == -1 and do { $self->ttylog("Unable to make anything but miniperl", " in this configuration\n"); return $self->make_minitest } 0 0 0
319 0 $self->ttylog( "Unable to make anything but miniperl",
320 " in this configuration\n" );
321 0 return $self->make_minitest;
322 };
323  
324 0 ▶ $build_stat == BUILD_NOTHING and do {
Branch: 1 branch
BranchTrueFalseTotal
$build_stat == 0 and do { $self->ttylog("Unable to make perl in this configuration\n"); return 0 } 0 0 0
325 0 $self->ttylog( "Unable to make perl in this configuration\n" );
326 0 return 0;
327 };
328  
329 0 ▶ $self->make_test_prep or do {
Branch: 1 branch
BranchTrueFalseTotal
$self->make_test_prep or do { $self->ttylog("Unable to test perl in this configuration\n"); return 0 } 0 0 0
330 0 $self->ttylog( "Unable to test perl in this configuration\n" );
331 0 return 0;
332 };
333  
334 0 $self->make_test( $config );
335  
336 # $self->{is_vms} and $self->_unset_rooted_logical;
337 0 return 1;
338 }
339  
340 =head2 $smoker->make_distclean( )
341  
342 C<make_distclean()> runs C<< make -i distclean 2>/dev/null >>
343  
344 =cut
345  
346 0 ▶sub make_distclean {
Subroutine make_distclean: not called CC=4 SCAR=30.0
Pod documented
347 0 my $self = shift;
348  
349 0 $self->tty( "make distclean ..." );
350 0 ▶ if ( $self->{fdir} && -d $self->{fdir} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'fdir'} and -d $self->{'fdir'}) { } 0 0 0
Condition0%0/3
$self->{"fdir"} and -d $self->{"fdir"}
!ll&&!rl&&r
000
MC/DC0%0/2
$self->{"fdir"} and -d $self->{"fdir"}
$self->{"fdir"} -d $self->{"fdir"}
Truth table0%0/3
A and B
A= $self->{"fdir"}B= -d $self->{"fdir"}
ABresult
0X0
100
111
351 0 require Test::Smoke::Syncer;
352 my %options = (
353 hdir => $self->{fdir},
354 0 ddir => cwd(),
355 v => 0,
356 );
357 0 my $distclean = Test::Smoke::Syncer->new( hardlink => %options );
358 0 $distclean->clean_from_directory( $self->{fdir}, 'mktest.out' );
359 } else {
360 0 ▶ my $target = $self->{is_vms} ? 'realclean' : '-i distclean';
Branch: 1 branch
BranchTrueFalseTotal
$self->{'is_vms'} ? : 0 0 0
361 0 $self->_make( "$target 2>/dev/null" );
362 }
363 }
364  
365 =head2 $smoker->extra_manicheck( )
366  
367 C<extra_manicheck()> will only work for C<< $self->{v} > 1 >> and does
368 an extra integrity check comparing F<MANIFEST> and the
369 source-tree. Output is send to the tty.
370  
371 =cut
372  
373 0 ▶sub extra_manicheck {
Subroutine extra_manicheck: not called CC=5 SCAR=34.0
Pod documented
374 0 my $self = shift;
375 0 ▶ $self->{v} > 1 or return;
Branch: 1 branch
BranchTrueFalseTotal
$self->{"v"} > 1 or return 0 0 0
376  
377 0 require Test::Smoke::SourceTree;
378 0 Test::Smoke::SourceTree->import( qw( :mani_const ) );
379 0 my $tree = Test::Smoke::SourceTree->new( $self->{ddir} );
380 0 my $mani_check = $tree->check_MANIFEST(qw( mktest.out mktest.rpt ));
381 0 foreach my $file ( sort keys %$mani_check ) {
382 0 ▶ if ( $mani_check->{ $file } == ST_MISSING() ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($mani_check->{$file} == ST_MISSING()) { } 0 0 0
elsif ($mani_check->{$file} == ST_UNDECLARED()) { } 0 0 0
383 0 $self->tty( "manicheck: missing '$file' (not in source-tree)\n" );
384 } elsif ( $mani_check->{ $file } == ST_UNDECLARED() ) {
385 0 $self->tty( "manicheck: extra '$file' (not in MANIFEST)\n" );
386 }
387 }
388 }
389  
390 =head2 $smoker->handle_policy( $policy, @substs );
391  
392 C<handle_policy()> will try to apply the substition rules and then
393 write the file F<Policy.sh>.
394  
395 =cut
396  
397 0 ▶sub handle_policy {
Subroutine handle_policy: not called CC=4 SCAR=30.0
Pod documented
398 0 my $self = shift;
399 0 my( $policy, @substs ) = @_;
400  
401 0 ▶ return unless UNIVERSAL::isa( $policy, 'Test::Smoke::Policy' );
Branch: 1 branch
BranchTrueFalseTotal
unless UNIVERSAL::isa($policy, "Test::Smoke::Policy") 0 0 0
402  
403 0 $self->tty( "\nCopy Policy.sh ..." );
404 0 $policy->reset_rules;
405 0 ▶ if ( @substs ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@substs) 0 0 0
406 0 $policy->set_rules( $_ ) foreach @substs;
407 }
408 0 $policy->write;
409 }
410  
411 =head2 $smoker->Configure( $config )
412  
413 C<Configure()> sorts out the MSWin32 mess and calls F<./Configure>
414  
415 returns true if a makefile was created
416  
417 =cut
418  
419 0 ▶sub Configure {
Subroutine Configure: not called CC=4 SCAR=30.0
Pod documented
420 0 my $self = shift;
421 0 my( $config, $policy ) = @_;
422  
423 0 $self->tty( "\nConfigure ..." );
424 0 my $makefile = '';
425 0 ▶ if ( $self->{is_win32} ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->{'is_win32'}) { } 0 0 0
elsif ($self->{'is_vms'}) { } 0 0 0
426 0 my @w32args = @{ $self->{w32args} };
427 0 @w32args = @w32args[ 4 .. $#w32args ];
428 0 ▶ my $w32_cfg = "$config" =~ /-DCCTYPE=/
Branch: 1 branch
BranchTrueFalseTotal
"$config" =~ /-DCCTYPE=/ ? : 0 0 0
429 ? "$config" : "$config -DCCTYPE=$self->{w32cc}";
430  
431 $makefile = $self->_run( "./Configure $w32_cfg",
432 \&Test::Smoke::Util::Configure_win32,
433 0 $self->{w32make}, @w32args );
434 } elsif ( $self->{is_vms} ) {
435 0 my $vms_cfg = $config->vms;
436 0 $self->_run( qq/\@configure -"des" $vms_cfg/ );
437 0 $makefile = 'DESCRIP.MMS';
438 } else {
439 0 $self->_run( "./Configure -des $config" );
440 0 $makefile = 'Makefile';
441 }
442 0 return -f $makefile;
443 }
444  
445 =head2 $smoker->make_( )
446  
447 C<make_()> will run make.
448  
449 returns true if a perl executable is found
450  
451 =cut
452  
453 0 ▶sub make_ {
Subroutine make_: not called CC=17 SCAR=57.2
Pod documented
454 0 my $self = shift;
455 0 my $config = shift;
456  
457 0 $self->tty( "\nmake ..." );
458 0 my $make_args = "";
459 0 ▶ $self->{is_vms} && $config->has_arg( '-Dusevmsdebug' ) and
Branch: 1 branch
BranchTrueFalseTotal
$self->{"is_vms"} and $config->has_arg("-Dusevmsdebug") and $make_args = "/macro=(\"__DEBUG__=1\")" 0 0 0
Condition0%0/3
$self->{"is_vms"} and $config->has_arg("-Dusevmsdebug")
!ll&&!rl&&r
000
MC/DC0%0/2
$self->{"is_vms"} and $config->has_arg("-Dusevmsdebug")
$self->{"is_vms"} $config->has_arg("-Dusevmsdebug")
Truth table0%0/3
A and B
A= $self->{"is_vms"}B= $config->has_arg("-Dusevmsdebug")
ABresult
0X0
100
111
460 $make_args = qq[/macro=("__DEBUG__=1")];
461  
462 0 ▶ $self->{is_win32} && $config->has_arg( '-Uuseshrplib' ) and
Branch: 1 branch
BranchTrueFalseTotal
$self->{"is_win32"} and $config->has_arg("-Uuseshrplib") and $make_args = "static" 0 0 0
Condition0%0/3
$self->{"is_win32"} and $config->has_arg("-Uuseshrplib")
!ll&&!rl&&r
000
MC/DC0%0/2
$self->{"is_win32"} and $config->has_arg("-Uuseshrplib")
$self->{"is_win32"} $config->has_arg("-Uuseshrplib")
Truth table0%0/3
A and B
A= $self->{"is_win32"}B= $config->has_arg("-Uuseshrplib")
ABresult
0X0
100
111
463 $make_args = "static";
464  
465 0 my $make_output = $self->_make( $make_args );
466  
467 0 ▶ if ( $self->{is_win32} ) { # Win32 creates config.sh during make
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"is_win32"}) 0 0 0
468 0 my %cinfo = get_smoked_Config( $self->{ddir} => qw(
469 cc ccversion gccversion
470 ));
471 0 ▶ my $version = $cinfo{gccversion} || $cinfo{ccversion};
Condition0%0/3
$cinfo{'gccversion'} || $cinfo{'ccversion'}
l!l&&r!l&&!r
000
MC/DC0%0/2
$cinfo{'gccversion'} || $cinfo{'ccversion'}
$cinfo{'gccversion'} $cinfo{'ccversion'}
Truth table0%0/3
A || B
A= $cinfo{'gccversion'}B= $cinfo{'ccversion'}
ABresult
1X1
011
000
472 $self->log( "\nCompiler info: $cinfo{cc} version $version\n" )
473 0 ▶ if $cinfo{cc};
Branch: 1 branch
BranchTrueFalseTotal
if $cinfo{"cc"} 0 0 0
474  
475 0 ▶ $self->{w32cc} =~ /MSVC|BORLAND|GCC/ and $self->tty( "\n$make_output\n" );
Branch: 1 branch
BranchTrueFalseTotal
$self->{"w32cc"} =~ /MSVC|BORLAND|GCC/ and $self->tty("\n$make_output\n") 0 0 0
476 }
477  
478 0 ▶ my $exe_ext = $Config{_exe} || $Config{exe_ext};
Condition0%0/3
$Test::Smoke::Smoker::Config{'_exe'} || $Test::Smoke::Smoker::Config{'exe_ext'}
l!l&&r!l&&!r
000
MC/DC0%0/2
$Test::Smoke::Smoker::Config{'_exe'} || $Test::Smoke::Smoker::Config{'exe_ext'}
$Test::Smoke::Smoker::Config{'_exe'} $Test::Smoke::Smoker::Config{'exe_ext'}
Truth table0%0/3
A || B
A= $Test::Smoke::Smoker::Config{'_exe'}B= $Test::Smoke::Smoker::Config{'exe_ext'}
ABresult
1X1
011
000
479 0 my $miniperl = "miniperl$exe_ext";
480 0 my $perl = "perl$exe_ext";
481 $perl = "ndbg$perl"
482 0 ▶ if $self->{is_vms} && $config->has_arg( '-Dusevmsdebug' );
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"is_vms"} and $config->has_arg("-Dusevmsdebug") 0 0 0
Condition0%0/3
$self->{"is_vms"} and $config->has_arg("-Dusevmsdebug")
!ll&&!rl&&r
000
MC/DC0%0/2
$self->{"is_vms"} and $config->has_arg("-Dusevmsdebug")
$self->{"is_vms"} $config->has_arg("-Dusevmsdebug")
Truth table0%0/3
A and B
A= $self->{"is_vms"}B= $config->has_arg("-Dusevmsdebug")
ABresult
0X0
100
111
483 $perl = "perl-static$exe_ext"
484 0 ▶ if $self->{is_win32} && $config->has_arg( '-Uuseshrplib' );
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"is_win32"} and $config->has_arg("-Uuseshrplib") 0 0 0
Condition0%0/3
$self->{"is_win32"} and $config->has_arg("-Uuseshrplib")
!ll&&!rl&&r
000
MC/DC0%0/2
$self->{"is_win32"} and $config->has_arg("-Uuseshrplib")
$self->{"is_win32"} $config->has_arg("-Uuseshrplib")
Truth table0%0/3
A and B
A= $self->{"is_win32"}B= $config->has_arg("-Uuseshrplib")
ABresult
0X0
100
111
485  
486 0 $self->{_miniperl_bin} = $miniperl;
487 0 $self->{_perl_bin} = $perl;
488  
489 0 ▶ -x $miniperl or return BUILD_NOTHING;
Branch: 1 branch
BranchTrueFalseTotal
-x $miniperl or return 0 0 0 0
490 return -x $perl
491 0 ▶ ? $self->{_run_exit} ? BUILD_MINIPERL : BUILD_PERL
Branch: 2 branches
BranchTrueFalseTotal
-x $perl ? : 0 0 0
$self->{'_run_exit'} ? : 0 0 0
492 : BUILD_MINIPERL;
493 }
494  
495 =head2 make_test_prep( )
496  
497 Run C<< I<make test-prep> >> and check if F<t/perl> exists.
498  
499 =cut
500  
501 0 ▶sub make_test_prep {
Subroutine make_test_prep: not called CC=4 SCAR=30.0
Pod documented
502 0 my $self = shift;
503 0 ▶ $self->{harnessonly} and return 1; # no test-prep target
Branch: 1 branch
BranchTrueFalseTotal
$self->{"harnessonly"} and return 1 0 0 0
504  
505 0 my $perl = catfile( "t", $self->{_perl_bin} );
506  
507 0 ▶ $self->{run} and unlink $perl;
Branch: 1 branch
BranchTrueFalseTotal
$self->{"run"} and unlink $perl 0 0 0
508 0 $self->_make( "test-prep" );
509  
510 0 ▶ return $self->{is_win32} ? -f $perl : -l $perl;
Branch: 1 branch
BranchTrueFalseTotal
$self->{'is_win32'} ? : 0 0 0
511 }
512  
513 =head2 $smoker->make_test( )
514  
515 =cut
516  
517 0 ▶sub make_test {
Subroutine make_test: not called CC=19 SCAR=59.4
Pod documented
518 0 my $self = shift;
519  
520 0 $self->set_skip_tests;
521  
522 0 my( $config ) = @_;
523 0 my $config_args = "$config";
524  
525 0 $self->tty( "\n Tests start here:\n" );
526  
527 # No use testing different io layers without PerlIO
528 # just output 'stdio' for tssendrpt.pl
529 0 my @layers = qw/ perlio /;
530  
531 0 my @locales;
532 0 ▶ if ( !($config_args =~ /-Uuseperlio\b/ || $self->{defaultenv}) &&
Branch: 1 branch
BranchTrueFalseTotal
if (not $config_args =~ /-Uuseperlio\b/ || $self->{"defaultenv"} and $self->{"locale"}) 0 0 0
Condition0%0/6
not $config_args =~ /-Uuseperlio\b/ || $self->{"defaultenv"} and $self->{"locale"}
!ll&&!rl&&r
000
$config_args =~ /-Uuseperlio\b/ || $self->{'defaultenv'}
l!l&&r!l&&!r
000
MC/DC0%0/3
not $config_args =~ /-Uuseperlio\b/ || $self->{"defaultenv"} and $self->{"locale"}
$config_args =~ /-Uuseperlio\b/ $self->{'defaultenv'} $self->{"locale"}
Truth table0%0/4
not(A || B) and C
A= $config_args =~ /-Uuseperlio\b/B= $self->{'defaultenv'}C= $self->{"locale"}
ABCresult
1XX0
01X0
0000
0011
533 $self->{locale} ) {
534 0 @locales = split ' ', $self->{locale};
535 0 push @layers, ( 'locale' ) x @locales;
536 }
537  
538 0 delete $ENV{PERL_UNICODE};
539 0 foreach my $perlio ( @layers ) {
540 0 my $had_LC_ALL = exists $ENV{LC_ALL};
541 local( $ENV{PERLIO}, $ENV{LC_ALL} ) =
542 0 ▶ ( "", defined $ENV{LC_ALL} ? $ENV{LC_ALL} : "" );
Branch: 1 branch
BranchTrueFalseTotal
defined $ENV{'LC_ALL'} ? : 0 0 0
543 0 my $perlio_logmsg = $perlio;
544 0 ▶ if ( $perlio ne 'locale' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($perlio ne 'locale') { } 0 0 0
545 0 $ENV{PERLIO} = $perlio;
546 0 ▶ $self->{is_win32} and $ENV{PERLIO} .= " :crlf";
Branch: 1 branch
BranchTrueFalseTotal
$self->{"is_win32"} and $ENV{"PERLIO"} .= ' :crlf' 0 0 0
547 0 ▶ $ENV{LC_ALL} = 'C' if $self->{force_c_locale};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"force_c_locale"} 0 0 0
548 0 ▶ $ENV{LC_ALL} or delete $ENV{LC_ALL};
Branch: 1 branch
BranchTrueFalseTotal
$ENV{"LC_ALL"} or delete $ENV{"LC_ALL"} 0 0 0
549 # make default 'make test' runs possible
550 0 ▶ delete $ENV{PERLIO} if $self->{defaultenv};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"defaultenv"} 0 0 0
551 } else {
552 0 my $this_locale = pop(@locales);
553 0 $ENV{LC_ALL} = $this_locale;
554 0 $perlio_logmsg .= ":$this_locale";
555 }
556 0 $self->ttylog( "TSTENV = $perlio_logmsg\t" );
557  
558 0 ▶ unless ( $self->{run} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"run"}) 0 0 0
559 0 $self->ttylog( "bailing out (--norun)...\n" );
560 0 next;
561 }
562  
563 0 ▶ if ( $self->{harnessonly} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'harnessonly'}) { } 0 0 0
564 0 $self->log_debug("[make test] Test::Harness ONLY");
565  
566 $self->{harness3opts} and
567 0 ▶ local $ENV{HARNESS_OPTIONS} = $self->{harness3opts};
Branch: 1 branch
BranchTrueFalseTotal
$self->{"harness3opts"} and local $ENV{"HARNESS_OPTIONS"} = $self->{"harness3opts"} 0 0 0
568  
569 0 $self->make_test_harness( $config );
570  
571 } else {
572 my $test_target = $self->{is_vms}
573 0 ▶ ? 'test' : $self->{is56x} ? 'test-notty' : '_test';
Branch: 2 branches
BranchTrueFalseTotal
$self->{'is_vms'} ? : 0 0 0
$self->{'is56x'} ? : 0 0 0
574  
575 # MSWin32 builds from its own directory
576 0 ▶ if ( $self->{is_win32} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'is_win32'}) { } 0 0 0
577 # $config->has_arg( '-Uuseshrplib' )
578 # and $test_target = 'static-test';
579 # $self->_run_harness_target( $test_target );
580 0 $self->make_test_harness( $config );
581 } else {
582 0 $self->_run_TEST_target( $test_target, 1 );
583 }
584 0 $self->tty( "\n" );
585 }
586 0 ▶ !$had_LC_ALL && exists $ENV{LC_ALL} and delete $ENV{LC_ALL};
Branch: 1 branch
BranchTrueFalseTotal
not $had_LC_ALL and exists $ENV{"LC_ALL"} and delete $ENV{"LC_ALL"} 0 0 0
Condition0%0/3
not $had_LC_ALL and exists $ENV{"LC_ALL"}
!ll&&!rl&&r
000
MC/DC0%0/2
not $had_LC_ALL and exists $ENV{"LC_ALL"}
not $had_LC_ALL exists $ENV{"LC_ALL"}
Truth table0%0/3
not(A) and B
A= not $had_LC_ALLB= exists $ENV{"LC_ALL"}
ABresult
0X0
100
111
587 }
588  
589 0 $self->unset_skip_tests;
590  
591 0 return 1;
592 }
593  
594 =head2 $self->extend_with_harness( @nok )
595  
596 =cut
597  
598 0 ▶sub extend_with_harness {
Subroutine extend_with_harness: not called CC=13 SCAR=52.0
Pod documented
599 0 my $self = shift;
600 0 my %inconsistent = $self->_transform_testnames( @_ );
601 0 my @harness = sort keys %inconsistent;
602 0 my $harness_re1 = HARNESS_RE1();
603 0 my $harness_re2 = HARNESS_RE2();
604 0 ▶ if ( @harness ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@harness) 0 0 0
605  
606 # @20051016 By request of Nicholas Clark
607 0 local $ENV{PERL_DESTRUCT_LEVEL} = $self->{harness_destruct};
608 0 local $ENV{PERL_SKIP_TTY_TEST} = 1;
609  
610 # I'm not happy with this PERLSHR approach for VMS
611 0 ▶ local $ENV{PERLSHR} = $ENV{PERLSHR} || "";
Condition0%0/2
$ENV{'PERLSHR'} || ''
l!l
00
MC/DC0%0/1
$ENV{'PERLSHR'} || ''
$ENV{'PERLSHR'}
Truth table0%0/2
A
A= $ENV{'PERLSHR'}
Aresult
11
00
612 $self->{is_vms} and
613 $ENV{PERLSHR} = catfile( $self->{ddir},
614 0 ▶ 'PERLSHR' . $Config{_exe} );
Branch: 1 branch
BranchTrueFalseTotal
$self->{"is_vms"} and $ENV{"PERLSHR"} = catfile($self->{"ddir"}, 'PERLSHR' . $Test::Smoke::Smoker::Config{"_exe"}) 0 0 0
615 0 my $harness = join " ", @harness;
616 0 $self->tty( "\nExtending failures with harness:\n\t$harness\n" );
617 0 my $changed_dir;
618 0 ▶ chdir 't' and $changed_dir = 1;
Branch: 1 branch
BranchTrueFalseTotal
chdir "t" and $changed_dir = 1 0 0 0
619 0 my $all_ok = 0;
620 0 my $tst_perl = catfile( curdir(), 'perl' );
621 0 ▶ my $verbose = $self->{v} > 1 ? "-v" : "";
Branch: 1 branch
BranchTrueFalseTotal
$self->{'v'} > 1 ? : 0 0 0
622 0 my @run_harness = $self->_run( "$tst_perl harness $verbose $harness" );
623 0 my $harness_out = $self->_parse_harness_output( \%inconsistent, $all_ok,
624 @run_harness );
625  
626 # safeguard against empty results
627 0 ▶ $inconsistent{ $_ } ||= 'FAILED' for keys %inconsistent;
Condition0%0/2
$inconsistent{$_} ||= "FAILED"
l!l
00
MC/DC0%0/1
$inconsistent{$_} ||= "FAILED"
$inconsistent{$_}
Truth table0%0/2
A
A= $inconsistent{$_}
Aresult
11
00
628 0 $harness_out =~ s/^\s*$//;
629 0 ▶ if ( $all_ok ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($all_ok) { } 0 0 0
630 $harness_out .= scalar keys %inconsistent
631 ? "Inconsistent test results (between TEST and harness):\n" .
632 join "", map {
633 0 ▶ my $dots = '.' x (40 - length $_ );
Branch: 1 branch
BranchTrueFalseTotal
scalar keys %inconsistent ? : 0 0 0
634 0 ▶ " $_${dots}$inconsistent{ $_ }\n";
Branch: 1 branch
BranchTrueFalseTotal
$harness_out ? : 0 0 0
635 } keys %inconsistent
636 : $harness_out ? "" : "All tests successful.";
637 } else {
638 $harness_out .= scalar keys %inconsistent
639 ? "Inconsistent test results (between TEST and harness):\n" .
640 join "", map {
641 0 ▶ my $dots = '.' x (40 - length $_ );
Branch: 1 branch
BranchTrueFalseTotal
scalar keys %inconsistent ? : 0 0 0
642 0 " $_${dots}$inconsistent{ $_ }\n";
643 } keys %inconsistent
644 : "";
645 }
646 0 $self->ttylog("\n", $harness_out, "\n" );
647 0 ▶ $changed_dir and chdir updir();
Branch: 1 branch
BranchTrueFalseTotal
$changed_dir and chdir ".." 0 0 0
648 }
649 }
650  
651 =head2 $smoker->make_test_harness
652  
653 Use Test::Harness (the test_harness target) to get the failing test
654 information and do not bother with TEST.
655  
656 =cut
657  
658 0 ▶sub make_test_harness {
Subroutine make_test_harness: not called CC=6 SCAR=37.4
Pod documented
659 0 my( $self, $config ) = @_;
660  
661 0 my $target= "test_harness";
662 0 my $debugging = "";
663  
664 0 ▶ if ( $self->{is_vms} ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->{'is_vms'}) { } 0 0 0
elsif ($self->{'is_win32'}) { } 0 0 0
665  
666 0 ▶ $debugging = $config->has_arg( '-Dusevmsdebug' )
Branch: 1 branch
BranchTrueFalseTotal
$config->has_arg('-Dusevmsdebug') ? : 0 0 0
667 ? qq[/macro=("__DEBUG__=1")]
668 : "";
669  
670 } elsif ($self->{is_win32}) {
671 0 ▶ $target = $config->has_arg( '-Uuseshrplib' ) ? "static-test" : "test";
Branch: 1 branch
BranchTrueFalseTotal
$config->has_arg('-Uuseshrplib') ? : 0 0 0
672 }
673  
674 0 ▶ if ( $self->{hasharness3} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'hasharness3'}) { } 0 0 0
675 0 $self->log_debug("[make_test_harness] Test::Harness >= 3");
676 0 $self->_run_harness3_target( $target, $debugging );
677 } else {
678 0 $self->log_debug("[make_test_harness] Test::Harness < 3");
679 0 $self->_run_harness_target( $target, $debugging );
680 }
681 }
682  
683 =head2 $smoker->_run_harness_target( $target, $extra )
684  
685 The command to run C<make test_harness> differs based on platform, so
686 the arguments have to be passed into general routine. C<$target>
687 specifies the makefile-target, C<$makeopt> specifies the extra options
688 for the make program.
689  
690 =cut
691  
692 0 ▶sub _run_harness_target {
Subroutine _run_harness_target: not called CC=11 SCAR=48.8
693 0 my( $self, $target, $extra ) = @_;
694  
695 0 my $seenheader = 0;
696 0 my @failed = ( );
697  
698 0 my $harness_re1 = HARNESS_RE1();
699 0 my $harness_re2 = HARNESS_RE2();
700  
701 0 my $tst = $self->_make_fork( $target, $extra );
702  
703 0 my ($line, $last);
704 0 ▶ while ( $line = <$tst> ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($line = readline $tst)) 0 0 0
705 #$self->log_debug($line);
706  
707 # This line with timings only has to be logged to .out.
708 0 ▶ $line =~ / \b (?:Files | u) = .+ Tests = [0-9]+ /xi
Branch: 1 branch
BranchTrueFalseTotal
$line =~ / \b (?:Files | u) = .+ Tests = [0-9]+ /xi and $self->log($line) 0 0 0
709 and $self->log($line);
710  
711 0 ▶ $last and next;
Branch: 1 branch
BranchTrueFalseTotal
$last and next 0 0 0
712 0 ▶ $line =~ /All tests successful/
Branch: 1 branch
BranchTrueFalseTotal
$line =~ /All tests successful/ and push(@failed, $line), ++$last, next 0 0 0
713 and push( @failed, $line ), $last++, next;
714  
715 0 ▶ $line =~ /Failed Test\s+Stat/
Branch: 1 branch
BranchTrueFalseTotal
$line =~ /Failed Test\s+Stat/ and $seenheader = 1, next 0 0 0
716 and $seenheader = 1, next;
717 0 ▶ $seenheader or next;
Branch: 1 branch
BranchTrueFalseTotal
$seenheader or next 0 0 0
718  
719 0 my( $name, $fail ) = $line =~ m/$harness_re1/;
720 0 ▶ if ( $name ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($name) { } 0 0 0
721 0 my $dots = '.' x (40 - length $name );
722 0 $self->log_debug("[known failed test] $name");
723 0 push @failed, " $name${dots}FAILED $fail\n";
724 } else {
725 0 ( $fail ) = $line =~ m/$harness_re2/;
726 0 ▶ next unless $fail;
Branch: 1 branch
BranchTrueFalseTotal
unless $fail 0 0 0
727 0 push @failed, " " x 51 . "$fail\n";
728 }
729 }
730 0 my @dump = <$tst>; # Read trailing output from pipe
731  
732 0 ▶ close $tst or do {
Branch: 1 branch
BranchTrueFalseTotal
close $tst or do { my $error = $! || $? >> 8; require Carp; Carp::carp("\nerror while running harness target '${target}': $error") } 0 0 0
733 0 ▶ my $error = $! || ( $? >> 8);
Condition0%0/3
$! || $? >> 8
l!l&&r!l&&!r
000
MC/DC0%0/2
$! || $? >> 8
$! $? >> 8
Truth table0%0/3
A || B
A= $!B= $? >> 8
ABresult
1X1
011
000
734 0 require Carp;
735 0 Carp::carp("\nerror while running harness target '$target': $error");
736 };
737  
738 0 $self->ttylog( "\n", join( "", @failed ), "\n" );
739 0 $self->tty( "Archived results...\n" );
740 }
741  
742 =head2 $smoker->_run_harness3_target( $target, $extra )
743  
744 The command to run C<make test_harness> differs based on platform, so
745 the arguments have to be passed into general routine. C<$target>
746 specifies the makefile-target, C<$makeopt> specifies the extra options
747 for the make program.
748  
749 =cut
750  
751 0 ▶sub _run_harness3_target {
Subroutine _run_harness3_target: not called CC=18 SCAR=58.3
752 0 my( $self, $target, $extra ) = @_;
753  
754 0 my $harness3_failed = HARNESS3_RE_FAILED();
755 0 my $harness3_todo = HARNESS3_RE_TODO();
756 0 my $harness3_extra = HARNESS3_RE_EXTRA();
757 0 my $seenheader = 0;
758 0 my @failed = ( );
759  
760 0 my $tst = $self->_make_fork( $target, $extra );
761  
762 0 my $line;
763 my $file;
764 0 my $found = 0;
765 0 ▶ while ( $line = <$tst> ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($line = readline $tst)) 0 0 0
766 #$self->log_debug($line);
767  
768 # This line with timings only has to be logged to .out.
769 0 ▶ $line =~ / \b (?:Files | u) = .+ Tests = [0-9]+ /xi
Branch: 1 branch
BranchTrueFalseTotal
$line =~ / \b (?:Files | u) = .+ Tests = [0-9]+ /xi and $self->log($line) 0 0 0
770 and $self->log($line);
771  
772 0 ▶ $line =~ /All tests successful/
Branch: 1 branch
BranchTrueFalseTotal
$line =~ /All tests successful/ and push(@failed, $line), next 0 0 0
773 and push( @failed, $line ), next;
774  
775 0 ▶ $line =~ /Test Summary Report/ and $seenheader = 1, next;
Branch: 1 branch
BranchTrueFalseTotal
$line =~ /Test Summary Report/ and $seenheader = 1, next 0 0 0
776 0 ▶ $seenheader or next;
Branch: 1 branch
BranchTrueFalseTotal
$seenheader or next 0 0 0
777  
778 0 my( $tname ) = $line =~ /^\s*(.+(?:\.t)?)\s+\(Wstat/;
779 0 ▶ if ( $tname ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tname) 0 0 0
780 0 ▶ if ($file and not $found) {
Branch: 1 branch
BranchTrueFalseTotal
if ($file and not $found) 0 0 0
Condition0%0/3
$file and not $found
!ll&&!rl&&r
000
MC/DC0%0/2
$file and not $found
$file not $found
Truth table0%0/3
A and not(B)
A= $fileB= not $found
ABresult
0X0
100
111
781 0 $self->log_debug("[weird failed test] $file");
782 0 push @failed, "${file}??????\n";
783 }
784 0 my $ntest = $self->_normalize_testname( $tname );
785 0 my $dots = '.' x (60 - length $ntest);
786 0 $file = $ntest . $dots;
787 0 $found = 0;
788 0 next;
789 }
790  
791 0 my( $failed ) = $line =~ /$harness3_failed/x;
792 0 ▶ if ( $failed ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($failed) 0 0 0
793 0 $self->log_debug("[known failed test] $file");
794 0 push @failed, "${file}FAILED\n";
795 0 push @failed, " $failed\n";
796 0 $found = 1;
797 0 next;
798 }
799  
800 0 my( $todo ) = $line =~ /$harness3_todo/x;
801 0 ▶ if ( $todo ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($todo) 0 0 0
802 0 $self->log_debug("[todo test passed] $file");
803 0 push @failed, "${file}PASSED\n";
804 0 push @failed, " $todo\n";
805 0 $found = 1;
806 0 next;
807 }
808  
809 0 my ( $extra ) = $line =~ /$harness3_extra/x;
810 0 ▶ if ( $extra) {
Branch: 1 branch
BranchTrueFalseTotal
if ($extra) 0 0 0
811 0 push @failed, " $extra\n";
812 0 next;
813 }
814  
815 0 my( $parse_error ) = $line =~ /^ Parse errors: (.+)/;
816 0 ▶ if ( $parse_error ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($parse_error) 0 0 0
817 0 $self->log_debug("[TAP-error test] $file");
818 0 push @failed, "${file}FAILED\n";
819 0 push @failed, " $parse_error\n";
820 0 $found = 1;
821 0 next;
822 }
823  
824 0 my( $exit_status ) = $line =~ /^ (Non-zero exit status: .+)/;
825 0 ▶ if ( $exit_status ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($exit_status) 0 0 0
826 0 $self->log_debug("[died test] $file");
827 0 push @failed, "${file}FAILED\n";
828 0 push @failed, " $exit_status\n";
829 0 $found = 1;
830 0 next;
831 }
832 }
833 0 ▶ if ($file and not $found) {
Branch: 1 branch
BranchTrueFalseTotal
if ($file and not $found) 0 0 0
Condition0%0/3
$file and not $found
!ll&&!rl&&r
000
MC/DC0%0/2
$file and not $found
$file not $found
Truth table0%0/3
A and not(B)
A= $fileB= not $found
ABresult
0X0
100
111
834 0 $self->log_debug("[unknown failure] $file");
835 0 push @failed, "${file}??????\n";
836 }
837  
838 0 my @dump = <$tst>; # Read trailing output from pipe
839  
840 0 ▶ close $tst or do {
Branch: 1 branch
BranchTrueFalseTotal
close $tst or do { my $error = $! || $? >> 8; require Carp; Carp::carp("\nerror while running harness target '${target}': $error") } 0 0 0
841 0 ▶ my $error = $! || ( $? >> 8);
Condition0%0/3
$! || $? >> 8
l!l&&r!l&&!r
000
MC/DC0%0/2
$! || $? >> 8
$! $? >> 8
Truth table0%0/3
A || B
A= $!B= $? >> 8
ABresult
1X1
011
000
842 0 require Carp;
843 0 Carp::carp("\nerror while running harness target '$target': $error" );
844 };
845  
846 0 $self->ttylog( "\n", join( "", @failed ), "\n" );
847 0 $self->tty( "Archived results...\n" );
848 }
849  
850 0 ▶sub _run_TEST_target {
Subroutine _run_TEST_target: not called CC=11 SCAR=48.8
851 0 my( $self, $target, $extend ) = @_;
852 0 ▶ !$target and do {
Branch: 1 branch
BranchTrueFalseTotal
$target or do { require Carp; Carp::confess("No target in _run_TEST_target") } 0 0 0
853 0 require Carp;
854 0 Carp::confess("No target in _run_TEST_target");
855 };
856  
857 0 my @nok;
858 0 my $tst = $self->_make_fork( $target );
859 0 my $ok;
860  
861 0 ▶ while (<$tst>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline $tst)) 0 0 0
862 0 $self->log_debug($_);
863 0 ▶ skip_filter( $_ ) and next;
Branch: 1 branch
BranchTrueFalseTotal
skip_filter($_) and next 0 0 0
864  
865 # make tssendrpt.pl life easier
866 0 s/(.)(TSTENV\s+=\s+\w+)/$1\n$2/;
867  
868 0 ▶ if (m/^u=.*tests=/) {
Branch: 1 branch
BranchTrueFalseTotal
if (/^u=.*tests=/) { } 0 0 0
869 0 s/(\d\.\d*) /sprintf "%.2f ", $1/ge;
870 0 $self->log( $_ );
871 } else {
872 0 ▶ $ok ||= m/^All tests successful/;
Condition0%0/3
$ok ||= /^All tests successful/
l!l&&r!l&&!r
000
MC/DC0%0/2
$ok ||= /^All tests successful/
$ok /^All tests successful/
Truth table0%0/3
A ||= B
A= $okB= /^All tests successful/
ABresult
1X1
011
000
873 0 push @nok, $_;
874 }
875 0 $self->tty( $_ );
876 }
877 0 ▶ close $tst or do {
Branch: 1 branch
BranchTrueFalseTotal
close $tst or do { my $error = $! || $? >> 8; $self->tty("\nError while reading test-results: $error") } 0 0 0
878 0 ▶ my $error = $! || ( $? >> 8);
Condition0%0/3
$! || $? >> 8
l!l&&r!l&&!r
000
MC/DC0%0/2
$! || $? >> 8
$! $? >> 8
Truth table0%0/3
A || B
A= $!B= $? >> 8
ABresult
1X1
011
000
879 0 $self->tty("\nError while reading test-results: $error");
880 };
881  
882 # $self->log( map { " $_" } @nok );
883 0 ▶ if ( grep m/^All tests successful/, @nok ) {
Branch: 2 branches
BranchTrueFalseTotal
if (grep /^All tests successful/, @nok) { } 0 0 0
elsif (not $extend) { } 0 0 0
884 0 $self->log( "All tests successful.\n" );
885 0 $self->tty( "\nOK, archive results ..." );
886 $self->{patch} and
887 0 ▶ $nok[0] =~ s/\./ for .patch = $self->{patch}./;
Branch: 1 branch
BranchTrueFalseTotal
$self->{"patch"} and $nok[0] =~ s/\./ for .patch = $self->{"patch"}./ 0 0 0
888 } elsif ( !$extend ) {
889 0 $self->ttylog( map { " $_" } @nok );
890 } else {
891 0 $self->extend_with_harness( @nok );
892 }
893 }
894  
895 =head2 $self->make_minitest
896  
897 C<make> was unable to build a I<perl> executable, but managed to build
898 I<miniperl>, so we do C<< S<make minitest> >>.
899  
900 =cut
901  
902 0 ▶sub make_minitest {
Subroutine make_minitest: not called CC=2 SCAR=17.9
Pod documented
903 0 my $self = shift;
904  
905 0 $self->ttylog( "TSTENV = minitest\t" );
906  
907 0 ▶ if ($self->{is_win32}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'is_win32'}) { } 0 0 0
908 0 $self->_run_harness_target( "minitest" );
909 } else {
910 0 $self->_run_TEST_target( "minitest", 0 );
911 }
912  
913 0 $self->tty( "\n" );
914 0 return 1;
915 }
916  
917 =head2 $self->_parse_harness_output( $\%notok, $all_ok, @lines )
918  
919 Factor out the parsing of the Test::Harness output, as it seems subject
920 to change.
921  
922 =cut
923  
924 17 ▶sub _parse_harness_output {
Subroutine _parse_harness_output: called CC=5 SCAR=16.1
925 17 my( $self, $notok, $all_ok, @lines ) = @_;
926  
927 17 ▶ grep m/^Test Summary Report/ => @lines
Branch: 1 branch
BranchTrueFalseTotal
grep /^Test Summary Report/, @lines and return $self->_parse_harness3_output($notok, $_[2], @lines) 12 5 17
928 and return $self->_parse_harness3_output( $notok, $_[2], @lines );
929  
930 5 my $harness_re1 = HARNESS_RE1();
931 5 my $harness_re2 = HARNESS_RE2();
932  
933 my $output = join "", map {
934 16 my( $name, $fail ) = m/$harness_re1/;
935 16 ▶ if ( $name ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($name) { } 10 6 16
936 10 delete $notok->{ $name };
937 10 my $dots = '.' x (40 - length $name );
938 10 " $name${dots}FAILED $fail\n";
939 } else {
940 6 ( $fail ) = m/$harness_re2/;
941 6 ▶ " " x 51 . "$fail\n";
Condition100%3/3
/$harness_re2/ || /$harness_re1/
l!l&&r!l&&!r
61012
MC/DC100%2/2
/$harness_re2/ || /$harness_re1/
/$harness_re2/ /$harness_re1/
Truth table100%3/3
A || B
A= /$harness_re2/B= /$harness_re1/
ABresult
1X1
011
000
942 }
943 } grep m/$harness_re2/ || m/$harness_re1/ => map {
944 5 ▶ /All tests successful/ && $all_ok++;
Branch: 1 branch
BranchTrueFalseTotal
/All tests successful/ and ++$all_ok 0 28 28
945 28 $self->log_info( $_ );
946 28 $_;
947 } @lines;
948  
949 5 $_[2] = $all_ok;
950 5 return $output;
951 }
952  
953 =head2 $self->_parse_harness3_output( $\%notok, $all_ok, @lines )
954  
955 Fator out the parsing of the Test::Harness 3 output, as it seems subject
956 to change.
957  
958 =cut
959  
960 12 ▶sub _parse_harness3_output {
Subroutine _parse_harness3_output: called CC=15 SCAR=27.1
961 12 my( $self, $notok, $all_ok, @lines ) = @_;
962  
963 12 my $harness3_failed = HARNESS3_RE_FAILED();
964 12 my $harness3_todo = HARNESS3_RE_TODO();
965 12 my $harness3_extra = HARNESS3_RE_EXTRA();
966 12 my $seenheader = 0;
967 12 my $ntest = "";
968 12 my $file = "";
969 12 my $found = 0;
970  
971 my @out = map {
972 130 my $line = $_;
973  
974 130 my( $tname ) = $line =~ /^\s*(.+(:?\.t)?)\s+\(Wstat/;
975 130 my( $failed ) = $line =~ /$harness3_failed/x;
976 130 my( $todo ) = $line =~ /$harness3_todo/x;
977 130 my( $extra ) = $line =~ /$harness3_extra/x;
978 130 my( $parse_error ) = $line =~ /^ Parse errors: (.+)/;
979 130 my( $exit_status ) = $line =~ /^ (Non-zero exit status: .+)/;
980  
981 130 ▶ if ( $tname ) {
Branch: 6 branches
BranchTrueFalseTotal
if ($tname) { } 22 108 130
elsif ($failed) { } 9 99 108
elsif ($todo) { } 14 85 99
elsif ($extra) { } 23 62 85
elsif ($parse_error) { } 7 55 62
elsif ($exit_status) { } 6 49 55
982 22 my $r;
983 22 ▶ if ($file and not $found) {
Branch: 1 branch
BranchTrueFalseTotal
if ($file and not $found) 0 22 22
Condition66%2/3
$file and not $found
!ll&&!rl&&r
12100
MC/DC0%0/2
$file and not $found
$file not $found
Truth table66%2/3
A and not(B)
A= $fileB= not $found
ABresult
0X0
100
111
984 0 $r = "${file}??????\n";
985 }
986  
987 22 $ntest = $self->_normalize_testname( $tname );
988 22 my $dots = '.' x (60 - length $ntest);
989 22 $file = " $ntest${dots}";
990 22 $found = 0;
991 22 $r;
992 } elsif ( $failed ) {
993 9 delete $notok->{ $ntest };
994 9 $found = 1;
995 9 ($file . "FAILED\n", " $failed\n");
996 } elsif ( $todo ) {
997 14 $found = 1;
998 14 ($file . "PASSED\n", " $todo\n");
999 } elsif ($extra) {
1000 23 " $extra\n"
1001 } elsif ( $parse_error ) {
1002 7 delete $notok->{ $ntest };
1003 7 $found = 1;
1004 7 ($file . "FAILED\n", " $parse_error\n");
1005 } elsif ( $exit_status ) {
1006 6 delete $notok->{ $ntest };
1007 6 $found = 1;
1008 6 ($file . "FAILED\n", " $exit_status\n");
1009 } else {
1010 49 ▶ undef;
Condition66%2/3
defined $_ && length $_
!ll&&!rl&&r
0166130
MC/DC50%1/2
defined $_ && length $_
defined $_ length $_
Truth table66%2/3
A && B
A= defined $_B= length $_
ABresult
0X0
100
111
1011 }
1012 } grep defined $_ && length $_ => map {
1013 12 ▶ $seenheader or $seenheader = $_ =~ /Test Summary Report/;
Branch: 1 branch
BranchTrueFalseTotal
$seenheader or $seenheader = $_ =~ /Test Summary Report/ 118 178 296
1014 296 ▶ /All tests successful/ && $all_ok++;
Branch: 1 branch
BranchTrueFalseTotal
/All tests successful/ and ++$all_ok 2 294 296
1015 296 $self->log_info($_);
1016 296 ▶ $seenheader ? $_ : '';
Branch: 1 branch
BranchTrueFalseTotal
$seenheader ? : 130 166 296
1017 } @lines;
1018 12 ▶ if ($file and not $found) {
Branch: 1 branch
BranchTrueFalseTotal
if ($file and not $found) 1 11 12
Condition66%2/3
$file and not $found
!ll&&!rl&&r
0111
MC/DC50%1/2
$file and not $found
$file not $found
Truth table66%2/3
A and not(B)
A= $fileB= not $found
ABresult
0X0
100
111
1019 1 push @out, "${file}??????\n";
1020 }
1021 12 my $output = join "", grep defined $_ => @out;
1022  
1023 12 $_[2] = $all_ok;
1024 12 return $output;
1025 }
1026  
1027 =head2 $self->_transform_testnames( @notok )
1028  
1029 C<_transform_testnames()> takes a list of testnames, as found by
1030 C<TEST> (testname without C<.t> suffix followed by dots and a reason)
1031 and returns a hash with the filenames relative to the C<t/> directory
1032 as keys and the reason as value.
1033  
1034 =cut
1035  
1036 1 ▶sub _transform_testnames {
Subroutine _transform_testnames: called CC=4 SCAR=14.3
1037 1 my( $self, @notok ) = @_;
1038 1 my %inconsistent;
1039 1 for my $nok ( @notok ) {
1040 4 ▶ $nok =~ m!^((?:\.\.[\\/])?\w+[\\/][-\w/\\]+)\.*(.*)! or next;
Branch: 1 branch
BranchTrueFalseTotal
$nok =~ m(^((?:\.\.[\\/])?\w+[\\/][-\w/\\]+)\.*(.*)) or next 4 0 4
1041 4 my( $test_name, $status ) = ( $1, $2 );
1042  
1043 4 my $test_path = $self->_normalize_testname( $test_name );
1044  
1045 4 ▶ $inconsistent{ $test_path } ||= $status;
Condition33%1/3
$inconsistent{$test_path} ||= $status
l!l&&r!l&&!r
040
MC/DC0%0/2
$inconsistent{$test_path} ||= $status
$inconsistent{$test_path} $status
Truth table33%1/3
A ||= B
A= $inconsistent{$test_path}B= $status
ABresult
1X1
011
000
1046 }
1047 1 return %inconsistent;
1048 }
1049  
1050 =head2 $smoker->_normalize_testname( $test )
1051  
1052 Normalize a testname...
1053  
1054 =cut
1055  
1056 30 ▶sub _normalize_testname {
Subroutine _normalize_testname: called CC=6 SCAR=18.0
1057 30 my( $self, $test_name ) = @_;
1058  
1059 30 $test_name =~ s/\s+$//;
1060 30 ▶ $test_name =~ /\.t$/ or $test_name .= '.t';
Branch: 1 branch
BranchTrueFalseTotal
$test_name =~ /\.t$/ or $test_name .= '.t' 24 6 30
1061 30 ▶ if ( $test_name !~ m|^\Q../| ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($test_name =~ m[^\.\.\/]) 28 2 30
1062 28 ▶ $test_name = $test_name =~ /^(?:cpan|dist|ext|lib|t)\b/
Branch: 1 branch
BranchTrueFalseTotal
$test_name =~ /^(?:cpan|dist|ext|lib|t)\b/ ? : 5 23 28
1063 ? catfile( updir(), $test_name )
1064 : catfile( updir(), 't', $test_name );
1065 }
1066  
1067 30 my $test_base = catdir( $self->{ddir}, 'pod' );
1068 30 $test_name = rel2abs( $test_name, $test_base );
1069  
1070 30 my $test_path = abs2rel( $test_name, $test_base );
1071 30 ▶ $test_path =~ tr!\\!/! if $self->{is_win32};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"is_win32"} 0 30 30
1072  
1073 # sometimes ../t is optimized away
1074 30 ▶ $test_path !~ m|^\.\.[\\/]| and $test_path = "../t/$test_path";
Branch: 1 branch
BranchTrueFalseTotal
$test_path =~ m[^\.\.[\\/]] or $test_path = "../t/$test_path" 30 0 30
1075  
1076 30 return $test_path;
1077 }
1078  
1079 =head2 set_skip_tests( [$unset] )
1080  
1081 Read from a MANIFEST like file, set in C<< $self->{skip_tests} >>, and
1082 rename the files in it with the extension F<.tskip>. If C<$unset> is
1083 set, they will be renamed back.
1084  
1085 =head2 unset_skip_tests
1086  
1087 Calls C<< $self->set_skip_tests( 1 ) >>.
1088  
1089 =cut
1090  
1091 2 ▶sub set_skip_tests {
Subroutine set_skip_tests: called CC=12 SCAR=25.6
Pod documented
1092 2 my( $self, $unset ) = @_;
1093  
1094 2 ▶ $self->{skip_tests} or return;
Branch: 1 branch
BranchTrueFalseTotal
$self->{"skip_tests"} or return 2 0 2
1095 2 local *SKIPTESTS;
1096  
1097 2 ▶ if ( open SKIPTESTS, "< $self->{skip_tests}" ) {
Branch: 1 branch
BranchTrueFalseTotal
if (open SKIPTESTS, "< $self->{'skip_tests'}") { } 2 0 2
1098 2 ▶ my $action = $unset ? 'Unskip' : 'Skip';
Branch: 1 branch
BranchTrueFalseTotal
$unset ? : 1 1 2
1099 2 $self->log_info("$action tests from '$self->{skip_tests}'");
1100 2 my @libext;
1101 my $raw;
1102 2 ▶ while ( $raw = <SKIPTESTS> ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($raw = readline SKIPTESTS)) 10 2 12
1103 10 ▶ $raw =~ m/^\s*#/ and next;
Branch: 1 branch
BranchTrueFalseTotal
$raw =~ /^\s*#/ and next 0 10 10
1104 10 $raw =~ s/(\S+).*/$1/s;
1105 10 ▶ if ($raw !~ m/\.t$/ and $raw !~ m/test\.pl$/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($raw =~ /\.t$/ or $raw =~ /test\.pl$/) 0 10 10
Condition33%1/3
$raw =~ /\.t$/ or $raw =~ /test\.pl$/
l!l&&r!l&&!r
1000
MC/DC0%0/2
$raw =~ /\.t$/ or $raw =~ /test\.pl$/
$raw =~ /\.t$/ $raw =~ /test\.pl$/
Truth table33%1/3
A or B
A= $raw =~ /\.t$/B= $raw =~ /test\.pl$/
ABresult
1X1
011
000
1106 0 next;
1107 }
1108 10 ▶ if ( $raw =~ m{^(?:lib|ext|cpan|dist)/} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($raw =~ m[^(?:lib|ext|cpan|dist)/]) 8 2 10
1109 8 push @libext, $raw;
1110 8 next;
1111 }
1112 2 my $tsrc = File::Spec->catfile( $self->{ddir}, $raw );
1113 2 ▶ next if !-f $tsrc;
Branch: 1 branch
BranchTrueFalseTotal
unless -f $tsrc 0 2 2
1114 2 my $skip = qq[print "1..0 # SKIP Disabled by Test::Smoke\\n";\nexit 0;\n__END__\n];
1115 13 ▶ use autodie;
Subroutine BEGIN: called CC=1 SCAR=0.0
1116  
1117 2 open my $test_fh_r, "<:raw", $tsrc;
1118 2 my $body = do { local $/; <$test_fh_r> };
1119 2 close $test_fh_r;
1120  
1121 2 open my $test_fh_w, ">:raw", $tsrc;
1122 2 ▶ print $test_fh_w !$unset ? "$skip$body" : do { $body =~ s/^\Q$skip\E//; $body; };
Branch: 1 branch
BranchTrueFalseTotal
!$unset ? : 1 1 2
1123 2 close $test_fh_w;
1124  
1125 2 $self->log_info("\t%s: %sok%s\n", $raw, '', "");
1126 }
1127 2 close SKIPTESTS;
1128 2 ▶ @libext and $self->change_manifest( \@libext, $unset );
Branch: 1 branch
BranchTrueFalseTotal
@libext and $self->change_manifest(\@libext, $unset) 2 0 2
1129 } else {
1130 0 require Carp;
1131 0 Carp::carp("Cannot open($self->{skip_tests}): $!");
1132 }
1133 }
1134  
1135 1 ▶sub unset_skip_tests { $_[0]->set_skip_tests( 1 ) }
Subroutine unset_skip_tests: called CC=1 SCAR=0.0
Pod documented
1136  
1137 =head2 $self->change_manifest( \@tests, $unset )
1138  
1139 =cut
1140  
1141 2 ▶sub change_manifest {
Subroutine change_manifest: called CC=8 SCAR=21.2
Pod documented
1142 2 my( $self, $tests, $unset ) = @_;
1143  
1144 2 my $mani_org = catfile $self->{ddir}, 'MANIFEST';
1145 2 my $mani_new = catfile $self->{ddir}, 'MANIFEST.ORG';
1146 2 ▶ if ( $unset ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($unset) { } 1 1 2
1147 1 ▶ if ( -f $mani_new ) {
Branch: 1 branch
BranchTrueFalseTotal
if (-f $mani_new) 1 0 1
1148 1 my $perms = (stat $mani_new)[2] & 07777;
1149 1 chmod 0755, $mani_new;
1150 1 unlink $mani_org;
1151 1 rename $mani_new, $mani_org;
1152 1 chmod $perms, $mani_org;
1153 }
1154 } else {
1155 1 my $perms = (stat $mani_org)[2] & 07777;
1156 1 chmod 0755, $mani_org;
1157 1 ▶ rename $mani_org, $mani_new or do {
Branch: 1 branch
BranchTrueFalseTotal
rename $mani_org, $mani_new or do { chmod $perms, $mani_org; require Carp; Carp::carp("No skip of lib or ext tests [rename($mani_new): $!]"); return } 1 0 1
1158 0 chmod $perms, $mani_org;
1159 0 require Carp;
1160 0 Carp::carp("No skip of lib or ext tests [rename($mani_new): $!]");
1161 0 return;
1162 };
1163 1 local( *MANIO, *MANIN );
1164 1 ▶ if ( open MANIO, "< $mani_new" ) {
Branch: 1 branch
BranchTrueFalseTotal
if (open MANIO, "< $mani_new") 1 0 1
1165 1 binmode MANIO;
1166 1 ▶ if ( open MANIN, "> $mani_org" ) {
Branch: 1 branch
BranchTrueFalseTotal
if (open MANIN, "> $mani_org") 1 0 1
1167 1 binmode MANIN;
1168 1 my $mline;
1169 1 ▶ while ( $mline = <MANIO> ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($mline = readline MANIO)) 18 1 19
1170 18 chomp $mline;
1171 18 ( my $fn = $mline ) =~ s/^(\S+).*/$1/;
1172 18 ▶ if ( ! grep /\Q$fn\E/ => @$tests ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not grep(/\Q$fn\E/, @$tests)) { } 14 4 18
1173 14 print MANIN "$mline\n";
1174 } else {
1175 4 $self->log_info("\t$fn");
1176 }
1177 }
1178 1 close MANIN;
1179 }
1180 1 close MANIO;
1181 1 chmod $perms, $mani_new;
1182 }
1183 }
1184 }
1185  
1186 =head2 $self->_run( $command[, $sub[, @args]] )
1187  
1188 C<_run()> returns C<< qx( $command ) >> unless C<$sub> is specified.
1189 If C<$sub> is defined (and a coderef) C<< $sub->( $command, @args ) >> will
1190 be called.
1191  
1192 =cut
1193  
1194 0 ▶sub _run {
Subroutine _run: not called CC=4 SCAR=30.0
1195 0 my $self = shift;
1196 0 my( $command, $sub, @args ) = @_;
1197  
1198 0 $self->log_debug("[$command]");
1199 0 ▶ defined $sub and return &$sub( $command, @args );
Branch: 1 branch
BranchTrueFalseTotal
defined $sub and return &$sub($command, @args) 0 0 0
1200  
1201 0 ▶ my ( $out, $err, $res ) = capture { system $command };
Subroutine __ANON__: not called CC=1 SCAR=6.9
1202 0 $self->tty($out);
1203 0 ▶ $self->ttylog($err) if $err;
Branch: 1 branch
BranchTrueFalseTotal
if $err 0 0 0
1204 0 $self->{_run_exit} = $res >> 8;
1205 0 ▶ return wantarray ? split /(\r\n|\r|\n)/, $out : $out;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
1206 }
1207  
1208 =head2 $self->_make( $command )
1209  
1210 C<_make()> calls C<< run( "make $command" ) >>, and does some extra
1211 stuff to help MSWin32 (the right maker, the directory).
1212  
1213 =cut
1214  
1215 0 ▶sub _make {
Subroutine _make: not called CC=5 SCAR=34.0
1216 0 my $self = shift;
1217 0 my $cmd = shift;
1218 0 ▶ $self->{makeopt} and $cmd = "$self->{makeopt} $cmd";
Branch: 1 branch
BranchTrueFalseTotal
$self->{"makeopt"} and $cmd = qq[$self->{"makeopt"} $cmd] 0 0 0
1219 0 ▶ $cmd =~ m/clean/ and $cmd =~ s/-j[0-9]+\s+//;
Branch: 1 branch
BranchTrueFalseTotal
$cmd =~ /clean/ and $cmd =~ s/-j[0-9]+\s+// 0 0 0
1220  
1221 return
1222 $self->{is_vms} ? $self->_make_vms($cmd)
1223 0 ▶ : $self->{is_win32} ? $self->_make_win32($cmd)
Branch: 2 branches
BranchTrueFalseTotal
$self->{'is_vms'} ? : 0 0 0
$self->{'is_win32'} ? : 0 0 0
1224 : $self->_run("make $cmd");
1225 }
1226  
1227 0 ▶sub _make_win32 {
Subroutine _make_win32: not called CC=4 SCAR=30.0
1228 0 my $self = shift;
1229 0 my $cmd = shift;
1230  
1231 0 $cmd =~ s|2\s*>\s*/dev/null\s*$|2>nul|;
1232  
1233 0 $cmd = "$self->{w32make} -f smoke.mk $cmd";
1234 0 ▶ chdir "win32" or die "unable to chdir () into 'win32'";
Branch: 1 branch
BranchTrueFalseTotal
chdir "win32" or die "unable to chdir () into 'win32'" 0 0 0
1235 0 my @output = $self->_run($cmd);
1236 0 ▶ chdir ".." or die "unable to chdir() out of 'win32'";
Branch: 1 branch
BranchTrueFalseTotal
chdir ".." or die "unable to chdir() out of 'win32'" 0 0 0
1237 0 ▶ return wantarray ? @output : join "", @output;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
1238 }
1239  
1240 0 ▶sub _make_vms {
Subroutine _make_vms: not called CC=4 SCAR=30.0
1241 0 my $self = shift;
1242 0 my $cmd = shift;
1243  
1244 0 my $kill_err;
1245 # don't capture STDERR
1246 # @ But why? and what if we do it DOSish? 2>NUL:
1247  
1248 0 ▶ $cmd =~ s|2\s*>\s*/dev/null\s*$|| and $kill_err = 1;
Branch: 1 branch
BranchTrueFalseTotal
$cmd =~ s[2\s*>\s*/dev/null\s*$][] and $kill_err = 1 0 0 0
1249  
1250 0 $cmd = "$self->{vmsmake} $cmd";
1251 0 ▶ my @output = $self->_run(
Branch: 1 branch
BranchTrueFalseTotal
$kill_err ? : 0 0 0
1252 $kill_err ? qq{$^X -e "close STDERR; system '$cmd'"} : $cmd
1253 );
1254 0 ▶ return wantarray ? @output : join "", @output;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
1255 }
1256  
1257 =head2 $smoker->_make_fork( $target, $extra )
1258  
1259 C<_make_fork()> opens a read pipe to the make command with C<$target>
1260 and C<$extra> arguments for the make command.
1261  
1262 =cut
1263  
1264 0 ▶sub _make_fork {
Subroutine _make_fork: not called CC=8 SCAR=42.8
1265 0 my( $self, $target, $extra ) = @_;
1266  
1267 0 ▶ !defined $extra and $extra = "";
Branch: 1 branch
BranchTrueFalseTotal
defined $extra or $extra = "" 0 0 0
1268  
1269 0 my( $ok, $err, $cmd );
1270 0 local *TST;
1271  
1272 # MSWin32 builds from its own directory
1273 0 ▶ if ( $self->{is_win32} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'is_win32'}) { } 0 0 0
1274 0 ▶ chdir "win32" or die "unable to chdir () into 'win32'";
Branch: 1 branch
BranchTrueFalseTotal
chdir "win32" or die "unable to chdir () into 'win32'" 0 0 0
1275 # Same as in make ()
1276 0 $cmd = "$self->{testmake}$extra -f smoke.mk $target |";
1277 0 ▶ $ok = open TST, $cmd or $err = $!;
Branch: 1 branch
BranchTrueFalseTotal
$ok = open(TST, $cmd) or $err = $! 0 0 0
1278 0 ▶ chdir ".." or die "unable to chdir () out of 'win32'";
Branch: 1 branch
BranchTrueFalseTotal
chdir ".." or die "unable to chdir () out of 'win32'" 0 0 0
1279 } else {
1280 0 local $ENV{PERL} = "./perl";
1281 0 $cmd = "$self->{testmake}$extra $target |";
1282 0 ▶ $ok = open TST, $cmd or $err = $!;
Branch: 1 branch
BranchTrueFalseTotal
$ok = open(TST, $cmd) or $err = $! 0 0 0
1283 }
1284 0 ▶ $ok or do {
Branch: 1 branch
BranchTrueFalseTotal
$ok or do { require Carp; Carp::carp("Cannot fork '${cmd}': $err"); return 0 } 0 0 0
1285 0 require Carp;
1286 0 Carp::carp("Cannot fork '$cmd': $err");
1287 0 return 0;
1288 };
1289 0 select ((select (*TST), $| = 1)[0]);
1290 0 return *TST;
1291 }
1292  
1293 =head2 $smoker->_vms__rooted_logical
1294  
1295 This code sets up a rooted logical C<TSP5SRC> and changes the {ddir}
1296 to that root.
1297  
1298 =cut
1299  
1300 0 ▶sub _vms_rooted_logical {
Subroutine _vms_rooted_logical: not called CC=2 SCAR=17.9
1301 0 my $self = shift;
1302 0 ▶ return unless $^O eq 'VMS';
Branch: 1 branch
BranchTrueFalseTotal
unless $^O eq "VMS" 0 0 0
1303  
1304 0 Test::Smoke::Util::set_vms_rooted_logical( TSP5SRC => $self->{ddir} );
1305 0 $self->{vms_ddir} = $self->{ddir};
1306 0 $self->{ddir} = 'TSP5SRC:[000000]';
1307  
1308 }
1309  
1310 13 1;
1311  
1312 =head1 SEE ALSO
1313  
1314 L<Test::Smoke>
1315  
1316 =head1 COPYRIGHT
1317  
1318 (c) 2002-2003, All rights reserved.
1319  
1320 * Abe Timmerman <abeltje@cpan.org>
1321  
1322 This library is free software; you can redistribute it and/or modify
1323 it under the same terms as Perl itself.
1324  
1325 See:
1326  
1327 =over 4
1328  
1329 =item * L<http://www.perl.com/perl/misc/Artistic.html>
1330  
1331 =item * L<http://www.gnu.org/copyleft/gpl.html>
1332  
1333 =back
1334  
1335 This program is distributed in the hope that it will be useful,
1336 but WITHOUT ANY WARRANTY; without even the implied warranty of
1337 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
1338  
1339 =cut
« blib/lib/Test/Smoke/Mailer/Mail_X.pm ↑ Summary blib/lib/Test/Smoke/Mailer/Sendmail.pm »