blib/lib/Test/Smoke.pm

filter: Statementstmt 48.4% 48 / 99 Branchbran 20.0% 10 / 50 Conditioncond 26.6% 4 / 15 MC/DCmcdc 10.0% 1 / 10 Subroutinesub 81.2% 13 / 16 Podpod 100% 6 / 6 totaltotal 41.8% 82 / 196 CC 33 SCAR 51.9
CC
33
Cov
38%
run_smoke
420.0
do_manifest_check
20.0
read_config
8.9
CRAP 178.8
« blib/lib/Test/Smoke/Mailer/SendEmail.pm ↑ Summary blib/lib/Test/Smoke/App/SmokeStatus.pl »
1 package Test::Smoke;
2 12 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 12 ▶use vars qw($conf);
Subroutine BEGIN: called CC=1 SCAR=0.0
5 12 our $VERSION = "1.87";
6  
7 12 ▶use base 'Exporter';
Subroutine BEGIN: called CC=1 SCAR=0.0
8 12 our @EXPORT = qw( $conf &read_config &run_smoke );
9  
10 12 my $ConfigError;
11  
12 12 ▶use File::Spec;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 12 ▶use Test::Smoke::Policy;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 12 ▶use Test::Smoke::BuildCFG;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 12 ▶use Test::Smoke::Smoker;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 12 ▶use Test::Smoke::SourceTree qw( :mani_const );
Subroutine BEGIN: called CC=1 SCAR=0.0
17 12 ▶use Test::Smoke::Util qw( get_patch skip_config
Subroutine BEGIN: called CC=1 SCAR=0.0
18 12 get_local_patches set_local_patch );
19 12 ▶use Config;
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 =head1 NAME
22  
23 Test::Smoke - The Perl core test smoke suite
24  
25 =head1 SYNOPSIS
26  
27 use Test::Smoke;
28  
29 use vars qw( $VERSION );
30 $VERSION = Test::Smoke->VERSION;
31  
32 read_config( $config_name ) or warn Test::Smoke->config_error;
33  
34  
35 =head1 DESCRIPTION
36  
37 If you are looking to get started, start at the B<README>!
38  
39 C<Test::Smoke> exports C<$conf> and C<read_config()> by default.
40  
41 =head2 Test::Smoke::read_config( $config_name )
42  
43 Read (require) the configfile.
44  
45 =cut
46  
47 2 ▶sub read_config {
Subroutine read_config: called CC=8 SCAR=21.8
Pod documented
48 2 my( $config_name ) = @_;
49  
50 2 ▶ $config_name = 'smokecurrent_config'
Branch: 1 branch
BranchTrueFalseTotal
unless defined $config_name and length $config_name 0 2 2
Condition33%1/3
defined $config_name and length $config_name
!ll&&!rl&&r
002
MC/DC0%0/2
defined $config_name and length $config_name
defined $config_name length $config_name
Truth table33%1/3
A and B
A= defined $config_nameB= length $config_name
ABresult
0X0
100
111
51 unless defined $config_name && length $config_name;
52 2 ▶ $config_name .= '_config'
Branch: 1 branch
BranchTrueFalseTotal
unless $config_name =~ /_config$/ or -f $config_name 1 1 2
Condition66%2/3
$config_name =~ /_config$/ or -f $config_name
l!l&&r!l&&!r
101
MC/DC50%1/2
$config_name =~ /_config$/ or -f $config_name
$config_name =~ /_config$/ -f $config_name
Truth table66%2/3
A or B
A= $config_name =~ /_config$/B= -f $config_name
ABresult
1X1
011
000
53 unless $config_name =~ /_config$/ || -f $config_name;
54  
55 # Enable reloading by hackery
56 2 local @INC = ( File::Spec->curdir, @INC );
57 2 ▶ delete $INC{ $config_name } if exists $INC{ $config_name };
Branch: 1 branch
BranchTrueFalseTotal
if exists $INC{$config_name} 1 1 2
58 2 eval { require $config_name };
59 2 ▶ $ConfigError = $@ ? $@ : undef;
Branch: 1 branch
BranchTrueFalseTotal
$@ ? : 0 2 2
60  
61 2 ▶ return defined $ConfigError ? undef : 1;
Branch: 1 branch
BranchTrueFalseTotal
defined $ConfigError ? : 0 2 2
62 }
63  
64 =head2 Test::Smoke->config_error()
65  
66 Return the value of C<$ConfigError>
67  
68 =cut
69  
70 2 ▶sub config_error {
Subroutine config_error: called CC=1 SCAR=0.0
Pod documented
71 2 return $ConfigError;
72 }
73  
74 =head2 is_win32( )
75  
76 C<is_win32()> returns true if C<< $^O eq "MSWin32" >>.
77  
78 =cut
79  
80 0 ▶sub is_win32() { $^O eq "MSWin32" }
Subroutine is_win32: not called CC=1 SCAR=6.9
Pod documented
81  
82 =head2 do_manifest_check( $ddir, $smoker )
83  
84 C<do_manifest_check()> uses B<Test::Smoke::SourceTree> to do the
85 MANIFEST check.
86  
87 =cut
88  
89 0 ▶sub do_manifest_check {
Subroutine do_manifest_check: not called CC=4 SCAR=30.0
Pod documented
90 0 my( $ddir, $smoker ) = @_;
91  
92 0 my $tree = Test::Smoke::SourceTree->new( $ddir );
93 0 my $mani_check = $tree->check_MANIFEST( 'mktest.out', 'mktest.rpt' );
94 0 foreach my $file ( sort keys %$mani_check ) {
95 0 ▶ if ( $mani_check->{ $file } == ST_MISSING ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($mani_check->{$file} == 1) { } 0 0 0
elsif ($mani_check->{$file} == 0) { } 0 0 0
96 0 $smoker->log( "MANIFEST declared '$file' but it is missing\n" );
97 } elsif ( $mani_check->{ $file } == ST_UNDECLARED ) {
98 0 $smoker->log( "MANIFEST did not declare '$file'\n" );
99 }
100 }
101 }
102  
103 =head2 set_smoke_patchlevel( $ddir, $patch[, $verbose] )
104  
105 Set the current patchlevel as a registered patch like "SMOKE$patch"
106  
107 =cut
108  
109 6 ▶sub set_smoke_patchlevel {
Subroutine set_smoke_patchlevel: called CC=4 SCAR=14.6
Pod documented
110 6 my( $ddir, $patch, $verbose ) = @_;
111 6 ▶ $ddir && $patch or return;
Branch: 1 branch
BranchTrueFalseTotal
$ddir and $patch or return 6 0 6
Condition33%1/3
$ddir and $patch
!ll&&!rl&&r
006
MC/DC0%0/2
$ddir and $patch
$ddir $patch
Truth table33%1/3
A and B
A= $ddirB= $patch
ABresult
0X0
100
111
112  
113 6 my @smokereg = grep
114 /^SMOKE[a-fA-F0-9]+$/
115 , get_local_patches( $ddir, $verbose );
116 6 ▶ @smokereg or set_local_patch( $ddir, "SMOKE$patch" );
Branch: 1 branch
BranchTrueFalseTotal
@smokereg or set_local_patch($ddir, "SMOKE$patch") 3 3 6
117 }
118  
119 =head2 run_smoke( [$continue[, @df_buildopts]] )
120  
121 C<run_smoke()> sets up de build environment and gets the private Policy
122 file and build configurations and then runs the smoke stuff for all
123 configurations.
124  
125 All arguments after the C<$continue> are taken as default buildoptions
126 and passed to C<./Configure>.
127  
128 =cut
129  
130 0 ▶sub run_smoke {
Subroutine run_smoke: not called CC=20 SCAR=60.4
Pod documented
131 0 my $continue = shift;
132 0 ▶ defined $continue or $continue = $conf->{continue};
Branch: 1 branch
BranchTrueFalseTotal
defined $continue or $continue = $Test::Smoke::conf->{"continue"} 0 0 0
133  
134 0 ▶ my @df_buildopts = @_ ? grep /^-[DUA]/ => @_ : ();
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 0 0 0
135 # We *always* want -Dusedevel!
136 0 ▶ push @df_buildopts, '-Dusedevel'
Branch: 1 branch
BranchTrueFalseTotal
unless grep /^-Dusedevel$/, @df_buildopts 0 0 0
137 unless grep /^-Dusedevel$/ => @df_buildopts;
138 0 Test::Smoke::BuildCFG->config( dfopts => join " ", @df_buildopts );
139  
140 0 my $patch = Test::Smoke::Util::get_patch( $conf->{ddir} );
141  
142 { # I cannot find a better place to stick this (thanks Bram!)
143 # change 33961 introduced Test::Harness 3 for 5.10.x
144 # that needs different parsing, so set the config to do that
145 # 20081220; new patchlevels due to git; cannot test it like an int
146 0 ▶ if ( $conf->{perl_version} eq '5.10.x' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Test::Smoke::conf->{"perl_version"} eq "5.10.x") 0 0 0
147 0 $conf->{hasharness3} = 1;
148 }
149 }
150  
151 0 my $logfile = File::Spec->catfile( $conf->{ddir}, 'mktest.out' );
152 my $BuildCFG = $continue
153 ? Test::Smoke::BuildCFG->continue( $logfile, $conf->{cfg},
154 v => $conf->{v} )
155 0 ▶ : Test::Smoke::BuildCFG->new( $conf->{cfg}, v => $conf->{v} );
Branch: 1 branch
BranchTrueFalseTotal
$continue ? : 0 0 0
156  
157 0 local *LOG;
158 0 ▶ my $mode = $continue ? ">>" : ">";
Branch: 1 branch
BranchTrueFalseTotal
$continue ? : 0 0 0
159 0 ▶ open LOG, "$mode $logfile" or die "Cannot create 'mktest.out': $!";
Branch: 1 branch
BranchTrueFalseTotal
open LOG, "$mode $logfile" or die "Cannot create 'mktest.out': $!" 0 0 0
160  
161 my $Policy = Test::Smoke::Policy->new( File::Spec->updir, $conf->{v},
162 0 $BuildCFG->policy_targets );
163  
164 0 my $smoker = Test::Smoke::Smoker->new( \*LOG, $conf );
165 0 $smoker->mark_in;
166  
167 $conf->{v} && $conf->{defaultenv} and
168 0 ▶ $smoker->tty( "Running smoke tests without \$ENV{PERLIO}\n" );
Branch: 1 branch
BranchTrueFalseTotal
$Test::Smoke::conf->{"v"} and $Test::Smoke::conf->{"defaultenv"} and $smoker->tty("Running smoke tests without \$ENV{PERLIO}\n") 0 0 0
Condition0%0/3
$Test::Smoke::conf->{"v"} and $Test::Smoke::conf->{"defaultenv"}
!ll&&!rl&&r
000
MC/DC0%0/2
$Test::Smoke::conf->{"v"} and $Test::Smoke::conf->{"defaultenv"}
$Test::Smoke::conf->{"v"} $Test::Smoke::conf->{"defaultenv"}
Truth table0%0/3
A and B
A= $Test::Smoke::conf->{"v"}B= $Test::Smoke::conf->{"defaultenv"}
ABresult
0X0
100
111
169  
170 0 my $harness_msg;
171 0 ▶ if ( $conf->{harnessonly} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Test::Smoke::conf->{"harnessonly"}) 0 0 0
172 0 $harness_msg = "Running test suite only with 'harness'";
173 $conf->{harness3opts} and
174 0 ▶ $harness_msg .= " with HARNESS_OPTIONS=$conf->{harness3opts}";
Branch: 1 branch
BranchTrueFalseTotal
$Test::Smoke::conf->{"harness3opts"} and $harness_msg .= qq[ with HARNESS_OPTIONS=$Test::Smoke::conf->{"harness3opts"}] 0 0 0
175 }
176 0 ▶ $conf->{v} && $harness_msg and $smoker->tty( "$harness_msg.\n" );
Branch: 1 branch
BranchTrueFalseTotal
$Test::Smoke::conf->{"v"} and $harness_msg and $smoker->tty("$harness_msg.\n") 0 0 0
Condition0%0/3
$Test::Smoke::conf->{"v"} and $harness_msg
!ll&&!rl&&r
000
MC/DC0%0/2
$Test::Smoke::conf->{"v"} and $harness_msg
$Test::Smoke::conf->{"v"} $harness_msg
Truth table0%0/3
A and B
A= $Test::Smoke::conf->{"v"}B= $harness_msg
ABresult
0X0
100
111
177  
178 0 ▶ chdir $conf->{ddir} or die "Cannot chdir($conf->{ddir}): $!";
Branch: 1 branch
BranchTrueFalseTotal
chdir $Test::Smoke::conf->{"ddir"} or die qq[Cannot chdir($Test::Smoke::conf->{"ddir"}): $!] 0 0 0
179 0 ▶ unless ( $continue ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($continue) 0 0 0
180 0 $smoker->make_distclean( );
181 0 $smoker->ttylog("Smoking patch $patch->[0] $patch->[1]\n");
182 0 ▶ $smoker->ttylog("Smoking branch $patch->[2]\n") if $patch->[2];
Branch: 1 branch
BranchTrueFalseTotal
if $patch->[2] 0 0 0
183 0 do_manifest_check( $conf->{ddir}, $smoker );
184 0 set_smoke_patchlevel( $conf->{ddir}, $patch->[0] );
185 }
186  
187 0 foreach my $this_cfg ( $BuildCFG->configurations ) {
188 0 $smoker->mark_out; $smoker->mark_in;
189 0 ▶ if ( skip_config( $this_cfg ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (skip_config($this_cfg)) 0 0 0
190 0 $smoker->ttylog( "Skipping: '$this_cfg'\n" );
191 0 next;
192 }
193  
194 0 $smoker->ttylog( join "\n",
195 "", "Configuration: $this_cfg", "-" x 78, "" );
196 0 $smoker->smoke( $this_cfg, $Policy );
197 }
198  
199 0 $smoker->ttylog( "Finished smoking $patch->[0] $patch->[1] $patch->[2]\n" );
200 0 $smoker->mark_out;
201  
202 0 ▶ close LOG or do {
Branch: 1 branch
BranchTrueFalseTotal
close LOG or do { require Carp; Carp::carp("Error on closing logfile: $!") } 0 0 0
203 0 require Carp;
204 0 Carp::carp "Error on closing logfile: $!";
205 };
206 }
207  
208 12 1;
209  
210 =head1 COPYRIGHT
211  
212 (c) 2003, All rights reserved.
213  
214 * Abe Timmerman <abeltje@cpan.org>
215  
216 This library is free software; you can redistribute it and/or modify
217 it under the same terms as Perl itself.
218  
219 See:
220  
221 =over 4
222  
223 =item * L<http://www.perl.com/perl/misc/Artistic.html>
224  
225 =item * L<http://www.gnu.org/copyleft/gpl.html>
226  
227 =back
228  
229 This program is distributed in the hope that it will be useful,
230 but WITHOUT ANY WARRANTY; without even the implied warranty of
231 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
232  
233 =cut
« blib/lib/Test/Smoke/Mailer/SendEmail.pm ↑ Summary blib/lib/Test/Smoke/App/SmokeStatus.pl »