File Coverage

lib/App/Perlbrew/Patchperl.pm
Criterion Covered Total %
statement 29 29 100.0
branch 4 4 100.0
condition 5 6 83.3
subroutine 10 10 100.0
pod 0 3 0.0
total 48 52 92.3


line stmt bran cond sub pod time code
1             package App::Perlbrew::Patchperl;
2 69     69   709 use strict;
  69         466  
  69         2926  
3 69     69   508 use warnings;
  69         250  
  69         3402  
4 69     69   18483 use 5.008;
  69         240  
5              
6 69     69   342 use App::Perlbrew::Path::Root;
  69         151  
  69         3053  
7 69     69   391 use Capture::Tiny qw(capture);
  69         134  
  69         8293  
8              
9 69     69   421 use Exporter 'import';
  69         220  
  69         30321  
10             our @EXPORT_OK = qw(maybe_patchperl);
11              
12             sub maybe_patchperl {
13 9     9 0 57 my App::Perlbrew::Path::Root $perlbrew_root = shift;
14             return (
15 9   100     31 maybe_patchperl_in_app_root($perlbrew_root) ||
16             maybe_patchperl_in_system()
17             );
18             }
19              
20             sub maybe_patchperl_in_app_root {
21 9     9 0 16 my App::Perlbrew::Path::Root $perlbrew_root = shift;
22 9         41 my $patchperl = $perlbrew_root->bin("patchperl");
23              
24 9 100 66     39 if (-x $patchperl && -f _) {
25 2         10 return $patchperl;
26             } else {
27 7         88 return undef;
28             }
29             }
30              
31             sub maybe_patchperl_in_system {
32             my (undef, undef, $exit_status) = capture {
33 7     7   2538358 system("patchperl --version");
34 7     7 0 392 };
35              
36 7 100       12863 if ($exit_status == 0) {
37 5         239 return "patchperl"
38             } else {
39 2         34 return undef;
40             }
41             }
42              
43             1;