blib/lib/Test/Smoke/Mailer/Base.pm

filter: Statementstmt 36.1% 13 / 36 Branchbran 0.0% 0 / 12 Conditioncond 0.0% 0 / 7 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 42.8% 3 / 7 Podpod 100% 3 / 3 totaltotal 27.5% 19 / 69 CC 10 SCAR 36.3
CC
10
Cov
24%
_get_cc
72.0
fetch_report
6.0
error
6.0
CRAP 37.8
« blib/lib/Test/Smoke/Syncer/Base.pm ↑ Summary blib/lib/Test/Smoke/App/ConfigSmoke/MakeOptions.pm »
1 package Test::Smoke::Mailer::Base;
2 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 3 our $VERSION = '0.001';
6  
7 3 ▶use Test::Smoke::Util qw( parse_report_Config );
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 =head1 NAME
10  
11 Test::Smoke::Mailer::Base - baseclass for Mailers
12  
13 =head1 DESCRIPTION
14  
15  
16 =cut
17  
18 3 our $P5P = 'perl5-porters@perl.org';
19 3 our $NOCC_RE = ' (?:PASS\b|FAIL\(X\))';
20  
21 =head2 Test::Smoke::Mailer::Base->new()
22  
23 constructor.
24  
25 =cut
26  
27 0 ▶sub new {
Subroutine new: not called CC=1 SCAR=6.9
Pod documented
28 0 my $class = shift;
29 0 return bless {@_}, $class;
30 }
31  
32 =head2 $mailer->fetch_report( )
33  
34 C<fetch_report()> reads B<mktest.rpt> from C<{ddir}> and return the
35 subject line for the mail-message.
36  
37 =cut
38  
39 0 ▶sub fetch_report {
Subroutine fetch_report: not called CC=2 SCAR=17.9
Pod documented
40 0 my $self = shift;
41  
42 0 $self->{file} = File::Spec->catfile( $self->{ddir}, $self->{rptfile} );
43  
44 0 local *REPORT;
45 0 ▶ if ( open REPORT, "< $self->{file}" ) {
Branch: 1 branch
BranchTrueFalseTotal
if (open REPORT, "< $self->{'file'}") { } 0 0 0
46 0 $self->{body} = do { local $/; <REPORT> };
47 0 close REPORT;
48 } else {
49 0 require Carp;
50 0 Carp::croak( "Cannot read '$self->{file}': $!" );
51 }
52  
53 0 my @config = parse_report_Config( $self->{body} );
54  
55 0 return sprintf "Smoke [%s] %s %s %s %s (%s)", @config[6, 1, 5, 2, 3, 4];
56 }
57  
58 =head2 $mailer->error( )
59  
60 C<error()> returns the value of C<< $mailer->{error} >>.
61  
62 =cut
63  
64 0 ▶sub error {
Subroutine error: not called CC=2 SCAR=17.9
Pod documented
65 0 my $self = shift;
66  
67 0 ▶ return $self->{error} || '';
Condition0%0/2
$self->{'error'} || ''
l!l
00
MC/DC0%0/1
$self->{'error'} || ''
$self->{'error'}
Truth table0%0/2
A
A= $self->{'error'}
Aresult
11
00
68 }
69  
70 =head2 $self->_get_cc( $subject )
71  
72 C<_get_cc()> implements the C<--ccp5p_onfail> option. It looks at the
73 subject to see if the smoke FAILed and then adds the I<perl5-porters>
74 mailing-list to the C<Cc:> field unless it is already part of C<To:>
75 or C<Cc:>.
76  
77 The new behaviour is to only return C<Cc:> on fail. This is determined
78 by the new global regex kept in C<< $Test::Smoke::Mailer::NOCC_RE >>.
79  
80 =cut
81  
82 0 ▶sub _get_cc {
Subroutine _get_cc: not called CC=8 SCAR=42.8
83 0 my( $self, $subject ) = @_;
84 0 ▶ return "" if $subject =~ m/$Test::Smoke::Mailer::NOCC_RE/;
Branch: 1 branch
BranchTrueFalseTotal
if $subject =~ /$Test::Smoke::Mailer::NOCC_RE/ 0 0 0
85  
86 0 ▶ return $self->{cc} || "" unless $self->{ccp5p_onfail};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"ccp5p_onfail"} 0 0 0
Condition0%0/2
$self->{'cc'} || ''
l!l
00
MC/DC0%0/1
$self->{'cc'} || ''
$self->{'cc'}
Truth table0%0/2
A
A= $self->{'cc'}
Aresult
11
00
87  
88 0 ▶ my $p5p = $Test::Smoke::Mailer::P5P or return $self->{cc};
Branch: 1 branch
BranchTrueFalseTotal
my $p5p = $Test::Smoke::Mailer::P5P or return $self->{"cc"} 0 0 0
89 0 ▶ my @cc = $self->{cc} ? $self->{cc} : ();
Branch: 1 branch
BranchTrueFalseTotal
$self->{'cc'} ? : 0 0 0
90  
91 push @cc, $p5p unless $self->{to} =~ /\Q$p5p\E/ ||
92 0 ▶ $self->{cc} =~ /\Q$p5p\E/;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"to"} =~ /\Q$p5p\E/ or $self->{"cc"} =~ /\Q$p5p\E/ 0 0 0
Condition0%0/3
$self->{"to"} =~ /\Q$p5p\E/ or $self->{"cc"} =~ /\Q$p5p\E/
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->{"to"} =~ /\Q$p5p\E/ or $self->{"cc"} =~ /\Q$p5p\E/
$self->{"to"} =~ /\Q$p5p\E/ $self->{"cc"} =~ /\Q$p5p\E/
Truth table0%0/3
A or B
A= $self->{"to"} =~ /\Q$p5p\E/B= $self->{"cc"} =~ /\Q$p5p\E/
ABresult
1X1
011
000
93 0 return join ", ", @cc;
94 }
95  
96  
97 3 1;
98  
99 =head1 COPYRIGHT
100  
101 (c) 2002-2013, All rights reserved.
102  
103 * Abe Timmerman <abeltje@cpan.org>
104  
105 This library is free software; you can redistribute it and/or modify
106 it under the same terms as Perl itself.
107  
108 See:
109  
110 * <http://www.perl.com/perl/misc/Artistic.html>,
111 * <http://www.gnu.org/copyleft/gpl.html>
112  
113 This program is distributed in the hope that it will be useful,
114 but WITHOUT ANY WARRANTY; without even the implied warranty of
115 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
116  
117 =cut
« blib/lib/Test/Smoke/Syncer/Base.pm ↑ Summary blib/lib/Test/Smoke/App/ConfigSmoke/MakeOptions.pm »