line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Smoke::Mailer::Base; |
2
|
3
|
|
|
3
|
|
22
|
use warnings; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
99
|
|
3
|
3
|
|
|
3
|
|
15
|
use strict; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
121
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.001'; |
6
|
|
|
|
|
|
|
|
7
|
3
|
|
|
3
|
|
652
|
use Test::Smoke::Util qw( parse_report_Config ); |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
1389
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 NAME |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
Test::Smoke::Mailer::Base - baseclass for Mailers |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 DESCRIPTION |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=cut |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
our $P5P = 'perl5-porters@perl.org'; |
19
|
|
|
|
|
|
|
our $NOCC_RE = ' (?:PASS\b|FAIL\(X\))'; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head2 Test::Smoke::Mailer::Base->new() |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
constructor. |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=cut |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub new { |
28
|
0
|
|
|
0
|
1
|
|
my $class = shift; |
29
|
0
|
|
|
|
|
|
return bless {@_}, $class; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head2 $mailer->fetch_report( ) |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
C reads B from C<{ddir}> and return the |
35
|
|
|
|
|
|
|
subject line for the mail-message. |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=cut |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub fetch_report { |
40
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
41
|
|
|
|
|
|
|
|
42
|
0
|
|
|
|
|
|
$self->{file} = File::Spec->catfile( $self->{ddir}, $self->{rptfile} ); |
43
|
|
|
|
|
|
|
|
44
|
0
|
|
|
|
|
|
local *REPORT; |
45
|
0
|
0
|
|
|
|
|
if ( open REPORT, "< $self->{file}" ) { |
46
|
0
|
|
|
|
|
|
$self->{body} = do { local $/; }; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
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 returns the value of C<< $mailer->{error} >>. |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=cut |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub error { |
65
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
66
|
|
|
|
|
|
|
|
67
|
0
|
|
0
|
|
|
|
return $self->{error} || ''; |
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 |
74
|
|
|
|
|
|
|
mailing-list to the C field unless it is already part of C |
75
|
|
|
|
|
|
|
or C. |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
The new behaviour is to only return C on fail. This is determined |
78
|
|
|
|
|
|
|
by the new global regex kept in C<< $Test::Smoke::Mailer::NOCC_RE >>. |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=cut |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub _get_cc { |
83
|
0
|
|
|
0
|
|
|
my( $self, $subject ) = @_; |
84
|
0
|
0
|
|
|
|
|
return "" if $subject =~ m/$Test::Smoke::Mailer::NOCC_RE/; |
85
|
|
|
|
|
|
|
|
86
|
0
|
0
|
0
|
|
|
|
return $self->{cc} || "" unless $self->{ccp5p_onfail}; |
87
|
|
|
|
|
|
|
|
88
|
0
|
0
|
|
|
|
|
my $p5p = $Test::Smoke::Mailer::P5P or return $self->{cc}; |
89
|
0
|
0
|
|
|
|
|
my @cc = $self->{cc} ? $self->{cc} : (); |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
push @cc, $p5p unless $self->{to} =~ /\Q$p5p\E/ || |
92
|
0
|
0
|
0
|
|
|
|
$self->{cc} =~ /\Q$p5p\E/; |
93
|
0
|
|
|
|
|
|
return join ", ", @cc; |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
1; |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head1 COPYRIGHT |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
(c) 2002-2013, All rights reserved. |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
* Abe Timmerman |
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
|
|
|
|
|
|
|
* , |
111
|
|
|
|
|
|
|
* |
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 |