blib/lib/pler.pm

filter: Statementstmt 34.9% 65 / 186 Branchbran 7.6% 6 / 78 Conditioncond 4.6% 2 / 43 MC/DCmcdc 0.0% 0 / 24 Subroutinesub 35.7% 20 / 56 Podpod 0.0% 0 / 37 totaltotal 21.9% 93 / 424 CC 55 SCAR 62.4
CC
55
Cov
24%
main
1482.0
in_distroot
12.0
old_makefile
12.0
CRAP 514.4
↑ Summary
1 package pler;
2  
3 # See 'sub main' for main functionality
4  
5 2 ▶use 5.00503;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use Config;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 ▶use Cwd 3.00 ();
Subroutine BEGIN: called CC=1 SCAR=0.0
10 2 ▶use File::Which 0.05 ();
Subroutine BEGIN: called CC=1 SCAR=0.0
11 2 ▶use File::Spec 0.80 ();
Subroutine BEGIN: called CC=1 SCAR=0.0
12 2 ▶use File::Spec::Functions ':ALL';
Subroutine BEGIN: called CC=1 SCAR=0.0
13 2 ▶use File::Find::Rule 0.20 ();
Subroutine BEGIN: called CC=1 SCAR=0.0
14 2 ▶use Getopt::Long 0 ();
Subroutine BEGIN: called CC=1 SCAR=0.0
15 2 ▶use Probe::Perl 0.01 ();
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 2 ▶use vars qw{$VERSION};
Subroutine BEGIN: called CC=1 SCAR=0.0
18 2 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
19 2 $VERSION = '1.06';
20 }
21  
22 # Does exec work on this platform
23 2 ▶use constant EXEC_OK => ($^O ne 'MSWin32' and $^O ne 'cygwin');
Subroutine BEGIN: called CC=2 SCAR=7.6
Condition33%1/3
$^O ne 'MSWin32' && $^O ne 'cygwin'
!ll&&!rl&&r
002
MC/DC0%0/2
$^O ne 'MSWin32' && $^O ne 'cygwin'
$^O ne 'MSWin32' $^O ne 'cygwin'
Truth table33%1/3
A && B
A= $^O ne 'MSWin32'B= $^O ne 'cygwin'
ABresult
0X0
100
111
24  
25 # Can you overwrite an open file on this platform
26 2 ▶use constant OVERWRITE_OK => !! ( $^O ne 'MSWin32' );
Subroutine BEGIN: called CC=1 SCAR=0.0
27  
28  
29  
30  
31  
32  
33 #####################################################################
34 # Resource Locations
35  
36 0 ▶sub MakefilePL () {
Subroutine MakefilePL: not called CC=1 SCAR=6.9
Pod undocumented
37 0 catfile( curdir(), 'Makefile.PL' );
38 }
39  
40 0 ▶sub BuildPL () {
Subroutine BuildPL: not called CC=1 SCAR=6.9
Pod undocumented
41 0 catfile( curdir(), 'Build.PL' );
42 }
43  
44 0 ▶sub Makefile () {
Subroutine Makefile: not called CC=1 SCAR=6.9
Pod undocumented
45 0 catfile( curdir(), 'Makefile' );
46 }
47  
48 0 ▶sub Build () {
Subroutine Build: not called CC=1 SCAR=6.9
Pod undocumented
49 0 catfile( curdir(), 'Build' );
50 }
51  
52 4 ▶sub perl () {
Subroutine perl: called CC=1 SCAR=0.0
Pod undocumented
53 4 Probe::Perl->find_perl_interpreter;
54 }
55  
56 # Look for make in $Config
57 4 ▶sub make () {
Subroutine make: called CC=2 SCAR=7.4
Pod undocumented
58 4 my $make = $Config::Config{make};
59 4 my $found = File::Which::which( $make );
60 4 ▶ unless ( $found ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($found) 0 4 4
61 0 Carp::croak("Failed to find '$make' (as specified by \$Config{make})");
62 }
63 4 return $found;
64 }
65  
66 0 ▶sub blib () {
Subroutine blib: not called CC=1 SCAR=6.9
Pod undocumented
67 0 catdir( curdir(), 'blib' );
68 }
69  
70 0 ▶sub inc () {
Subroutine inc: not called CC=1 SCAR=6.9
Pod undocumented
71 0 catdir( curdir(), 'inc' );
72 }
73  
74 0 ▶sub lib () {
Subroutine lib: not called CC=1 SCAR=6.9
Pod undocumented
75 0 catdir( curdir(), 'lib' );
76 }
77  
78 0 ▶sub t () {
Subroutine t: not called CC=1 SCAR=6.9
Pod undocumented
79 0 catdir( curdir(), 't' );
80 }
81  
82 0 ▶sub xt () {
Subroutine xt: not called CC=1 SCAR=6.9
Pod undocumented
83 0 catdir( curdir(), 'xt' );
84 }
85  
86  
87  
88  
89  
90 #####################################################################
91 # Convenience Logic
92  
93 0 ▶sub has_makefilepl () {
Subroutine has_makefilepl: not called CC=1 SCAR=6.9
Pod undocumented
94 0 !! -f MakefilePL;
95 }
96  
97 0 ▶sub has_buildpl () {
Subroutine has_buildpl: not called CC=1 SCAR=6.9
Pod undocumented
98 0 !! -f BuildPL;
99 }
100  
101 0 ▶sub has_makefile () {
Subroutine has_makefile: not called CC=1 SCAR=6.9
Pod undocumented
102 0 !! -f Makefile;
103 }
104  
105 0 ▶sub has_build () {
Subroutine has_build: not called CC=1 SCAR=6.9
Pod undocumented
106 0 !! -f Build;
107 }
108  
109 0 ▶sub has_blib () {
Subroutine has_blib: not called CC=1 SCAR=6.9
Pod undocumented
110 0 !! -d blib;
111 }
112  
113 0 ▶sub blibpm () {
Subroutine blibpm: not called CC=1 SCAR=6.9
Pod undocumented
114 0 eval {
115 0 require blib;
116 };
117 0 return ! $@;
118 }
119  
120 0 ▶sub has_inc () {
Subroutine has_inc: not called CC=1 SCAR=6.9
Pod undocumented
121 0 !! -f inc;
122 }
123  
124 0 ▶sub has_lib () {
Subroutine has_lib: not called CC=1 SCAR=6.9
Pod undocumented
125 0 !! -d lib;
126 }
127  
128 0 ▶sub has_t () {
Subroutine has_t: not called CC=1 SCAR=6.9
Pod undocumented
129 0 !! -d t;
130 }
131  
132 0 ▶sub has_xt () {
Subroutine has_xt: not called CC=1 SCAR=6.9
Pod undocumented
133 0 !! -d xt;
134 }
135  
136 0 ▶sub in_distroot () {
Subroutine in_distroot: not called CC=3 SCAR=24.8
Pod undocumented
137 !! (
138 0 ▶ has_makefilepl or (has_lib and has_t)
Condition0%0/6
&has_makefilepl() || &has_lib() && &has_t()
l!l&&r!l&&!r
000
&has_lib() and &has_t()
!ll&&!rl&&r
000
MC/DC0%0/3
&has_makefilepl() || &has_lib() && &has_t()
&has_makefilepl() &has_lib() &has_t()
Truth table0%0/4
A || B and C
A= &has_makefilepl()B= &has_lib()C= &has_t()
ABCresult
1XX1
0111
00X0
0100
139 );
140 }
141  
142 0 ▶sub in_subdir () {
Subroutine in_subdir: not called CC=2 SCAR=17.9
Pod undocumented
143 !! (
144 0 ▶ -f catfile( updir(), 'Makefile.PL' )
Condition0%0/3
-f catfile('..', 'Makefile.PL') || -d catdir('..', 't')
l!l&&r!l&&!r
000
MC/DC0%0/2
-f catfile('..', 'Makefile.PL') || -d catdir('..', 't')
-f catfile('..', 'Makefile.PL') -d catdir('..', 't')
Truth table0%0/3
A || B
A= -f catfile('..', 'Makefile.PL')B= -d catdir('..', 't')
ABresult
1X1
011
000
145 or
146 -d catdir( updir(), 't' )
147 );
148 }
149  
150 0 ▶sub needs_makefile () {
Subroutine needs_makefile: not called CC=2 SCAR=17.9
Pod undocumented
151 0 ▶ has_makefilepl and ! has_makefile;
Branch: 1 branch
BranchTrueFalseTotal
&has_makefilepl() and not &has_makefile() 0 0 0
152 }
153  
154 0 ▶sub needs_build () {
Subroutine needs_build: not called CC=2 SCAR=17.9
Pod undocumented
155 0 ▶ has_buildpl and ! has_build;
Branch: 1 branch
BranchTrueFalseTotal
&has_buildpl() and not &has_build() 0 0 0
156 }
157  
158 0 ▶sub mtime ($) {
Subroutine mtime: not called CC=1 SCAR=6.9
Pod undocumented
159 0 (stat($_[0]))[9];
160 }
161  
162 0 ▶sub old_makefile () {
Subroutine old_makefile: not called CC=3 SCAR=24.8
Pod undocumented
163 0 ▶ has_makefile
Branch: 1 branch
BranchTrueFalseTotal
&has_makefile() and &has_makefilepl() and &mtime(scalar &Makefile()) < &mtime(scalar &MakefilePL()) 0 0 0
Condition0%0/3
&has_makefile() and &has_makefilepl()
!ll&&!rl&&r
000
MC/DC0%0/2
&has_makefile() and &has_makefilepl()
&has_makefile() &has_makefilepl()
Truth table0%0/3
A and B
A= &has_makefile()B= &has_makefilepl()
ABresult
0X0
100
111
164 and
165 has_makefilepl
166 and
167 mtime(Makefile) < mtime(MakefilePL);
168 }
169  
170 0 ▶sub old_build () {
Subroutine old_build: not called CC=3 SCAR=24.8
Pod undocumented
171 0 ▶ has_build
Branch: 1 branch
BranchTrueFalseTotal
&has_build() and &has_buildpl() and &mtime(scalar &Build()) < &mtime(scalar &BuildPL()) 0 0 0
Condition0%0/3
&has_build() and &has_buildpl()
!ll&&!rl&&r
000
MC/DC0%0/2
&has_build() and &has_buildpl()
&has_build() &has_buildpl()
Truth table0%0/3
A and B
A= &has_build()B= &has_buildpl()
ABresult
0X0
100
111
172 and
173 has_buildpl
174 and
175 mtime(Build) < mtime(BuildPL);
176 }
177  
178  
179  
180  
181  
182 #####################################################################
183 # Utility Functions
184  
185 # Support verbosity
186 2 ▶use vars qw{$VERBOSE};
Subroutine BEGIN: called CC=1 SCAR=0.0
187 2 ▶BEGIN {
Subroutine BEGIN: called CC=2 SCAR=7.6
188 2 ▶ $VERBOSE ||= 0;
Condition50%1/2
$pler::VERBOSE ||= 0
l!l
02
MC/DC0%0/1
$pler::VERBOSE ||= 0
$pler::VERBOSE
Truth table50%1/2
A
A= $pler::VERBOSE
Aresult
11
00
189 }
190  
191 0 ▶sub is_verbose {
Subroutine is_verbose: not called CC=1 SCAR=6.9
Pod undocumented
192 0 $VERBOSE;
193 }
194  
195 0 ▶sub verbose ($) {
Subroutine verbose: not called CC=2 SCAR=17.9
Pod undocumented
196 0 ▶ message( $_[0] ) if $VERBOSE;
Branch: 1 branch
BranchTrueFalseTotal
if $pler::VERBOSE 0 0 0
197 }
198  
199 0 ▶sub message ($) {
Subroutine message: not called CC=1 SCAR=6.9
Pod undocumented
200 0 print $_[0];
201 }
202  
203 0 ▶sub error (@) {
Subroutine error: not called CC=1 SCAR=6.9
Pod undocumented
204 0 print ' ' . join '', map { "$_\n" } ('', @_, '');
205 0 exit(255);
206 }
207  
208 0 ▶sub run ($) {
Subroutine run: not called CC=1 SCAR=6.9
Pod undocumented
209 0 my $cmd = shift;
210 0 verbose( "> $cmd" );
211 0 system( $cmd );
212 }
213  
214 0 ▶sub handoff (@) {
Subroutine handoff: not called CC=2 SCAR=17.9
Pod undocumented
215 0 my $cmd = join ' ', @_;
216 0 verbose( "> $cmd" );
217 0 $ENV{HARNESS_ACTIVE} = 1;
218 0 $ENV{RELEASE_TESTING} = 1;
219 0 if ( EXEC_OK ) {
220 0 ▶ exec( @_ ) or Carp::croak("Failed to exec '$cmd'");
Branch: 1 branch
BranchTrueFalseTotal
exec @_ or Carp::croak("Failed to exec '${cmd}'") 0 0 0
221 } else {
222 system( @_ );
223 exit(0);
224 }
225 }
226  
227  
228  
229  
230  
231 #####################################################################
232 # Main Script
233  
234 2 my @SWITCHES = ();
235  
236 0 ▶sub main {
Subroutine main: not called CC=38 SCAR=73.0
Pod undocumented
237 0 Getopt::Long::Configure('no_ignore_case');
238 Getopt::Long::GetOptions(
239 'help' => \&help,
240 0 ▶ 'V' => sub { print "pler $VERSION\n"; exit(0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
241 0 ▶ 'w' => sub { push @SWITCHES, '-w' },
Subroutine __ANON__: not called CC=1 SCAR=6.9
242 0 );
243  
244 # Get the script name
245 0 my $script = shift @ARGV;
246 0 ▶ unless ( defined $script ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $script) 0 0 0
247 0 print "# No file name pattern provided, using 't'...\n";
248 0 $script = 't';
249 }
250  
251 # Abuse the highly mature logic in Cwd to define an $ENV{PWD} value
252 # by chdir'ing to the current directory.
253 # This lets us get the current directory without losing symlinks.
254 0 Cwd::chdir(curdir());
255 0 ▶ my $orig = $ENV{PWD} or die "Failed to get original directory";
Branch: 1 branch
BranchTrueFalseTotal
my $orig = $ENV{"PWD"} or die "Failed to get original directory" 0 0 0
256  
257 # Can we locate the distribution root
258 0 my ($v,$d,$f) = splitpath($ENV{PWD}, 'nofile');
259 0 my @dirs = splitdir($d);
260 0 ▶ while ( @dirs ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@dirs) 0 0 0
261 0 my $buildpl = catpath(
262 $v, catdir(@dirs), BuildPL,
263 );
264 0 my $makefilepl = catpath(
265 $v, catdir(@dirs), MakefilePL,
266 );
267 0 ▶ unless ( -f $buildpl or -f $makefilepl ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (-f $buildpl or -f $makefilepl) 0 0 0
Condition0%0/3
-f $buildpl or -f $makefilepl
l!l&&r!l&&!r
000
MC/DC0%0/2
-f $buildpl or -f $makefilepl
-f $buildpl -f $makefilepl
Truth table0%0/3
A or B
A= -f $buildplB= -f $makefilepl
ABresult
1X1
011
000
268 0 pop @dirs;
269 0 next;
270 }
271  
272 # This is a distroot
273 0 my $distroot = catpath( $v, catdir(@dirs), undef );
274 0 Cwd::chdir($distroot);
275 0 last;
276 }
277 0 ▶ unless ( in_distroot ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (&in_distroot()) 0 0 0
278 0 error "Failed to locate the distribution root";
279 }
280  
281 # Makefile.PL? Or Build.PL?
282 0 ▶ my $BUILD_SYSTEM = has_buildpl ? 'build' : has_makefilepl ? 'make' : '';
Branch: 2 branches
BranchTrueFalseTotal
&has_buildpl() ? : 0 0 0
&has_makefilepl() ? : 0 0 0
283 0 ▶ if ( $BUILD_SYSTEM eq 'build' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($BUILD_SYSTEM eq "build") 0 0 0
284 # Because Module::Build always runs with warnings on,
285 # pler will as well when you use a Build.PL
286 0 ▶ unless ( grep { $_ eq '-w' } @SWITCHES ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (grep {$_ eq "-w";} @SWITCHES) 0 0 0
287 0 push @SWITCHES, '-w';
288 }
289 }
290  
291 # If needed, regenerate the Makefile or Build file
292 # Currently we do not remember Makefile.PL or Build.PL params
293 0 ▶ if ( $BUILD_SYSTEM eq 'make' ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($BUILD_SYSTEM eq 'make') { } 0 0 0
elsif ($BUILD_SYSTEM eq 'build') { } 0 0 0
294 0 ▶ if ( needs_makefile or (old_makefile and ! OVERWRITE_OK) ) {
Branch: 1 branch
BranchTrueFalseTotal
if () 0 0 0
Condition0%0/5
&needs_makefile() or
l!l&&r!l&&!r
000
&old_makefile() and
!ll
00
MC/DC0%0/2
&needs_makefile() or
&needs_makefile() &old_makefile()
Truth table0%0/3
A or B
A= &needs_makefile()B= &old_makefile()
ABresult
1X1
011
000
295 0 run( join ' ', perl, MakefilePL );
296 }
297 } elsif ( $BUILD_SYSTEM eq 'build' ) {
298 0 ▶ if ( needs_build or old_build ) {
Branch: 1 branch
BranchTrueFalseTotal
if (&needs_build() or &old_build()) 0 0 0
Condition0%0/3
&needs_build() or &old_build()
l!l&&r!l&&!r
000
MC/DC0%0/2
&needs_build() or &old_build()
&needs_build() &old_build()
Truth table0%0/3
A or B
A= &needs_build()B= &old_build()
ABresult
1X1
011
000
299 0 run( join ' ', perl, BuildPL );
300 }
301 }
302  
303 # Locate the test script to run
304 0 ▶ if ( $script =~ /\.t$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($script =~ /\.t$/) { } 0 0 0
305 # EITHER
306 # 1. They tab-completed the script relative to the original directory (most likely)
307 # OR
308 # 2. They typed the entire name of the test script
309 0 my $tab_completed = File::Spec->catfile( $orig, $script );
310 0 ▶ if ( -f $tab_completed ) {
Branch: 1 branch
BranchTrueFalseTotal
if (-f $tab_completed) 0 0 0
311 0 ▶ if ( $orig eq $ENV{PWD} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($orig eq $ENV{'PWD'}) { } 0 0 0
312 0 $script = $script; # Included for clarity
313 } else {
314 0 $script = File::Spec->abs2rel( $tab_completed, $ENV{PWD} );
315 }
316 }
317  
318 } else {
319 # Get the list of possible tests
320 0 ▶ my @directory = ( 't', has_xt ? 'xt' : () );
Branch: 1 branch
BranchTrueFalseTotal
&has_xt() ? : 0 0 0
321 0 my @possible = File::Find::Rule->name('*.t')->file->in(@directory);
322  
323 # Filter by the search terms to find matching tests
324 0 my $matches = filter(
325 [ $script, @ARGV ],
326 [ @possible ],
327 );
328 0 ▶ unless ( @$matches ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@$matches) 0 0 0
329 0 error "No tests match '$script'";
330 }
331 0 ▶ if ( @$matches > 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@$matches > 1) 0 0 0
332 error(
333 "More than one possible test",
334 0 map { " $_" } sort @$matches,
335 );
336 }
337 0 $script = $matches->[0];
338  
339 # Localize the path
340 0 $script = File::Spec->catfile( split /\//, $script );
341 }
342 0 ▶ unless ( -f $script ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (-f $script) 0 0 0
343 0 error "Test script '$script' does not exist";
344 }
345  
346 # Rerun make or Build if needed
347 0 ▶ if ( $BUILD_SYSTEM eq 'make' ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($BUILD_SYSTEM eq 'make') { } 0 0 0
elsif ($BUILD_SYSTEM eq 'build') { } 0 0 0
348 # Do NOT run make if there is no Makefile.PL, because it likely means
349 # there is a hand-written Makefile and NOT one derived from Makefile.PL,
350 # and we have no idea what functionality we might trigger.
351 0 ▶ if ( in_distroot and has_makefile and has_makefilepl ) {
Branch: 1 branch
BranchTrueFalseTotal
if (&in_distroot() and &has_makefile() and &has_makefilepl()) 0 0 0
Condition0%0/6
&in_distroot() and &has_makefile() and &has_makefilepl()
!ll&&!rl&&r
000
&in_distroot() and &has_makefile()
!ll&&!rl&&r
000
MC/DC0%0/3
&in_distroot() and &has_makefile() and &has_makefilepl()
&in_distroot() &has_makefile() &has_makefilepl()
Truth table0%0/4
A and B and C
A= &in_distroot()B= &has_makefile()C= &has_makefilepl()
ABCresult
0XX0
10X0
1100
1111
352 0 run( make );
353 }
354 } elsif ( $BUILD_SYSTEM eq 'build' ) {
355 0 ▶ if ( in_distroot and has_build and has_buildpl ) {
Branch: 1 branch
BranchTrueFalseTotal
if (&in_distroot() and &has_build() and &has_buildpl()) 0 0 0
Condition0%0/6
&in_distroot() and &has_build() and &has_buildpl()
!ll&&!rl&&r
000
&in_distroot() and &has_build()
!ll&&!rl&&r
000
MC/DC0%0/3
&in_distroot() and &has_build() and &has_buildpl()
&in_distroot() &has_build() &has_buildpl()
Truth table0%0/4
A and B and C
A= &in_distroot()B= &has_build()C= &has_buildpl()
ABCresult
0XX0
10X0
1100
1111
356 0 run( Build );
357 }
358 }
359  
360 # Passing includes via -I params is not good enough
361 # because you can't subshell them, and it's also not
362 # how MakeMaker does it anyway.
363 # We need to hack/extend PERL5LIB instead.
364 0 my $path_sep = $Config{path_sep};
365 0 my @PERL5LIB = ();
366  
367 # Build the command to execute
368 0 my @flags = @SWITCHES;
369 0 ▶ if ( has_blib ) {
Branch: 2 branches
BranchTrueFalseTotal
if (&has_blib()) { } 0 0 0
elsif (&has_lib()) { } 0 0 0
370 0 ▶ if ( has_inc ) {
Branch: 1 branch
BranchTrueFalseTotal
if (&has_inc()) 0 0 0
371 0 push @PERL5LIB, inc;
372 }
373 0 push @PERL5LIB, File::Spec->catdir(
374 blib, 'lib',
375 );
376 0 push @PERL5LIB, File::Spec->catdir(
377 blib, 'arch',
378 );
379 } elsif ( has_lib ) {
380 0 push @PERL5LIB, lib;
381 }
382  
383 # Absolutify the PERL5LIB elements so they will survive
384 # the test script changing it's CWD. This was added to
385 # deal with the path-shifting of the Padre tests.
386 @PERL5LIB = map {
387 0 File::Spec->rel2abs($_)
388 } @PERL5LIB;
389  
390 # Hand off to the perl debugger
391 0 ▶ unless ( pler->is_verbose ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ("pler"->is_verbose) 0 0 0
392 0 message( "# Debugging $script...\n" );
393 }
394 0 my @cmd = ( perl, @flags, '-d', $script );
395 local $ENV{PERL5LIB} = defined($ENV{PERL5LIB})
396 ? join( $path_sep, @PERL5LIB, $ENV{PERL5LIB} )
397 0 ▶ : join( $path_sep, @PERL5LIB );
Branch: 1 branch
BranchTrueFalseTotal
defined $ENV{'PERL5LIB'} ? : 0 0 0
398 0 handoff( @cmd );
399 }
400  
401 # Encapsulates the smart filtering as a function
402 3 ▶sub filter {
Subroutine filter: called CC=4 SCAR=14.0
Pod undocumented
403 3 my $terms = shift;
404 3 my $possible = shift;
405 3 my @matches = @$possible;
406  
407 3 ▶ while ( @$terms ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@$terms) 3 3 6
408 3 my $term = shift @$terms;
409  
410 3 ▶ if ( ref $term eq 'Regexp' ) {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $term eq 'Regexp') { } 0 3 3
elsif ($term =~ /^[1-9]\d*$/) { } 2 1 3
411 # If the term is a regexp apply it directly
412 0 @matches = grep { $_ =~ $term } @matches;
413 } elsif ( $term =~ /^[1-9]\d*$/ ) {
414 # If the search is a pure integer (without leading
415 # zeros) attempt a specialised numeric filter.
416 2 @matches = grep { /\b0*${term}[^0-9]/ } @matches;
417 } else {
418 # Otherwise treat it as a naive string match
419 1 $term = quotemeta $term;
420 1 @matches = grep { /$term/i } @matches;
421 }
422 }
423  
424 3 return \@matches;
425 }
426  
427 0 ▶sub help { print <<'END_HELP'; exit(0); }
Subroutine help: not called CC=1 SCAR=6.9
Pod undocumented
428 Usage:
429 pler [options] [file/pattern]
430  
431 Options:
432 -V Print the pler version
433 -h, --help Display this help
434 -w Run test with the -w warnings flag
435 END_HELP
436  
437 2 1;
438  
439 =pod
440  
441 =head1 NAME
442  
443 pler - The DWIM Perl Debugger
444  
445 =head1 DESCRIPTION
446  
447 B<pler> is a small script which provides a sanity layer for debugging
448 test scripts in Perl distributions.
449  
450 While L<prove> has proven itself to be a highly useful program for
451 manually running one or more groups of scripts in a distribution,
452 what we also need is something that provides a similar level of
453 intelligence in a debugging context.
454  
455 B<pler> checks that the environment is sound, runs some cleanup tasks
456 if needed, makes sure you are in the right directory, and then hands off
457 to the perl debugger as normal.
458  
459 =head1 TO DO
460  
461 - Tweak some small terminal related issues on Win32
462  
463 =head1 SUPPORT
464  
465 All bugs should be filed via the bug tracker at
466  
467 L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=pler>
468  
469 For other issues, or commercial enhancement and support, contact the author
470  
471 =head1 AUTHOR
472  
473 Adam Kennedy E<lt>adamk@cpan.orgE<gt>
474  
475 =head1 SEE ALSO
476  
477 L<prove>, L<http://ali.as/>
478  
479 =head1 COPYRIGHT
480  
481 Copyright 2006 - 2010 Adam Kennedy.
482  
483 This program is free software; you can redistribute
484 it and/or modify it under the same terms as Perl itself.
485  
486 The full text of the license can be found in the
487 LICENSE file included with this module.
488  
489 =cut
↑ Summary