File Coverage

blib/lib/Test/Apocalypse/PPPort.pm
Criterion Covered Total %
statement 17 61 27.8
branch 0 26 0.0
condition n/a
subroutine 7 11 63.6
pod 0 1 0.0
total 24 99 24.2


line stmt bran cond sub pod time code
1             #
2             # This file is part of Test-Apocalypse
3             #
4             # This software is copyright (c) 2014 by Apocalypse.
5             #
6             # This is free software; you can redistribute it and/or modify it under
7             # the same terms as the Perl 5 programming language system itself.
8             #
9 38     38   1412112 use strict; use warnings;
  38     38   80  
  38         1302  
  38         163  
  38         75  
  38         1740  
10             package Test::Apocalypse::PPPort;
11             $Test::Apocalypse::PPPort::VERSION = '1.006';
12             BEGIN {
13 38     38   503 $Test::Apocalypse::PPPort::AUTHORITY = 'cpan:APOCAL';
14             }
15              
16             # ABSTRACT: Plugin to test for Devel::PPPort warnings
17              
18 38     38   156 use Test::More;
  38         39  
  38         262  
19 38     38   58153 use Devel::PPPort 3.19;
  38         12081  
  38         409  
20 38     38   19123 use Capture::Tiny 0.10 qw( capture_merged );
  38         214311  
  38         18698  
21              
22 37     37   222 sub _do_automated { 0 }
23              
24             sub do_test {
25 0     0 0   plan tests => 2;
26              
27             # do we have an existing ppport.h file?
28 0           my $haveppport = 0;
29 0           my $needstrip = 0;
30 0           my $ppp = 'ppport.h';
31             SKIP: {
32 0 0         if ( ! -f $ppp ) {
  0            
33             # generate our own ppport.h file
34 0           Devel::PPPort::WriteFile( $ppp );
35              
36 0           skip( "Distro did not come with a $ppp file", 1 );
37             }
38              
39 0           $haveppport++;
40              
41             # was it already stripped or not?
42 0     0     my $oldver = capture_merged { system( $^X, $ppp, '--version' ) };
  0            
43 0 0         if ( length $oldver ) {
44 0 0         if ( $oldver =~ /^This is ppport\.h ([\d\.]+)$/ms ) {
45 0           fail( "$ppp file needs to be stripped" );
46             } else {
47 0           $needstrip++;
48 0           pass( "$ppp file was already stripped" );
49             }
50             } else {
51 0           die "Unable to run $ppp and get the output";
52             }
53              
54             # remove it and create a new one so we have the latest one, always
55 0 0         unlink( $ppp ) or die "Unable to unlink '$ppp': $!";
56 0           Devel::PPPort::WriteFile( $ppp );
57             }
58              
59             # Then, we run it :)
60 0     0     my $result = capture_merged { system( $^X, $ppp ) };
  0            
61              
62 0 0         if ( length $result ) {
63             # Did we have any xs files?
64 0 0         if ( $result =~ /^No input files given/m ) {
65 0           pass( 'No XS files detected' );
66             } else {
67             # is the last line saying "OK" ?
68 0 0         if ( $result =~ /Looks good$/m ) {
69             # Did we get any warnings? Display them in case they're useful...
70 0           my @warns;
71 0           foreach my $l ( split( "\n", $result ) ) {
72 0 0         if ( $l =~ /^\*\*\*\s+WARNING:\s+/s ) {
73 0           push( @warns, $l );
74             }
75             }
76              
77 0 0         if ( @warns ) {
78 0           pass( "$ppp says you are good to go with some warnings" );
79 0           diag( $_ ) for @warns;
80             } else {
81 0           pass( "$ppp says you are good to go" );
82             }
83             } else {
84 0           fail( "$ppp caught some errors" );
85 0           diag( $result );
86             }
87             }
88             } else {
89 0           die "Unable to run $ppp and get the output";
90             }
91              
92             # remove our generated ppport.h file
93 0 0         if ( ! $haveppport ) {
94 0 0         unlink( $ppp ) or die "Unable to unlink '$ppp': $!";
95             } else {
96 0 0         if ( $needstrip ) {
97 0     0     $result = capture_merged { system( $^X, $ppp, '--strip' ) };
  0            
98 0 0         if ( length $result ) {
99 0           die "Unable to strip $ppp file: $result";
100             }
101             }
102             }
103              
104 0           return;
105             }
106              
107             1;
108              
109             __END__
110              
111             =pod
112              
113             =encoding UTF-8
114              
115             =for :stopwords Apocalypse Niebur Ryan ppport
116              
117             =for Pod::Coverage do_test
118              
119             =head1 NAME
120              
121             Test::Apocalypse::PPPort - Plugin to test for Devel::PPPort warnings
122              
123             =head1 VERSION
124              
125             This document describes v1.006 of Test::Apocalypse::PPPort - released October 25, 2014 as part of Test-Apocalypse.
126              
127             =head1 DESCRIPTION
128              
129             Plugin to test for L<Devel::PPPort> warnings. It automatically updates your bundled F<ppport.h> file to the latest provided by L<Devel::PPPort>!
130             Also, it will strip the F<ppport.h> file to make it smaller.
131              
132             =head1 SEE ALSO
133              
134             Please see those modules/websites for more information related to this module.
135              
136             =over 4
137              
138             =item *
139              
140             L<Test::Apocalypse|Test::Apocalypse>
141              
142             =back
143              
144             =head1 AUTHOR
145              
146             Apocalypse <APOCAL@cpan.org>
147              
148             =head1 COPYRIGHT AND LICENSE
149              
150             This software is copyright (c) 2014 by Apocalypse.
151              
152             This is free software; you can redistribute it and/or modify it under
153             the same terms as the Perl 5 programming language system itself.
154              
155             The full text of the license can be found in the
156             F<LICENSE> file included with this distribution.
157              
158             =head1 DISCLAIMER OF WARRANTY
159              
160             THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
161             APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
162             HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
163             OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
164             THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
165             PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
166             IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
167             ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
168              
169             IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
170             WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
171             THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
172             GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
173             USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
174             DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
175             PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
176             EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
177             SUCH DAMAGES.
178              
179             =cut