Build/PPK/Deptool/Git.pm untested

filter: Statementstmt 0.0% 0 / 38 Branchbran 0.0% 0 / 10 Conditioncond 0.0% 0 / 17 MC/DCmcdc 0.0% 0 / 9 Subroutinesub 0.0% 0 / 7 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 82 CC 6 SCAR 30.9
CC
6
Cov
0%
fetch_dist
42.0
BEGIN
2.0
BEGIN
2.0
CRAP 22.0
1 package Build::PPK::Deptool::Git;
2  
3 # Copyright (c) 2018, cPanel, L.L.C.
4 # All rights reserved.
5 # http://cpanel.net/
6 #
7 # This is free software; you can redistribute it and/or modify it under the same
8 # terms as Perl itself. See the LICENSE file for further details.
9  
10 use strict;
11 use warnings;
12  
13 use File::Basename ();
14 use Cwd ();
15  
16 use Build::PPK::Exec ();
17 use Build::PPK::Deptool::Util ();
18  
19 my $PERL = $^X;
20 my $MAKE = 'make';
21  
22 sub fetch_dist {
23 my ( $class, %args ) = @_;
24 my $clone = File::Basename::basename( $args{'url'}, '.git' );
25  
26 if ( -e $args{'path'} && -d $clone ) {
27 return unless Build::PPK::Deptool::Util->older_than( $args{'path'}, $clone );
28 }
29  
30 unless ( -d $clone ) {
31 Build::PPK::Exec->silent( qw(git clone), $args{'url'}, $clone ) == 0 or die("Unable to clone repo $args{'url'}: $@");
32 }
33  
34 if ( -e $args{'path'} ) {
35 Build::PPK::Deptool::Util->recursive_delete( $args{'path'} );
36 }
37  
38 my $oldcwd = Cwd::getcwd();
39 my $distrule = ( $args{'dist'} =~ /\.tar/ ) ? 'tardist' : 'distdir';
40  
41 chdir($clone) or die("Unable to chdir() to $clone: $!");
42  
43 Build::PPK::Exec->silent( $PERL, 'Makefile.PL' ) == 0 or die("Unable to run Makefile.PL: $@");
44 Build::PPK::Exec->silent( $MAKE, 'manifest' ) == 0 or die("Unable to run 'make manifest': $@");
45 Build::PPK::Exec->silent( $MAKE, $distrule ) == 0 or die("Unable to run 'make $distrule': $@");
46  
47 chdir $oldcwd or die("Unable to chdir() to old directory: $!");
48  
49 rename( "$clone/$args{'dist'}", $args{'path'} ) or die("Unable to rename $clone/$args{'dist'} to $args{'path'}: $!");
50 Build::PPK::Deptool::Util->recursive_delete($clone);
51  
52 return;
53 }
54  
55 1;