Scheme/Perl5/Build.pm untested

filter: Statementstmt 0.0% 0 / 59 Branchbran 0.0% 0 / 16 Conditioncond 0.0% 0 / 8 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 0.0% 0 / 15 Podpod 0.0% 0 / 8 totaltotal 0.0% 0 / 110 CC 9 SCAR 20.9
CC
9
Cov
0%
execute_buildtest
20.0
execute_buildpl
12.0
execute_build
12.0
CRAP 8.1
1 package PITA::Scheme::Perl5::Build;
2  
3 # Class for implementing the perl5-build testing scheme
4  
5 use 5.005;
6 use strict;
7 use Carp ();
8 use File::Spec ();
9 use File::Which ();
10 use PITA::Scheme::Perl ();
11  
12 use vars qw{$VERSION @ISA};
13 BEGIN {
14 $VERSION = '0.43';
15 @ISA = 'PITA::Scheme::Perl';
16 }
17  
18  
19  
20  
21  
22 #####################################################################
23 # Constructor
24  
25 sub default_path {
26 File::Which::which('perl') || '';
27 }
28  
29 sub new {
30 my $class = shift;
31 my $self = $class->SUPER::new(@_);
32  
33 ### Additional checks, if any
34  
35 $self;
36 }
37  
38  
39  
40  
41  
42 #####################################################################
43 # PITA::Scheme Methods
44  
45 sub prepare_package {
46 my $self = shift;
47  
48 # Do the generic unpacking
49 $self->SUPER::prepare_package(@_);
50  
51 # Validate that the package has a Makefile.PL in the root
52 unless ( -f $self->workarea_file('Build.PL') ) {
53 Carp::croak("Package does not contain a Makefile.PL");
54 }
55  
56 $self;
57 }
58  
59 sub execute_all {
60 my $self = shift;
61  
62 # Run the Makefile.PL
63 $self->execute_buildpl or return '';
64  
65 # Run the make
66 $self->execute_build or return '';
67  
68 # Run the tests
69 $self->execute_buildtest or return '';
70  
71 1;
72 }
73  
74 sub execute_buildpl {
75 my $self = shift;
76 unless ( -f $self->workarea_file('Build.PL') ) {
77 Carp::croak("Cannot execute_makefilepl without a Build.PL");
78 }
79  
80 # Run the Makefile.PL
81 my $command = $self->execute_command('perl', 'Build.PL');
82  
83 # Did it create a make file
84 if ( -f $self->workarea_file('Build') ) {
85 # Worked as expected
86 ### Do we need to add stuff here later?
87 return 1;
88 }
89  
90 # Didn't work
91 ### Do we need to add stuff here later?
92 return '';
93 }
94  
95 sub execute_build {
96 my $self = shift;
97 unless ( -f $self->workarea_file('Build') ) {
98 Carp::croak("Cannot execute_make without a Build file");
99 }
100  
101 # Run the make
102 my $command = $self->execute_command('perl', 'Build');
103  
104 # Did it create a blib directory?
105 if ( -d $self->workarea_file('blib') ) {
106 # Worked as expected
107 ### Do we need to add stuff here later?
108 return 1;
109 }
110  
111 # Didn't work
112 ### Do we need to add stuff here later?
113 return '';
114 }
115  
116 sub execute_buildtest {
117 my $self = shift;
118 unless ( -f $self->workarea_file('Build') ) {
119 Carp::croak("Cannot execute_maketest without a Build file");
120 }
121 unless ( -d $self->workarea_file('blib') ) {
122 Carp::croak("Cannot execute_maketest without a blib");
123 }
124  
125 # Run the make test
126 my $command = $self->execute_command('perl', 'Build', 'test');
127  
128 # Did it... erm...
129 if ( 1 ) {
130 # Worked as expected
131 ### Do we need to add stuff here later?
132 return 1;
133 }
134  
135 # Didn't work
136 ### Do we need to add stuff here later?
137 return '';
138 }
139  
140 1;