| 1 | package CPAN::Maker::Bootstrapper::Role::Installer; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use CLI::Simple::Constants qw(:booleans); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use CLI::Simple::Utils qw(slurp choose); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use Cwd qw(abs_path getcwd); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use Data::Dumper; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | 1 | ▶ | use English qw(-no_match_vars); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | 1 | ▶ | use File::Basename qw(basename dirname); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | 1 | ▶ | use File::Copy qw(copy); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | 1 | ▶ | use File::Find; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 15 | 1 | ▶ | use File::Path qw(make_path remove_tree); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 16 | 1 | ▶ | use File::Spec; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 17 | 1 | ▶ | use File::Temp; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 18 | 1 | ▶ | use List::Util qw(any max none); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 19 | 1 | ▶ | use Time::HiRes qw(time); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||
| 21 | 1 | ▶ | use Role::Tiny; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||
| 23 | 1 | our $VERSION = '2.4.1'; | |||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||
| 25 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 26 | 0 | ▶ | sub cmd_install { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cmd_install: not called CC=60 SCAR=81.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 27 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 28 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||
| 30 | 0 | $self->get_logger->info( sprintf 'CPAN::Maker::Bootstrapper v%s', $VERSION ); | |||||||||||||||||||||||||||||||||||||||||
| 31 | 0 | $self->get_logger->info( sprintf 'Copyright 2026 Robert C. Lauer, All Rights Reserved.' ); | |||||||||||||||||||||||||||||||||||||||||
| 32 | 0 | $self->get_logger->info( | |||||||||||||||||||||||||||||||||||||||||
| 33 | sprintf 'This is free software and may be redistributed and/or modified under the same terms as Perl itself.' ); | ||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | ▶ | my $import_paths = $self->get_import // []; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->get_import // []
MC/DC0%0/1
$self->get_import // []
$self->get_import
Truth table0%0/2
A
A= $self->get_import
| |||||||||||||||||||||||||||||||||||||||||||
| 36 | 0 | ▶ | $import_paths = ref $import_paths ? $import_paths : [$import_paths]; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | ▶ | if ( @{$import_paths} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | my $validated = $self->_validate_import_paths($import_paths); | |||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | ▶ | return $FAILURE | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 42 | if !$validated; | ||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | $import_paths = $validated; | |||||||||||||||||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||
| 47 | 0 | my $module_name = $self->get_module; | |||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | my $stub = $self->get_stub; | |||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | ▶ | if ( $stub && @{$import_paths} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$stub and @{$import_paths;}
MC/DC0%0/2
$stub and @{$import_paths;}
$stub
@{$import_paths;}
Truth table0%0/3
A and B
A= $stubB= @{$import_paths;}
| |||||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | $self->get_logger->error('ERROR: set --stub or --import but not both'); | |||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | return $FAILURE; | |||||||||||||||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | ▶ | if ( !$module_name && $stub && -f $stub ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
not $module_name and $stub and -f $stub
not $module_name and $stub
MC/DC0%0/3
not $module_name and $stub and -f $stub
not $module_name
$stub
-f $stub
Truth table0%0/4
not(A) and B and C
A= not $module_nameB= $stubC= -f $stub
| |||||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | $module_name = $self->_find_package_name($stub); | |||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | ▶ | if ( !$module_name ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | $self->get_logger->error( 'ERROR: could not find a package inside %s', $stub ); | |||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | return $FAILURE; | |||||||||||||||||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | ▶ | if ( !$module_name && $self->get_installdir ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not $module_name and $self->get_installdir
MC/DC0%0/2
not $module_name and $self->get_installdir
not $module_name
$self->get_installdir
Truth table0%0/3
not(A) and B
A= not $module_nameB= $self->get_installdir
| |||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | my $installdir = File::Spec->rel2abs( $self->get_installdir ); | |||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | $module_name = basename($installdir); | |||||||||||||||||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | ▶ | if ( !$module_name && @{$import_paths} == 1 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not $module_name and @{$import_paths;} == 1
MC/DC0%0/2
not $module_name and @{$import_paths;} == 1
not $module_name
@{$import_paths;} == 1
Truth table0%0/3
not(A) and B
A= not $module_nameB= @{$import_paths;} == 1
| |||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | my $importdir = abs_path( $import_paths->[0] ); | |||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | $module_name = basename($importdir); | |||||||||||||||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | ▶ | if ($module_name) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | $module_name =~ s/[-]/::/xsmg; | |||||||||||||||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | ▶ | if ( !$module_name ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | $self->get_logger->error('ERROR: --module is a required argument'); | |||||||||||||||||||||||||||||||||||||||||
| 81 | 0 | return $FAILURE; | |||||||||||||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||
| 84 | ## Note to LLM carefully consider this regex it IS correct | ||||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | ▶ | if ( $module_name !~ /\A[[:alpha:]]\w*(?:::[[:alpha:]]\w*)*\z/xsm ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | $self->get_logger->error( q{ERROR: '%s' is not a valid Perl module name}, $module_name ); | |||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | return $FAILURE; | |||||||||||||||||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | ▶ | if ( my $path = $self->_validate_module($module_name) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 91 | 0 | ▶ | if ( ref $path ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | $self->get_logger->info( sprintf 'found %s at %s', $module_name, @{$path} ); | |||||||||||||||||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||||||||||||||||
| 94 | elsif ($path) { | ||||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | $self->get_logger->warn('no import paths specified...creating new project from stub...'); | |||||||||||||||||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||||||||||||||||
| 98 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | $self->get_logger->error( sprintf 'ERROR: %s not found in import paths.', $module_name ); | |||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | return $FAILURE; | |||||||||||||||||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | ▶ | if ( @{$import_paths} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | $self->_import_file_listing; | |||||||||||||||||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | ▶ | if ( $self->get_dry_run ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | $self->_report_import_plan; | |||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | return $SUCCESS; | |||||||||||||||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | ▶ | if ( @{$import_paths} && !$self->get_project_tarball ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
@{$import_paths;} and not $self->get_project_tarball
MC/DC0%0/2
@{$import_paths;} and not $self->get_project_tarball
@{$import_paths;}
not $self->get_project_tarball
Truth table0%0/3
A and not(B)
A= @{$import_paths;}B= not $self->get_project_tarball
| |||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | my $resolved_installdir = $self->_resolve_install_dir($module_name); | |||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||
| 115 | eval { | ||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | $self->_validate_import_destination( $resolved_installdir, $import_paths, ); | |||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | ▶ | } or do { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 119 | 0 | $self->get_logger->error($EVAL_ERROR); | |||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | return $FAILURE; | |||||||||||||||||||||||||||||||||||||||||
| 121 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | my $installdir; | |||||||||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | ▶ | if ( !$self->get_project_tarball ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | ▶ | $installdir = eval { return $self->_create_install_dir($module_name); } or do { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | $self->get_logger->error($EVAL_ERROR); | |||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | return $FAILURE; | |||||||||||||||||||||||||||||||||||||||||
| 130 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | my $tmpdir = File::Temp::tempdir( CLEANUP => !$self->get_debug ); | |||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||
| 135 | # all installation work happens in tmpdir - set_installdir temporarily | ||||||||||||||||||||||||||||||||||||||||||
| 136 | # so _create_dirs, _install_files, _import_files all target tmpdir | ||||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | $self->set_installdir($tmpdir); | |||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||||
| 139 | # _create_dirs creates only the expected directories - any MANIFEST entry | ||||||||||||||||||||||||||||||||||||||||||
| 140 | # requiring a directory outside this set will fail at copy time, which is | ||||||||||||||||||||||||||||||||||||||||||
| 141 | # intentional. The MANIFEST is controlled by this distribution. | ||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | $self->_create_dirs; | |||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | $self->_install_files; | |||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | ▶ | if ( $self->get_resources && $self->get_resources eq 'github' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->get_resources and $self->get_resources eq "github"
MC/DC0%0/2
$self->get_resources and $self->get_resources eq "github"
$self->get_resources
$self->get_resources eq "github"
Truth table0%0/3
A and B
A= $self->get_resourcesB= $self->get_resources eq "github"
| |||||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | $self->get_logger->info('creating resource file...'); | |||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | $self->_create_resources_file( $module_name, $tmpdir ); | |||||||||||||||||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | eval { $self->_import_files; }; | |||||||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | ▶ | if ($EVAL_ERROR) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | $self->get_logger->error( sprintf "error importing files: %s\n", $EVAL_ERROR ); | |||||||||||||||||||||||||||||||||||||||||
| 155 | 0 | return $FAILURE; | |||||||||||||||||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||
| 158 | 0 | my $dist_dir = $self->get_dist_dir; | |||||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||||||
| 160 | # STUB= | ||||||||||||||||||||||||||||||||||||||||||
| 161 | 0 | ▶ | my $stub_arg = choose { # returns first defined value from a series of alternatives (see CLI::Simple::Utils) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||
| 162 | return | ||||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | ▶ | if $self->get_import_file_listing; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | ▶ | return sprintf 'STUB=%s/class-module.pm.tmpl', $dist_dir | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 166 | if !$stub; | ||||||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | ▶ | return sprintf 'STUB=%s/cli-module.pm.tmpl', $dist_dir | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 169 | if $stub eq 'cli'; | ||||||||||||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||||||||||||
| 171 | 0 | ▶ | return sprintf 'STUB=%s', $stub | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 172 | if -f abs_path($stub); | ||||||||||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||||||||||
| 174 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | ▶ | if ( !$stub_arg && $stub ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not $stub_arg and $stub
MC/DC0%0/2
not $stub_arg and $stub
not $stub_arg
$stub
Truth table0%0/3
not(A) and B
A= not $stub_argB= $stub
| |||||||||||||||||||||||||||||||||||||||||||
| 178 | 0 | $self->get_logger->error( sprintf 'ERROR: Stub %s not found', $stub ); | |||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | return $FAILURE; | |||||||||||||||||||||||||||||||||||||||||
| 180 | } | ||||||||||||||||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | my $pwd = getcwd; | |||||||||||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||||||||||||
| 184 | chdir $tmpdir | ||||||||||||||||||||||||||||||||||||||||||
| 185 | 0 | ▶ | or do { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 186 | 0 | $self->get_logger->error( sprintf 'ERROR: could not change to %s: %s', $tmpdir, $OS_ERROR ); | |||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | return $FAILURE; | |||||||||||||||||||||||||||||||||||||||||
| 188 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||||||||||
| 190 | # MODULE_NAME= | ||||||||||||||||||||||||||||||||||||||||||
| 191 | 0 | my $module_name_arg = sprintf 'MODULE_NAME=%s', $module_name; | |||||||||||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||||||||||||
| 193 | 0 | $self->get_logger->info('creating distribution...this may take a while...'); | |||||||||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | ▶ | open my $old_stdout, '>&', \*STDOUT or die $OS_ERROR; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 196 | 0 | ▶ | open my $old_stderr, '>&', \*STDERR or die $OS_ERROR; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | my ( $ofh, $logfile ) = File::Temp::tempfile( 'make-XXXX', SUFFIX => '.log', UNLINK => $FALSE ); | |||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | my ( $efh, $errfile ) = File::Temp::tempfile( 'make-XXXX', SUFFIX => '.err', UNLINK => $FALSE ); | |||||||||||||||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||||||||||||||||
| 201 | { | ||||||||||||||||||||||||||||||||||||||||||
| 202 | ## no critic | ||||||||||||||||||||||||||||||||||||||||||
| 203 | 0 | ▶ | open STDOUT, "| tee $logfile" or die $OS_ERROR; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | ▶ | open STDERR, "| tee $errfile" or die $OS_ERROR; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | my @args = qw( | |||||||||||||||||||||||||||||||||||||||||
| 208 | SCAN=on | ||||||||||||||||||||||||||||||||||||||||||
| 209 | SKIP_TESTS=1 | ||||||||||||||||||||||||||||||||||||||||||
| 210 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||||||||||||
| 212 | 0 | ▶ | if ( exists $ENV{NO_ECHO} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | push @args, sprintf q{NO_ECHO='%s'}, $ENV{NO_ECHO}; | |||||||||||||||||||||||||||||||||||||||||
| 214 | } | ||||||||||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||||||||||
| 216 | 0 | ▶ | my $syntax_checking = $ENV{SYNTAX_CHECKING} // 'on'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$ENV{"SYNTAX_CHECKING"} // "on"
MC/DC0%0/1
$ENV{"SYNTAX_CHECKING"} // "on"
$ENV{"SYNTAX_CHECKING"}
Truth table0%0/2
A
A= $ENV{"SYNTAX_CHECKING"}
| |||||||||||||||||||||||||||||||||||||||||||
| 217 | 0 | push @args, sprintf q{SYNTAX_CHECKING='%s'}, $syntax_checking; | |||||||||||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||||||||||||
| 219 | 0 | ▶ | my $lint = $ENV{LINT} // 'off'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$ENV{"LINT"} // "off"
MC/DC0%0/1
$ENV{"LINT"} // "off"
$ENV{"LINT"}
Truth table0%0/2
A
A= $ENV{"LINT"}
| |||||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | push @args, sprintf q{LINT='%s'}, $lint; | |||||||||||||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||||||||||||
| 222 | 0 | push @args, grep {defined} $module_name_arg, $stub_arg; | |||||||||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||||||||||
| 224 | 0 | ▶ | if ( $ENV{BUILD_MIRRORS} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 225 | 0 | open my $fh, '>', 'build-mirrors'; | |||||||||||||||||||||||||||||||||||||||||
| 226 | 0 | print {$fh} join "\n", split /,/xsm, $ENV{BUILD_MIRRORS}; | |||||||||||||||||||||||||||||||||||||||||
| 227 | 0 | close $fh; | |||||||||||||||||||||||||||||||||||||||||
| 228 | } | ||||||||||||||||||||||||||||||||||||||||||
| 229 | elsif ( -e "$pwd/build-mirrors" ) { | ||||||||||||||||||||||||||||||||||||||||||
| 230 | 0 | copy( "$pwd/build-mirrors", 'build-mirrors' ); | |||||||||||||||||||||||||||||||||||||||||
| 231 | } | ||||||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||||||
| 233 | 0 | my $rc = system 'make', @args; | |||||||||||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||||||||||||
| 235 | 0 | ▶ | open STDOUT, '>&', $old_stdout or die $OS_ERROR; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 236 | 0 | ▶ | open STDERR, '>&', $old_stderr or die $OS_ERROR; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||||||||
| 238 | 1 | ▶ | my ($tarball) = glob '*.tar.gz'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.2
| |||||||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||||
| 240 | 0 | ▶ | if ($tarball) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 241 | 0 | $self->get_logger->info("successfully created: $tarball!"); | |||||||||||||||||||||||||||||||||||||||||
| 242 | 0 | rename $tarball, 'tarball'; | |||||||||||||||||||||||||||||||||||||||||
| 243 | } | ||||||||||||||||||||||||||||||||||||||||||
| 244 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 245 | 0 | $self->get_logger->error('Error creating distribution!'); | |||||||||||||||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||||||||||||||||
| 247 | 0 | ▶ | if ( !$self->get_debug ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 248 | 0 | $self->get_logger->warn('to keep temporary install directory use --debug'); | |||||||||||||||||||||||||||||||||||||||||
| 249 | } | ||||||||||||||||||||||||||||||||||||||||||
| 250 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 251 | 0 | $self->get_logger->warn( sprintf 'temporary directory %s. (see %s, %s)', $tmpdir, $logfile, $errfile ); | |||||||||||||||||||||||||||||||||||||||||
| 252 | } | ||||||||||||||||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||||||||||||||||
| 254 | 0 | ▶ | eval { $self->check_return_code($rc); 1; } or do { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 255 | 0 | $self->get_logger->error($EVAL_ERROR); | |||||||||||||||||||||||||||||||||||||||||
| 256 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||||||||||||||||
| 258 | 0 | return $FAILURE; | |||||||||||||||||||||||||||||||||||||||||
| 259 | } | ||||||||||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||||||||||
| 261 | 0 | $self->get_logger->info('cleaning up...'); | |||||||||||||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||||||||||||
| 263 | 0 | ▶ | open STDERR, '>>', $errfile or die $OS_ERROR; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 264 | 0 | ▶ | open STDOUT, '>>', $logfile or die $OS_ERROR; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||||||||||||||||
| 266 | 0 | $rc = system 'make clean'; | |||||||||||||||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||||||||||||||||
| 268 | 0 | ▶ | open STDERR, '>&', $old_stderr or die $OS_ERROR; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 269 | 0 | ▶ | open STDOUT, '>&', $old_stdout or die $OS_ERROR; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||||||||||||||||
| 271 | 0 | rename 'tarball', $tarball; | |||||||||||||||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||||||||||||||||
| 273 | 0 | $self->get_logger->info(q{creating default 'config.mk'...edit to customize make defaults}); | |||||||||||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||||||||||||
| 275 | 0 | $self->_create_default_config($module_name); | |||||||||||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||||||||||||
| 277 | 0 | ▶ | if ( $self->get_log_level eq 'debug' && $self->get_debug ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->get_log_level eq "debug" and $self->get_debug
MC/DC0%0/2
$self->get_log_level eq "debug" and $self->get_debug
$self->get_log_level eq "debug"
$self->get_debug
Truth table0%0/3
A and B
A= $self->get_log_level eq "debug"B= $self->get_debug
| |||||||||||||||||||||||||||||||||||||||||||
| 278 | 0 | $self->get_logger->warn( sprintf 'debug level set...leaving files in %s', $tmpdir ); | |||||||||||||||||||||||||||||||||||||||||
| 279 | } | ||||||||||||||||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||||||||||||||||
| 281 | # cleanup intermediate and possibly existing files | ||||||||||||||||||||||||||||||||||||||||||
| 282 | 0 | foreach my $f (qw(resources buildspec.yml.tmpl test.t.tmpl provides module.pm.tmpl extra-files)) { | |||||||||||||||||||||||||||||||||||||||||
| 283 | 0 | unlink $f; | |||||||||||||||||||||||||||||||||||||||||
| 284 | } | ||||||||||||||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||||||||||||
| 286 | 0 | ▶ | if ( -d "$tmpdir/local" ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 287 | 0 | remove_tree("$tmpdir/local"); | |||||||||||||||||||||||||||||||||||||||||
| 288 | } | ||||||||||||||||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||||||||||||||||
| 290 | 0 | rename "$tmpdir/$errfile", "$tmpdir/make.err"; | |||||||||||||||||||||||||||||||||||||||||
| 291 | 0 | rename "$tmpdir/$logfile", "$tmpdir/make.log"; | |||||||||||||||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||||||||||||||||
| 293 | 0 | ▶ | if ( $self->get_project_tarball ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 294 | eval { | ||||||||||||||||||||||||||||||||||||||||||
| 295 | 0 | $self->_create_project_tarball( $tmpdir, $module_name, $pwd ); | |||||||||||||||||||||||||||||||||||||||||
| 296 | 0 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 297 | 0 | ▶ | } or do { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 298 | 0 | $self->get_logger->error($EVAL_ERROR); | |||||||||||||||||||||||||||||||||||||||||
| 299 | 0 | return $FAILURE; | |||||||||||||||||||||||||||||||||||||||||
| 300 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 301 | } | ||||||||||||||||||||||||||||||||||||||||||
| 302 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 303 | 0 | $self->get_logger->info("installing project to $installdir..."); | |||||||||||||||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||||||||||||||||
| 305 | 0 | require File::Copy::Recursive; | |||||||||||||||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||||||||||||||||
| 307 | File::Copy::Recursive::dircopy( $tmpdir, $installdir ) | ||||||||||||||||||||||||||||||||||||||||||
| 308 | 0 | ▶ | or do { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 309 | 0 | $self->get_logger->error( sprintf "ERROR: could not copy $tmpdir to $installdir: %s\n", $OS_ERROR ); | |||||||||||||||||||||||||||||||||||||||||
| 310 | 0 | return $FAILURE; | |||||||||||||||||||||||||||||||||||||||||
| 311 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||||||||||||||||
| 313 | } | ||||||||||||||||||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||||||||||||||||
| 315 | 0 | ▶ | if ( $self->get_project_tarball ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 316 | 0 | $self->get_logger->info( sprintf 'successfully created CPAN::Maker::Bootstrapper project tarball for %s', $module_name ); | |||||||||||||||||||||||||||||||||||||||||
| 317 | 0 | $self->_report_import_errors(); | |||||||||||||||||||||||||||||||||||||||||
| 318 | 0 | $self->get_logger->info('next steps:'); | |||||||||||||||||||||||||||||||||||||||||
| 319 | 0 | $self->get_logger->info('+-------------------------------------------------------+'); | |||||||||||||||||||||||||||||||||||||||||
| 320 | 0 | $self->get_logger->info('| 1. Extract the project tarball |'); | |||||||||||||||||||||||||||||||||||||||||
| 321 | 0 | $self->get_logger->info('| 2. Review source tree |'); | |||||||||||||||||||||||||||||||||||||||||
| 322 | 0 | $self->get_logger->info('| 3. Review `buildspec.yml` |'); | |||||||||||||||||||||||||||||||||||||||||
| 323 | 0 | $self->get_logger->info('| 4. Edit/Add files to lib, bin, t or root |'); | |||||||||||||||||||||||||||||||||||||||||
| 324 | 0 | $self->get_logger->info('| 5. run `make` |'); | |||||||||||||||||||||||||||||||||||||||||
| 325 | 0 | $self->get_logger->info('+-------------------------------------------------------+'); | |||||||||||||||||||||||||||||||||||||||||
| 326 | } | ||||||||||||||||||||||||||||||||||||||||||
| 327 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 328 | 0 | $self->get_logger->info("successfully imported $module_name"); | |||||||||||||||||||||||||||||||||||||||||
| 329 | 0 | $self->_report_import_errors(); | |||||||||||||||||||||||||||||||||||||||||
| 330 | 0 | $self->get_logger->info('next steps:'); | |||||||||||||||||||||||||||||||||||||||||
| 331 | 0 | $self->get_logger->info('+-------------------------------------------------------+'); | |||||||||||||||||||||||||||||||||||||||||
| 332 | 0 | $self->get_logger->info('| 1. Review source tree |'); | |||||||||||||||||||||||||||||||||||||||||
| 333 | 0 | $self->get_logger->info('| 2. Review `buildspec.yml` |'); | |||||||||||||||||||||||||||||||||||||||||
| 334 | 0 | $self->get_logger->info('| 3. Edit/Add files to lib, bin, t or root |'); | |||||||||||||||||||||||||||||||||||||||||
| 335 | 0 | $self->get_logger->info('| 4. run `make` |'); | |||||||||||||||||||||||||||||||||||||||||
| 336 | 0 | $self->get_logger->info('+-------------------------------------------------------+'); | |||||||||||||||||||||||||||||||||||||||||
| 337 | } | ||||||||||||||||||||||||||||||||||||||||||
| 338 | |||||||||||||||||||||||||||||||||||||||||||
| 339 | 0 | $self->get_logger->info('| Tip: type "make help" to see all make targets |'); | |||||||||||||||||||||||||||||||||||||||||
| 340 | 0 | $self->get_logger->info('| See "perldoc CPAN::Maker::Bootstrapper" to learn more |'); | |||||||||||||||||||||||||||||||||||||||||
| 341 | 0 | $self->get_logger->info('+-------------------------------------------------------+'); | |||||||||||||||||||||||||||||||||||||||||
| 342 | 0 | $self->get_logger->info('| https://github.com/rlauer6/CPAN-Maker-Bootstrapper |'); | |||||||||||||||||||||||||||||||||||||||||
| 343 | 0 | $self->get_logger->info('+-------------------------------------------------------+'); | |||||||||||||||||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||||||||||||||||
| 345 | 0 | return $SUCCESS; | |||||||||||||||||||||||||||||||||||||||||
| 346 | } | ||||||||||||||||||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||||||||||||||||
| 348 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 349 | 0 | ▶ | sub _resolve_install_dir { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_resolve_install_dir: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 350 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 351 | 0 | my ( $self, $module_name ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||||||||||||||||
| 353 | 0 | my $installdir = $self->get_installdir; | |||||||||||||||||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||||||||||||||||
| 355 | 0 | ▶ | if ( !$installdir ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 356 | 0 | $installdir = $module_name; | |||||||||||||||||||||||||||||||||||||||||
| 357 | 0 | $installdir =~ s/::/-/gxsm; | |||||||||||||||||||||||||||||||||||||||||
| 358 | 0 | $installdir = sprintf '%s/%s', $self->get_basedir, $installdir; | |||||||||||||||||||||||||||||||||||||||||
| 359 | } | ||||||||||||||||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||||||||||||||||
| 361 | 0 | return File::Spec->canonpath( File::Spec->rel2abs($installdir) ); | |||||||||||||||||||||||||||||||||||||||||
| 362 | } | ||||||||||||||||||||||||||||||||||||||||||
| 363 | |||||||||||||||||||||||||||||||||||||||||||
| 364 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 365 | 0 | ▶ | sub _create_default_config { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_create_default_config: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 366 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 367 | 0 | my ( $self, $module_name ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||||||||||||||||
| 369 | 0 | my $default_config = <<"END_OF_CONFIG"; | |||||||||||||||||||||||||||||||||||||||||
| 370 | SYNTAX_CHECKING ?= on | ||||||||||||||||||||||||||||||||||||||||||
| 371 | LINT ?= on | ||||||||||||||||||||||||||||||||||||||||||
| 372 | SCAN ?= on | ||||||||||||||||||||||||||||||||||||||||||
| 373 | MODULE_NAME ?= $module_name | ||||||||||||||||||||||||||||||||||||||||||
| 374 | END_OF_CONFIG | ||||||||||||||||||||||||||||||||||||||||||
| 375 | |||||||||||||||||||||||||||||||||||||||||||
| 376 | { | ||||||||||||||||||||||||||||||||||||||||||
| 377 | 0 | open my $fh, '>', 'config.mk' | |||||||||||||||||||||||||||||||||||||||||
| 378 | 0 | ▶ | or do { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 379 | 0 | $self->get_logger->warn( sprintf q{WARN: could not open 'config.mk' for writing: %s}, $OS_ERROR ); | |||||||||||||||||||||||||||||||||||||||||
| 380 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||||||||||||||||
| 382 | 0 | print {$fh} $default_config; | |||||||||||||||||||||||||||||||||||||||||
| 383 | |||||||||||||||||||||||||||||||||||||||||||
| 384 | 0 | close $fh; | |||||||||||||||||||||||||||||||||||||||||
| 385 | } | ||||||||||||||||||||||||||||||||||||||||||
| 386 | |||||||||||||||||||||||||||||||||||||||||||
| 387 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 388 | } | ||||||||||||||||||||||||||||||||||||||||||
| 389 | |||||||||||||||||||||||||||||||||||||||||||
| 390 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 391 | 0 | ▶ | sub _validate_import_paths { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_validate_import_paths: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||
| 392 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 393 | 0 | my ( $self, $import_paths ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||||||||||||||||
| 395 | 0 | my @validated; | |||||||||||||||||||||||||||||||||||||||||
| 396 | 0 | my $valid = $TRUE; | |||||||||||||||||||||||||||||||||||||||||
| 397 | |||||||||||||||||||||||||||||||||||||||||||
| 398 | 0 | foreach my $path ( @{$import_paths} ) { | |||||||||||||||||||||||||||||||||||||||||
| 399 | |||||||||||||||||||||||||||||||||||||||||||
| 400 | 0 | ▶ | if ( !-d $path ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 401 | 0 | $self->get_logger->error( sprintf "ERROR: import path '%s' is not a directory", $path ); | |||||||||||||||||||||||||||||||||||||||||
| 402 | |||||||||||||||||||||||||||||||||||||||||||
| 403 | 0 | $valid = $FALSE; | |||||||||||||||||||||||||||||||||||||||||
| 404 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 405 | } | ||||||||||||||||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||||||||||||||||
| 407 | 0 | my $abs_path = abs_path($path); | |||||||||||||||||||||||||||||||||||||||||
| 408 | |||||||||||||||||||||||||||||||||||||||||||
| 409 | 0 | ▶ | if ( !$abs_path ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 410 | 0 | $self->get_logger->error( sprintf "ERROR: could not resolve import path '%s'", $path ); | |||||||||||||||||||||||||||||||||||||||||
| 411 | |||||||||||||||||||||||||||||||||||||||||||
| 412 | 0 | $valid = $FALSE; | |||||||||||||||||||||||||||||||||||||||||
| 413 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 414 | } | ||||||||||||||||||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||||||||||||||||
| 416 | 0 | push @validated, $abs_path; | |||||||||||||||||||||||||||||||||||||||||
| 417 | } | ||||||||||||||||||||||||||||||||||||||||||
| 418 | |||||||||||||||||||||||||||||||||||||||||||
| 419 | return | ||||||||||||||||||||||||||||||||||||||||||
| 420 | 0 | ▶ | if !$valid; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 421 | |||||||||||||||||||||||||||||||||||||||||||
| 422 | 0 | return \@validated; | |||||||||||||||||||||||||||||||||||||||||
| 423 | } | ||||||||||||||||||||||||||||||||||||||||||
| 424 | |||||||||||||||||||||||||||||||||||||||||||
| 425 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 426 | 0 | ▶ | sub _validate_import_destination { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_validate_import_destination: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||
| 427 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 428 | 0 | my ( $self, $installdir, $import_paths ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 429 | |||||||||||||||||||||||||||||||||||||||||||
| 430 | 0 | foreach my $import_path ( @{$import_paths} ) { | |||||||||||||||||||||||||||||||||||||||||
| 431 | 0 | my $source = abs_path($import_path); | |||||||||||||||||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||||||||||||||||
| 433 | 0 | my $relative = File::Spec->abs2rel( $installdir, $source ); | |||||||||||||||||||||||||||||||||||||||||
| 434 | 0 | $relative =~ s{\\}{/}gxsm; | |||||||||||||||||||||||||||||||||||||||||
| 435 | |||||||||||||||||||||||||||||||||||||||||||
| 436 | 0 | ▶ | if ( $relative eq '.' || $relative !~ m{\A[.][.](?:/|\z)}xsm ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$relative eq "." or not $relative =~ m[\A[.][.](?:/|\z)]msx
MC/DC0%0/2
$relative eq "." or not $relative =~ m[\A[.][.](?:/|\z)]msx
$relative eq "."
not $relative =~ m[\A[.][.](?:/|\z)]msx
Truth table0%0/3
A or not(B)
A= $relative eq "."B= not $relative =~ m[\A[.][.](?:/|\z)]msx
| |||||||||||||||||||||||||||||||||||||||||||
| 437 | 0 | croak sprintf | |||||||||||||||||||||||||||||||||||||||||
| 438 | "ERROR: installation directory '%s' is inside import directory '%s'\n", | ||||||||||||||||||||||||||||||||||||||||||
| 439 | $installdir, | ||||||||||||||||||||||||||||||||||||||||||
| 440 | $source; | ||||||||||||||||||||||||||||||||||||||||||
| 441 | } | ||||||||||||||||||||||||||||||||||||||||||
| 442 | } | ||||||||||||||||||||||||||||||||||||||||||
| 443 | |||||||||||||||||||||||||||||||||||||||||||
| 444 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 445 | } | ||||||||||||||||||||||||||||||||||||||||||
| 446 | |||||||||||||||||||||||||||||||||||||||||||
| 447 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 448 | 0 | ▶ | sub _create_install_dir { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_create_install_dir: not called CC=7 SCAR=40.3
| |||||||||||||||||||||||||||||||||||||||||||
| 449 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 450 | 0 | my ( $self, $module_name ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 451 | |||||||||||||||||||||||||||||||||||||||||||
| 452 | 0 | my $installdir = $self->_resolve_install_dir($module_name); | |||||||||||||||||||||||||||||||||||||||||
| 453 | |||||||||||||||||||||||||||||||||||||||||||
| 454 | 0 | $self->set_installdir($installdir); | |||||||||||||||||||||||||||||||||||||||||
| 455 | |||||||||||||||||||||||||||||||||||||||||||
| 456 | 0 | ▶ | croak "ERROR: could not create $installdir\n$OS_ERROR" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
-d $installdir or make_path($installdir)
MC/DC0%0/2
-d $installdir or make_path($installdir)
-d $installdir
make_path($installdir)
Truth table0%0/3
A or B
A= -d $installdirB= make_path($installdir)
| |||||||||||||||||||||||||||||||||||||||||||
| 457 | if !-d $installdir && !make_path($installdir); | ||||||||||||||||||||||||||||||||||||||||||
| 458 | |||||||||||||||||||||||||||||||||||||||||||
| 459 | 0 | $self->get_logger->info( sprintf 'attempting to install module %s into %s', $module_name, $installdir ); | |||||||||||||||||||||||||||||||||||||||||
| 460 | |||||||||||||||||||||||||||||||||||||||||||
| 461 | 0 | ▶ | return $installdir | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
-d $installdir and not -e "$installdir/Makefile"
MC/DC0%0/2
-d $installdir and not -e "$installdir/Makefile"
-d $installdir
not -e "$installdir/Makefile"
Truth table0%0/3
A and not(B)
A= -d $installdirB= not -e "$installdir/Makefile"
| |||||||||||||||||||||||||||||||||||||||||||
| 462 | if -d $installdir && !-e "$installdir/Makefile"; | ||||||||||||||||||||||||||||||||||||||||||
| 463 | |||||||||||||||||||||||||||||||||||||||||||
| 464 | 0 | ▶ | croak sprintf 'ERROR: could not create %s', $installdir | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 465 | if !-d $installdir; | ||||||||||||||||||||||||||||||||||||||||||
| 466 | |||||||||||||||||||||||||||||||||||||||||||
| 467 | 0 | ▶ | croak sprintf q{ERROR: Found '%s/Makefile' - project may already exist! Use --force to overwrite}, $installdir | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 468 | if !$self->get_force; | ||||||||||||||||||||||||||||||||||||||||||
| 469 | |||||||||||||||||||||||||||||||||||||||||||
| 470 | 0 | $self->_remove_existing_files($installdir); | |||||||||||||||||||||||||||||||||||||||||
| 471 | |||||||||||||||||||||||||||||||||||||||||||
| 472 | 0 | return $installdir; | |||||||||||||||||||||||||||||||||||||||||
| 473 | } | ||||||||||||||||||||||||||||||||||||||||||
| 474 | |||||||||||||||||||||||||||||||||||||||||||
| 475 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 476 | 0 | ▶ | sub _remove_existing_files { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_remove_existing_files: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 477 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 478 | 0 | my ( $self, $installdir ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 479 | |||||||||||||||||||||||||||||||||||||||||||
| 480 | # remove existing files | ||||||||||||||||||||||||||||||||||||||||||
| 481 | 0 | unlink "$installdir/Makefile"; | |||||||||||||||||||||||||||||||||||||||||
| 482 | 0 | unlink "$installdir/buildspec.yml"; | |||||||||||||||||||||||||||||||||||||||||
| 483 | |||||||||||||||||||||||||||||||||||||||||||
| 484 | 0 | foreach ( glob "$installdir/.includes/*" ) { | |||||||||||||||||||||||||||||||||||||||||
| 485 | 0 | unlink $_; | |||||||||||||||||||||||||||||||||||||||||
| 486 | } | ||||||||||||||||||||||||||||||||||||||||||
| 487 | |||||||||||||||||||||||||||||||||||||||||||
| 488 | 0 | $self->get_logger->warn('existing files will be overwritten...you have been warned'); | |||||||||||||||||||||||||||||||||||||||||
| 489 | |||||||||||||||||||||||||||||||||||||||||||
| 490 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 491 | } | ||||||||||||||||||||||||||||||||||||||||||
| 492 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 493 | 0 | ▶ | sub check_return_code { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
check_return_code: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 494 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 495 | 0 | my ( $self, $rc ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 496 | |||||||||||||||||||||||||||||||||||||||||||
| 497 | 0 | ▶ | croak "ERROR: could not execute make: $OS_ERROR\n" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 498 | if $rc == -1; | ||||||||||||||||||||||||||||||||||||||||||
| 499 | |||||||||||||||||||||||||||||||||||||||||||
| 500 | 0 | ▶ | croak sprintf "ERROR: make killed by signal %d\n", $rc & 127 | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 501 | if $rc & 127; | ||||||||||||||||||||||||||||||||||||||||||
| 502 | |||||||||||||||||||||||||||||||||||||||||||
| 503 | 0 | ▶ | croak sprintf "ERROR: make failed with exit code %d\n", $rc >> 8 | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 504 | if $rc >> 8; | ||||||||||||||||||||||||||||||||||||||||||
| 505 | |||||||||||||||||||||||||||||||||||||||||||
| 506 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 507 | } | ||||||||||||||||||||||||||||||||||||||||||
| 508 | |||||||||||||||||||||||||||||||||||||||||||
| 509 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 510 | 0 | ▶ | sub _validate_module { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_validate_module: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||
| 511 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 512 | 0 | my ( $self, $module_name ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 513 | |||||||||||||||||||||||||||||||||||||||||||
| 514 | 0 | my $module_path = $module_name; | |||||||||||||||||||||||||||||||||||||||||
| 515 | 0 | $module_path =~ s/::/\//xsmg; | |||||||||||||||||||||||||||||||||||||||||
| 516 | 0 | $module_path = "$module_path.pm"; | |||||||||||||||||||||||||||||||||||||||||
| 517 | |||||||||||||||||||||||||||||||||||||||||||
| 518 | 0 | ▶ | my $import_paths = $self->get_import // []; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->get_import // []
MC/DC0%0/1
$self->get_import // []
$self->get_import
Truth table0%0/2
A
A= $self->get_import
| |||||||||||||||||||||||||||||||||||||||||||
| 519 | |||||||||||||||||||||||||||||||||||||||||||
| 520 | 0 | ▶ | $import_paths = ref $import_paths ? $import_paths : [$import_paths]; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 521 | |||||||||||||||||||||||||||||||||||||||||||
| 522 | # return $module_name if no import paths (stub?) | ||||||||||||||||||||||||||||||||||||||||||
| 523 | return "lib/$module_name" | ||||||||||||||||||||||||||||||||||||||||||
| 524 | 0 | ▶ | if !@{$import_paths}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 525 | |||||||||||||||||||||||||||||||||||||||||||
| 526 | 0 | my $found; | |||||||||||||||||||||||||||||||||||||||||
| 527 | |||||||||||||||||||||||||||||||||||||||||||
| 528 | 0 | foreach my $import_path ( @{$import_paths} ) { | |||||||||||||||||||||||||||||||||||||||||
| 529 | 0 | my $abs_path = abs_path($import_path); | |||||||||||||||||||||||||||||||||||||||||
| 530 | |||||||||||||||||||||||||||||||||||||||||||
| 531 | find( | ||||||||||||||||||||||||||||||||||||||||||
| 532 | { no_chdir => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 533 | |||||||||||||||||||||||||||||||||||||||||||
| 534 | 0 | ▶ | wanted => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||
| 535 | 0 | my $name = $File::Find::name; | |||||||||||||||||||||||||||||||||||||||||
| 536 | |||||||||||||||||||||||||||||||||||||||||||
| 537 | 0 | ▶ | if ( -d $name ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 538 | 0 | ▶ | if ( $self->_exclude_import_dir( $name, $abs_path ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 539 | 0 | $File::Find::prune = $TRUE; | |||||||||||||||||||||||||||||||||||||||||
| 540 | } | ||||||||||||||||||||||||||||||||||||||||||
| 541 | |||||||||||||||||||||||||||||||||||||||||||
| 542 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 543 | } | ||||||||||||||||||||||||||||||||||||||||||
| 544 | |||||||||||||||||||||||||||||||||||||||||||
| 545 | return | ||||||||||||||||||||||||||||||||||||||||||
| 546 | 0 | ▶ | if $name !~ m{(?:\A|/)\Q$module_path\E\z}xsm; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 547 | |||||||||||||||||||||||||||||||||||||||||||
| 548 | 0 | $found = [$name]; | |||||||||||||||||||||||||||||||||||||||||
| 549 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 550 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 551 | 0 | $abs_path, | |||||||||||||||||||||||||||||||||||||||||
| 552 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 553 | } | ||||||||||||||||||||||||||||||||||||||||||
| 554 | |||||||||||||||||||||||||||||||||||||||||||
| 555 | 0 | return $found; | |||||||||||||||||||||||||||||||||||||||||
| 556 | } | ||||||||||||||||||||||||||||||||||||||||||
| 557 | |||||||||||||||||||||||||||||||||||||||||||
| 558 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 559 | 0 | ▶ | sub _create_dirs { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_create_dirs: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 560 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 561 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 562 | |||||||||||||||||||||||||||||||||||||||||||
| 563 | 0 | my $installdir = $self->get_installdir; | |||||||||||||||||||||||||||||||||||||||||
| 564 | |||||||||||||||||||||||||||||||||||||||||||
| 565 | 0 | my @dirs = ( $installdir, map {"$installdir/$_"} qw(t lib bin .includes) ); | |||||||||||||||||||||||||||||||||||||||||
| 566 | |||||||||||||||||||||||||||||||||||||||||||
| 567 | 0 | make_path(@dirs); | |||||||||||||||||||||||||||||||||||||||||
| 568 | |||||||||||||||||||||||||||||||||||||||||||
| 569 | 0 | foreach (@dirs) { | |||||||||||||||||||||||||||||||||||||||||
| 570 | 0 | ▶ | croak "ERROR: could not create $_\n" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 571 | if !-d $_; | ||||||||||||||||||||||||||||||||||||||||||
| 572 | } | ||||||||||||||||||||||||||||||||||||||||||
| 573 | |||||||||||||||||||||||||||||||||||||||||||
| 574 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 575 | } | ||||||||||||||||||||||||||||||||||||||||||
| 576 | |||||||||||||||||||||||||||||||||||||||||||
| 577 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 578 | 0 | ▶ | sub _install_files { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_install_files: not called CC=9 SCAR=45.0
| |||||||||||||||||||||||||||||||||||||||||||
| 579 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 580 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 581 | |||||||||||||||||||||||||||||||||||||||||||
| 582 | 0 | my $installdir = $self->get_installdir; | |||||||||||||||||||||||||||||||||||||||||
| 583 | |||||||||||||||||||||||||||||||||||||||||||
| 584 | 0 | my $dist_dir = $self->get_dist_dir; | |||||||||||||||||||||||||||||||||||||||||
| 585 | |||||||||||||||||||||||||||||||||||||||||||
| 586 | 0 | my @manifest = split /\n/xsm, slurp("$dist_dir/MANIFEST"); | |||||||||||||||||||||||||||||||||||||||||
| 587 | |||||||||||||||||||||||||||||||||||||||||||
| 588 | 0 | foreach (@manifest) { | |||||||||||||||||||||||||||||||||||||||||
| 589 | 0 | ▶ | croak "ERROR: MANIFEST contains corrupted entry ($_)\n" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 590 | if $_ !~ m{\A[[:alnum:]][[:alnum:]._-]*(?:/[[:alnum:]][[:alnum:]._-]*)*\z}xsm; | ||||||||||||||||||||||||||||||||||||||||||
| 591 | |||||||||||||||||||||||||||||||||||||||||||
| 592 | 0 | ▶ | croak "ERROR: $_ is not found in the distribution. MANIFEST may be corrupted.\n" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 593 | if !-e "$dist_dir/$_"; | ||||||||||||||||||||||||||||||||||||||||||
| 594 | |||||||||||||||||||||||||||||||||||||||||||
| 595 | 0 | ▶ | if (/[.]mk$/xsm) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 596 | 0 | ▶ | croak "ERROR: could not copy $dist_dir/$_ to $installdir/.includes/$_\n" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 597 | if !copy( "$dist_dir/$_", "$installdir/.includes/$_" ); | ||||||||||||||||||||||||||||||||||||||||||
| 598 | 0 | chmod 0444, "$installdir/.includes/$_"; | |||||||||||||||||||||||||||||||||||||||||
| 599 | } | ||||||||||||||||||||||||||||||||||||||||||
| 600 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 601 | 0 | ▶ | croak "ERROR: could not copy $dist_dir/$_ to $installdir/$_\n" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 602 | if !copy( "$dist_dir/$_", "$installdir/$_" ); | ||||||||||||||||||||||||||||||||||||||||||
| 603 | } | ||||||||||||||||||||||||||||||||||||||||||
| 604 | } | ||||||||||||||||||||||||||||||||||||||||||
| 605 | |||||||||||||||||||||||||||||||||||||||||||
| 606 | # no need to check file existence, copy will fail above or rename will fail and be caught | ||||||||||||||||||||||||||||||||||||||||||
| 607 | 0 | ▶ | rename "$installdir/Makefile.txt", "$installdir/Makefile" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 608 | or croak "ERROR: error renaming $installdir/Makefile.txt to $installdir/Makefile: $OS_ERROR\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 609 | |||||||||||||||||||||||||||||||||||||||||||
| 610 | 0 | chmod 0444, "$installdir/Makefile"; | |||||||||||||||||||||||||||||||||||||||||
| 611 | 0 | chmod 0555, "$installdir/builder"; | |||||||||||||||||||||||||||||||||||||||||
| 612 | |||||||||||||||||||||||||||||||||||||||||||
| 613 | 0 | ▶ | rename "$installdir/gitignore", "$installdir/.gitignore" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 614 | or croak "ERROR: error renaming $installdir/gitignore to $installdir/.gitignore: $OS_ERROR\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 615 | |||||||||||||||||||||||||||||||||||||||||||
| 616 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 617 | } | ||||||||||||||||||||||||||||||||||||||||||
| 618 | |||||||||||||||||||||||||||||||||||||||||||
| 619 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 620 | 0 | ▶ | sub _import_files { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_import_files: not called CC=7 SCAR=40.3
| |||||||||||||||||||||||||||||||||||||||||||
| 621 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 622 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 623 | |||||||||||||||||||||||||||||||||||||||||||
| 624 | 0 | my $installdir = $self->get_installdir; | |||||||||||||||||||||||||||||||||||||||||
| 625 | |||||||||||||||||||||||||||||||||||||||||||
| 626 | 0 | my $import_listing = $self->get_import_file_listing; | |||||||||||||||||||||||||||||||||||||||||
| 627 | |||||||||||||||||||||||||||||||||||||||||||
| 628 | return | ||||||||||||||||||||||||||||||||||||||||||
| 629 | 0 | ▶ | if !$import_listing; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 630 | |||||||||||||||||||||||||||||||||||||||||||
| 631 | 0 | $self->get_logger->info('Importing files...'); | |||||||||||||||||||||||||||||||||||||||||
| 632 | |||||||||||||||||||||||||||||||||||||||||||
| 633 | 0 | my $files = $import_listing->{files}; | |||||||||||||||||||||||||||||||||||||||||
| 634 | |||||||||||||||||||||||||||||||||||||||||||
| 635 | 0 | my @scripts = grep { $_->{class} eq 'script' } @{$files}; | |||||||||||||||||||||||||||||||||||||||||
| 636 | |||||||||||||||||||||||||||||||||||||||||||
| 637 | 0 | ▶ | if (@scripts) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 638 | 0 | my $gitignore = slurp("$installdir/.gitignore"); | |||||||||||||||||||||||||||||||||||||||||
| 639 | |||||||||||||||||||||||||||||||||||||||||||
| 640 | 0 | ▶ | if ( $gitignore !~ /\n\z/xsm ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 641 | 0 | $gitignore .= "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 642 | } | ||||||||||||||||||||||||||||||||||||||||||
| 643 | |||||||||||||||||||||||||||||||||||||||||||
| 644 | $gitignore .= join "\n", map { | ||||||||||||||||||||||||||||||||||||||||||
| 645 | 0 | ( my $generated = $_->{destination} ) =~ s/[.]in\z//xsm; | |||||||||||||||||||||||||||||||||||||||||
| 646 | 0 | $generated; | |||||||||||||||||||||||||||||||||||||||||
| 647 | } @scripts; | ||||||||||||||||||||||||||||||||||||||||||
| 648 | |||||||||||||||||||||||||||||||||||||||||||
| 649 | 0 | $gitignore .= "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 650 | |||||||||||||||||||||||||||||||||||||||||||
| 651 | 0 | ▶ | open my $fh, '>', "$installdir/.gitignore" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 652 | or croak "ERROR: could not replace .gitignore: $OS_ERROR\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 653 | |||||||||||||||||||||||||||||||||||||||||||
| 654 | 0 | print {$fh} $gitignore; | |||||||||||||||||||||||||||||||||||||||||
| 655 | |||||||||||||||||||||||||||||||||||||||||||
| 656 | 0 | close $fh; | |||||||||||||||||||||||||||||||||||||||||
| 657 | } | ||||||||||||||||||||||||||||||||||||||||||
| 658 | |||||||||||||||||||||||||||||||||||||||||||
| 659 | 0 | foreach my $file ( @{$files} ) { | |||||||||||||||||||||||||||||||||||||||||
| 660 | 0 | my $source = $file->{source}; | |||||||||||||||||||||||||||||||||||||||||
| 661 | 0 | my $dest = sprintf '%s/%s', $installdir, $file->{destination}; | |||||||||||||||||||||||||||||||||||||||||
| 662 | |||||||||||||||||||||||||||||||||||||||||||
| 663 | 0 | make_path( dirname($dest) ); | |||||||||||||||||||||||||||||||||||||||||
| 664 | |||||||||||||||||||||||||||||||||||||||||||
| 665 | 0 | $self->get_logger->debug( sprintf 'copying %s => %s', $source, $dest ); | |||||||||||||||||||||||||||||||||||||||||
| 666 | |||||||||||||||||||||||||||||||||||||||||||
| 667 | 0 | ▶ | croak sprintf "ERROR: error copying %s to %s\n", $source, $dest | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 668 | if !copy( $source, $dest ); | ||||||||||||||||||||||||||||||||||||||||||
| 669 | |||||||||||||||||||||||||||||||||||||||||||
| 670 | 0 | chmod 0644, $dest; | |||||||||||||||||||||||||||||||||||||||||
| 671 | } | ||||||||||||||||||||||||||||||||||||||||||
| 672 | |||||||||||||||||||||||||||||||||||||||||||
| 673 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 674 | } | ||||||||||||||||||||||||||||||||||||||||||
| 675 | |||||||||||||||||||||||||||||||||||||||||||
| 676 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 677 | 0 | ▶ | sub _report_import_plan { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_report_import_plan: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||
| 678 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 679 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 680 | |||||||||||||||||||||||||||||||||||||||||||
| 681 | 0 | my $import_listing = $self->get_import_file_listing; | |||||||||||||||||||||||||||||||||||||||||
| 682 | |||||||||||||||||||||||||||||||||||||||||||
| 683 | return | ||||||||||||||||||||||||||||||||||||||||||
| 684 | 0 | ▶ | if !$import_listing; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 685 | |||||||||||||||||||||||||||||||||||||||||||
| 686 | 0 | my $files = $import_listing->{files}; | |||||||||||||||||||||||||||||||||||||||||
| 687 | |||||||||||||||||||||||||||||||||||||||||||
| 688 | 0 | $self->get_logger->info('Import plan:'); | |||||||||||||||||||||||||||||||||||||||||
| 689 | |||||||||||||||||||||||||||||||||||||||||||
| 690 | 0 | foreach my $file ( @{$files} ) { | |||||||||||||||||||||||||||||||||||||||||
| 691 | 0 | my $message = sprintf '%-12s %s -> %s', $file->{class}, $file->{source}, $file->{destination}; | |||||||||||||||||||||||||||||||||||||||||
| 692 | |||||||||||||||||||||||||||||||||||||||||||
| 693 | 0 | ▶ | if ( $file->{reason} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 694 | 0 | $message .= sprintf ' (%s)', $file->{reason}; | |||||||||||||||||||||||||||||||||||||||||
| 695 | } | ||||||||||||||||||||||||||||||||||||||||||
| 696 | |||||||||||||||||||||||||||||||||||||||||||
| 697 | 0 | $self->get_logger->info($message); | |||||||||||||||||||||||||||||||||||||||||
| 698 | } | ||||||||||||||||||||||||||||||||||||||||||
| 699 | |||||||||||||||||||||||||||||||||||||||||||
| 700 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 701 | } | ||||||||||||||||||||||||||||||||||||||||||
| 702 | |||||||||||||||||||||||||||||||||||||||||||
| 703 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 704 | 0 | ▶ | sub _report_import_errors { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_report_import_errors: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||||||||||||||||
| 705 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 706 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 707 | |||||||||||||||||||||||||||||||||||||||||||
| 708 | 0 | my $import_listing = $self->get_import_file_listing; | |||||||||||||||||||||||||||||||||||||||||
| 709 | |||||||||||||||||||||||||||||||||||||||||||
| 710 | return | ||||||||||||||||||||||||||||||||||||||||||
| 711 | 0 | ▶ | if !$import_listing; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 712 | |||||||||||||||||||||||||||||||||||||||||||
| 713 | 0 | my @errors = grep { $_->{class} eq 'import-error' } @{ $import_listing->{files} }; | |||||||||||||||||||||||||||||||||||||||||
| 714 | |||||||||||||||||||||||||||||||||||||||||||
| 715 | return | ||||||||||||||||||||||||||||||||||||||||||
| 716 | 0 | ▶ | if !@errors; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 717 | |||||||||||||||||||||||||||||||||||||||||||
| 718 | 0 | ▶ | $self->get_logger->warn( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 719 | sprintf '%d imported file%s require%s manual review.', | ||||||||||||||||||||||||||||||||||||||||||
| 720 | scalar @errors, | ||||||||||||||||||||||||||||||||||||||||||
| 721 | @errors == 1 ? q{} : 's', | ||||||||||||||||||||||||||||||||||||||||||
| 722 | @errors == 1 ? 's' : q{}, | ||||||||||||||||||||||||||||||||||||||||||
| 723 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 724 | |||||||||||||||||||||||||||||||||||||||||||
| 725 | 0 | $self->get_logger->warn('Preserved under import-errors/:'); | |||||||||||||||||||||||||||||||||||||||||
| 726 | |||||||||||||||||||||||||||||||||||||||||||
| 727 | 0 | foreach my $file (@errors) { | |||||||||||||||||||||||||||||||||||||||||
| 728 | 0 | $self->get_logger->warn( sprintf ' %s (%s)', $file->{destination}, $file->{reason}, ); | |||||||||||||||||||||||||||||||||||||||||
| 729 | } | ||||||||||||||||||||||||||||||||||||||||||
| 730 | |||||||||||||||||||||||||||||||||||||||||||
| 731 | 0 | $self->get_logger->warn('Review these files and place them manually.'); | |||||||||||||||||||||||||||||||||||||||||
| 732 | |||||||||||||||||||||||||||||||||||||||||||
| 733 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 734 | } | ||||||||||||||||||||||||||||||||||||||||||
| 735 | |||||||||||||||||||||||||||||||||||||||||||
| 736 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 737 | 0 | ▶ | sub _exclude_import_dir { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_exclude_import_dir: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||||||||||||||||
| 738 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 739 | 0 | my ( $self, $name, $root ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 740 | |||||||||||||||||||||||||||||||||||||||||||
| 741 | 0 | my $relative = File::Spec->abs2rel( $name, $root ); | |||||||||||||||||||||||||||||||||||||||||
| 742 | 0 | $relative =~ s{\\}{/}gxsm; | |||||||||||||||||||||||||||||||||||||||||
| 743 | |||||||||||||||||||||||||||||||||||||||||||
| 744 | 0 | my %hard_excludes = map { $_ => 1 } qw( | |||||||||||||||||||||||||||||||||||||||||
| 745 | .git | ||||||||||||||||||||||||||||||||||||||||||
| 746 | .hg | ||||||||||||||||||||||||||||||||||||||||||
| 747 | .svn | ||||||||||||||||||||||||||||||||||||||||||
| 748 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 749 | |||||||||||||||||||||||||||||||||||||||||||
| 750 | return $TRUE | ||||||||||||||||||||||||||||||||||||||||||
| 751 | 0 | ▶ | if $hard_excludes{ basename($name) }; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 752 | |||||||||||||||||||||||||||||||||||||||||||
| 753 | 0 | ▶ | foreach my $exclude ( @{ $self->get_exclude // [] } ) { | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->get_exclude // []
MC/DC0%0/1
$self->get_exclude // []
$self->get_exclude
Truth table0%0/2
A
A= $self->get_exclude
| |||||||||||||||||||||||||||||||||||||||||||
| 754 | 0 | ▶ | return $TRUE | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 755 | if $relative eq $exclude; | ||||||||||||||||||||||||||||||||||||||||||
| 756 | |||||||||||||||||||||||||||||||||||||||||||
| 757 | 0 | ▶ | return $TRUE | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 758 | if $relative =~ m{\A\Q$exclude\E/}xsm; | ||||||||||||||||||||||||||||||||||||||||||
| 759 | } | ||||||||||||||||||||||||||||||||||||||||||
| 760 | |||||||||||||||||||||||||||||||||||||||||||
| 761 | 0 | return $FALSE; | |||||||||||||||||||||||||||||||||||||||||
| 762 | } | ||||||||||||||||||||||||||||||||||||||||||
| 763 | |||||||||||||||||||||||||||||||||||||||||||
| 764 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 765 | 0 | ▶ | sub _create_resources_file { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_create_resources_file: not called CC=8 SCAR=42.8
| |||||||||||||||||||||||||||||||||||||||||||
| 766 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 767 | 0 | my ( $self, $module_name, $installdir ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 768 | |||||||||||||||||||||||||||||||||||||||||||
| 769 | 0 | my $project_name = $module_name; | |||||||||||||||||||||||||||||||||||||||||
| 770 | 0 | $project_name =~ s/::/-/xsmg; | |||||||||||||||||||||||||||||||||||||||||
| 771 | |||||||||||||||||||||||||||||||||||||||||||
| 772 | 0 | my $github_user = $self->get_github_user; | |||||||||||||||||||||||||||||||||||||||||
| 773 | 0 | ▶ | warn "WARNING: no github_user found in config or passed. Using default (anonymouse). Edit resources.yml to fix.\n" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 774 | if !defined $github_user; | ||||||||||||||||||||||||||||||||||||||||||
| 775 | |||||||||||||||||||||||||||||||||||||||||||
| 776 | 0 | ▶ | $github_user //= 'anonymouse'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$github_user //= "anonymouse"
MC/DC0%0/1
$github_user //= "anonymouse"
$github_user
Truth table0%0/2
A
A= $github_user
| |||||||||||||||||||||||||||||||||||||||||||
| 777 | |||||||||||||||||||||||||||||||||||||||||||
| 778 | 0 | require Email::Valid; | |||||||||||||||||||||||||||||||||||||||||
| 779 | 0 | require YAML::Tiny; | |||||||||||||||||||||||||||||||||||||||||
| 780 | |||||||||||||||||||||||||||||||||||||||||||
| 781 | 0 | my $email = $self->get_email; | |||||||||||||||||||||||||||||||||||||||||
| 782 | 0 | ▶ | croak "ERROR: invalid email address\n" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$email and not "Email::Valid"->address($email)
MC/DC0%0/2
$email and not "Email::Valid"->address($email)
$email
not "Email::Valid"->address($email)
Truth table0%0/3
A and not(B)
A= $emailB= not "Email::Valid"->address($email)
| |||||||||||||||||||||||||||||||||||||||||||
| 783 | if $email && !Email::Valid->address($email); | ||||||||||||||||||||||||||||||||||||||||||
| 784 | |||||||||||||||||||||||||||||||||||||||||||
| 785 | 0 | ▶ | my $resources = { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 786 | bugtracker => { | ||||||||||||||||||||||||||||||||||||||||||
| 787 | web => sprintf( 'https://github.com/%s/%s/issues', $github_user, $project_name ), | ||||||||||||||||||||||||||||||||||||||||||
| 788 | $self->get_email ? ( mailto => $self->get_email ) : (), | ||||||||||||||||||||||||||||||||||||||||||
| 789 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 790 | repository => { | ||||||||||||||||||||||||||||||||||||||||||
| 791 | type => 'git', | ||||||||||||||||||||||||||||||||||||||||||
| 792 | url => sprintf( 'git@github.com:%s/%s.git', $github_user, $project_name ), | ||||||||||||||||||||||||||||||||||||||||||
| 793 | web => sprintf( 'https://github.com/%s/%s', $github_user, $project_name ), | ||||||||||||||||||||||||||||||||||||||||||
| 794 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 795 | homepage => sprintf( 'https://github.com/%s/%s', $github_user, $project_name ), | ||||||||||||||||||||||||||||||||||||||||||
| 796 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 797 | |||||||||||||||||||||||||||||||||||||||||||
| 798 | 0 | ▶ | open my $fh, '>', "$installdir/resources.yml" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 799 | or croak "ERROR: could not open resources.yml for writing: $OS_ERROR\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 800 | |||||||||||||||||||||||||||||||||||||||||||
| 801 | 0 | my $yml = YAML::Tiny::Dump( { resources => $resources } ); | |||||||||||||||||||||||||||||||||||||||||
| 802 | 0 | $yml =~ s/^---\n//xsm; | |||||||||||||||||||||||||||||||||||||||||
| 803 | |||||||||||||||||||||||||||||||||||||||||||
| 804 | 0 | print {$fh} $yml; | |||||||||||||||||||||||||||||||||||||||||
| 805 | |||||||||||||||||||||||||||||||||||||||||||
| 806 | 0 | ▶ | close $fh | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 807 | or warn "WARNING: could not close resources.yml: $OS_ERROR\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 808 | |||||||||||||||||||||||||||||||||||||||||||
| 809 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 810 | } | ||||||||||||||||||||||||||||||||||||||||||
| 811 | |||||||||||||||||||||||||||||||||||||||||||
| 812 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 813 | 0 | ▶ | sub _import_file_listing { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_import_file_listing: not called CC=16 SCAR=56.1
| |||||||||||||||||||||||||||||||||||||||||||
| 814 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 815 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 816 | |||||||||||||||||||||||||||||||||||||||||||
| 817 | 0 | ▶ | my @import_paths = ref $self->get_import ? @{ $self->get_import } : ( $self->get_import ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 818 | 0 | $self->get_logger->debug( 'import paths: ' . join "\n", @import_paths ); | |||||||||||||||||||||||||||||||||||||||||
| 819 | |||||||||||||||||||||||||||||||||||||||||||
| 820 | 0 | my @modules; | |||||||||||||||||||||||||||||||||||||||||
| 821 | my %seen_sources; | ||||||||||||||||||||||||||||||||||||||||||
| 822 | 0 | my @scripts; | |||||||||||||||||||||||||||||||||||||||||
| 823 | |||||||||||||||||||||||||||||||||||||||||||
| 824 | 0 | my %tests = ( | |||||||||||||||||||||||||||||||||||||||||
| 825 | author => [], | ||||||||||||||||||||||||||||||||||||||||||
| 826 | release => [], | ||||||||||||||||||||||||||||||||||||||||||
| 827 | smoke => [], | ||||||||||||||||||||||||||||||||||||||||||
| 828 | t => [], | ||||||||||||||||||||||||||||||||||||||||||
| 829 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 830 | |||||||||||||||||||||||||||||||||||||||||||
| 831 | 0 | my %file_packages; | |||||||||||||||||||||||||||||||||||||||||
| 832 | |||||||||||||||||||||||||||||||||||||||||||
| 833 | my @files; | ||||||||||||||||||||||||||||||||||||||||||
| 834 | |||||||||||||||||||||||||||||||||||||||||||
| 835 | 0 | require File::Find; | |||||||||||||||||||||||||||||||||||||||||
| 836 | |||||||||||||||||||||||||||||||||||||||||||
| 837 | 0 | for my $path (@import_paths) { | |||||||||||||||||||||||||||||||||||||||||
| 838 | 0 | my $abs_path = abs_path($path); | |||||||||||||||||||||||||||||||||||||||||
| 839 | |||||||||||||||||||||||||||||||||||||||||||
| 840 | 0 | ▶ | croak "ERROR: import path '$path' is not a directory\n" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 841 | if !-d $abs_path; | ||||||||||||||||||||||||||||||||||||||||||
| 842 | |||||||||||||||||||||||||||||||||||||||||||
| 843 | File::Find::find( | ||||||||||||||||||||||||||||||||||||||||||
| 844 | 0 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=11 SCAR=48.8
| |||||||||||||||||||||||||||||||||||||||||||
| 845 | 0 | my $name = $File::Find::name; | |||||||||||||||||||||||||||||||||||||||||
| 846 | |||||||||||||||||||||||||||||||||||||||||||
| 847 | 0 | ▶ | if ( -d $name ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 848 | 0 | ▶ | if ( $self->_exclude_import_dir( $name, $abs_path ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 849 | 0 | $self->get_logger->debug( sprintf 'excluding directory %s', $name ); | |||||||||||||||||||||||||||||||||||||||||
| 850 | 0 | $File::Find::prune = $TRUE; | |||||||||||||||||||||||||||||||||||||||||
| 851 | } | ||||||||||||||||||||||||||||||||||||||||||
| 852 | |||||||||||||||||||||||||||||||||||||||||||
| 853 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 854 | } | ||||||||||||||||||||||||||||||||||||||||||
| 855 | |||||||||||||||||||||||||||||||||||||||||||
| 856 | return | ||||||||||||||||||||||||||||||||||||||||||
| 857 | 0 | ▶ | if $seen_sources{$name}++; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 858 | |||||||||||||||||||||||||||||||||||||||||||
| 859 | 0 | my $relative = File::Spec->abs2rel( $name, $abs_path ); | |||||||||||||||||||||||||||||||||||||||||
| 860 | 0 | $relative =~ s{\\}{/}gxsm; | |||||||||||||||||||||||||||||||||||||||||
| 861 | |||||||||||||||||||||||||||||||||||||||||||
| 862 | 0 | my $is_executable = -x $name; | |||||||||||||||||||||||||||||||||||||||||
| 863 | |||||||||||||||||||||||||||||||||||||||||||
| 864 | 0 | $self->get_logger->debug( | |||||||||||||||||||||||||||||||||||||||||
| 865 | Dumper( | ||||||||||||||||||||||||||||||||||||||||||
| 866 | [ name => $name, | ||||||||||||||||||||||||||||||||||||||||||
| 867 | is_executable => $is_executable, | ||||||||||||||||||||||||||||||||||||||||||
| 868 | ] | ||||||||||||||||||||||||||||||||||||||||||
| 869 | ) | ||||||||||||||||||||||||||||||||||||||||||
| 870 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 871 | |||||||||||||||||||||||||||||||||||||||||||
| 872 | 0 | ▶ | if ( any { $relative eq $_ } qw(ChangeLog CHANGELOG Changes CHANGES) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 873 | |||||||||||||||||||||||||||||||||||||||||||
| 874 | 0 | push @files, | |||||||||||||||||||||||||||||||||||||||||
| 875 | { | ||||||||||||||||||||||||||||||||||||||||||
| 876 | class => 'project', | ||||||||||||||||||||||||||||||||||||||||||
| 877 | source => $name, | ||||||||||||||||||||||||||||||||||||||||||
| 878 | destination => $relative, | ||||||||||||||||||||||||||||||||||||||||||
| 879 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 880 | |||||||||||||||||||||||||||||||||||||||||||
| 881 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 882 | } | ||||||||||||||||||||||||||||||||||||||||||
| 883 | |||||||||||||||||||||||||||||||||||||||||||
| 884 | 0 | my ($ext) = $name =~ /[.]([^.]+)\z/xsm; | |||||||||||||||||||||||||||||||||||||||||
| 885 | |||||||||||||||||||||||||||||||||||||||||||
| 886 | return | ||||||||||||||||||||||||||||||||||||||||||
| 887 | 0 | ▶ | if !defined $ext || none { $ext eq $_ } qw(pm pl sh t dat); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
Branch: 1 branch
Condition0%0/3
not defined $ext or &none(sub {
MC/DC0%0/2
not defined $ext or &none(sub {
$ext eq $_;
}
, "pm", "pl", "sh", "t", "dat")
not defined $ext
&none(sub {
$ext eq $_;
}
, "pm", "pl", "sh", "t", "dat")
Truth table0%0/3
not(A) or B
A= not defined $extB= &none(sub {
$ext eq $_;
}
, "pm", "pl", "sh", "t", "dat")
| |||||||||||||||||||||||||||||||||||||||||||
| 888 | |||||||||||||||||||||||||||||||||||||||||||
| 889 | return | ||||||||||||||||||||||||||||||||||||||||||
| 890 | 0 | ▶ | if $self->_classify_test_file( $name, $relative, $path, \%tests ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 891 | |||||||||||||||||||||||||||||||||||||||||||
| 892 | 0 | $self->get_logger->info( 'importing ' . $name ); | |||||||||||||||||||||||||||||||||||||||||
| 893 | |||||||||||||||||||||||||||||||||||||||||||
| 894 | 0 | ▶ | if ( $name =~ /[.]pm\z/xsm ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 895 | 0 | push @modules, | |||||||||||||||||||||||||||||||||||||||||
| 896 | { | ||||||||||||||||||||||||||||||||||||||||||
| 897 | source => $name, | ||||||||||||||||||||||||||||||||||||||||||
| 898 | relative => $relative, | ||||||||||||||||||||||||||||||||||||||||||
| 899 | import_root => $path, | ||||||||||||||||||||||||||||||||||||||||||
| 900 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 901 | } | ||||||||||||||||||||||||||||||||||||||||||
| 902 | elsif ( $name =~ /[.]pl\z/xsm ) { | ||||||||||||||||||||||||||||||||||||||||||
| 903 | 0 | push @scripts, { source => $name, import_root => $path, relative => $relative }; | |||||||||||||||||||||||||||||||||||||||||
| 904 | } | ||||||||||||||||||||||||||||||||||||||||||
| 905 | elsif ( $name =~ /[.]t\z/xsm ) { | ||||||||||||||||||||||||||||||||||||||||||
| 906 | # unclassified .t file (found somewhere we don't recognize?) | ||||||||||||||||||||||||||||||||||||||||||
| 907 | 0 | push @files, | |||||||||||||||||||||||||||||||||||||||||
| 908 | { | ||||||||||||||||||||||||||||||||||||||||||
| 909 | class => 'import-error', | ||||||||||||||||||||||||||||||||||||||||||
| 910 | source => $name, | ||||||||||||||||||||||||||||||||||||||||||
| 911 | import_root => $path, | ||||||||||||||||||||||||||||||||||||||||||
| 912 | relative => $relative, | ||||||||||||||||||||||||||||||||||||||||||
| 913 | destination => $self->_import_error_destination( | ||||||||||||||||||||||||||||||||||||||||||
| 914 | { import_root => $path, | ||||||||||||||||||||||||||||||||||||||||||
| 915 | relative => $relative, | ||||||||||||||||||||||||||||||||||||||||||
| 916 | } | ||||||||||||||||||||||||||||||||||||||||||
| 917 | ), | ||||||||||||||||||||||||||||||||||||||||||
| 918 | reason => 'could not determine test classification', | ||||||||||||||||||||||||||||||||||||||||||
| 919 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 920 | |||||||||||||||||||||||||||||||||||||||||||
| 921 | } | ||||||||||||||||||||||||||||||||||||||||||
| 922 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 923 | 0 | push @scripts, | |||||||||||||||||||||||||||||||||||||||||
| 924 | { | ||||||||||||||||||||||||||||||||||||||||||
| 925 | source => $name, | ||||||||||||||||||||||||||||||||||||||||||
| 926 | import_root => $path, | ||||||||||||||||||||||||||||||||||||||||||
| 927 | relative => $relative, | ||||||||||||||||||||||||||||||||||||||||||
| 928 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 929 | } | ||||||||||||||||||||||||||||||||||||||||||
| 930 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 931 | 0 | $abs_path | |||||||||||||||||||||||||||||||||||||||||
| 932 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 933 | } | ||||||||||||||||||||||||||||||||||||||||||
| 934 | |||||||||||||||||||||||||||||||||||||||||||
| 935 | 0 | require Module::Metadata; | |||||||||||||||||||||||||||||||||||||||||
| 936 | |||||||||||||||||||||||||||||||||||||||||||
| 937 | 0 | foreach my $module (@modules) { | |||||||||||||||||||||||||||||||||||||||||
| 938 | 0 | my $source = $module->{source}; | |||||||||||||||||||||||||||||||||||||||||
| 939 | |||||||||||||||||||||||||||||||||||||||||||
| 940 | 0 | my $meta = Module::Metadata->new_from_file($source); | |||||||||||||||||||||||||||||||||||||||||
| 941 | |||||||||||||||||||||||||||||||||||||||||||
| 942 | 0 | ▶ | if ( !$meta ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 943 | $file_packages{$source} = { | ||||||||||||||||||||||||||||||||||||||||||
| 944 | packages => [], | ||||||||||||||||||||||||||||||||||||||||||
| 945 | relative => $module->{relative}, | ||||||||||||||||||||||||||||||||||||||||||
| 946 | reason => 'could not parse module metadata', | ||||||||||||||||||||||||||||||||||||||||||
| 947 | import_root => $module->{import_root}, | ||||||||||||||||||||||||||||||||||||||||||
| 948 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||
| 949 | |||||||||||||||||||||||||||||||||||||||||||
| 950 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 951 | } | ||||||||||||||||||||||||||||||||||||||||||
| 952 | |||||||||||||||||||||||||||||||||||||||||||
| 953 | $file_packages{$source} = { | ||||||||||||||||||||||||||||||||||||||||||
| 954 | packages => [ $meta->packages_inside ], | ||||||||||||||||||||||||||||||||||||||||||
| 955 | relative => $module->{relative}, | ||||||||||||||||||||||||||||||||||||||||||
| 956 | import_root => $module->{import_root}, | ||||||||||||||||||||||||||||||||||||||||||
| 957 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||
| 958 | } | ||||||||||||||||||||||||||||||||||||||||||
| 959 | |||||||||||||||||||||||||||||||||||||||||||
| 960 | 0 | foreach my $source ( sort keys %file_packages ) { | |||||||||||||||||||||||||||||||||||||||||
| 961 | 0 | my $module = $file_packages{$source}; | |||||||||||||||||||||||||||||||||||||||||
| 962 | |||||||||||||||||||||||||||||||||||||||||||
| 963 | 0 | ▶ | if ( $module->{reason} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 964 | push @files, | ||||||||||||||||||||||||||||||||||||||||||
| 965 | { | ||||||||||||||||||||||||||||||||||||||||||
| 966 | class => 'import-error', | ||||||||||||||||||||||||||||||||||||||||||
| 967 | source => $source, | ||||||||||||||||||||||||||||||||||||||||||
| 968 | destination => sprintf( 'import-errors/%s', $module->{relative} ), | ||||||||||||||||||||||||||||||||||||||||||
| 969 | import_root => $module->{import_root}, | ||||||||||||||||||||||||||||||||||||||||||
| 970 | reason => $module->{reason}, | ||||||||||||||||||||||||||||||||||||||||||
| 971 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||
| 972 | |||||||||||||||||||||||||||||||||||||||||||
| 973 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 974 | } | ||||||||||||||||||||||||||||||||||||||||||
| 975 | |||||||||||||||||||||||||||||||||||||||||||
| 976 | 0 | my $primary = $self->_find_primary_package( $source, $module->{packages}, ); | |||||||||||||||||||||||||||||||||||||||||
| 977 | |||||||||||||||||||||||||||||||||||||||||||
| 978 | 0 | ▶ | if ( !$primary ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 979 | push @files, | ||||||||||||||||||||||||||||||||||||||||||
| 980 | { | ||||||||||||||||||||||||||||||||||||||||||
| 981 | class => 'import-error', | ||||||||||||||||||||||||||||||||||||||||||
| 982 | source => $source, | ||||||||||||||||||||||||||||||||||||||||||
| 983 | destination => sprintf( 'import-errors/%s', $module->{relative} ), | ||||||||||||||||||||||||||||||||||||||||||
| 984 | reason => 'could not determine primary package', | ||||||||||||||||||||||||||||||||||||||||||
| 985 | import_root => $module->{import_root}, | ||||||||||||||||||||||||||||||||||||||||||
| 986 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||
| 987 | |||||||||||||||||||||||||||||||||||||||||||
| 988 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 989 | } | ||||||||||||||||||||||||||||||||||||||||||
| 990 | |||||||||||||||||||||||||||||||||||||||||||
| 991 | 0 | ( my $module_path = $primary ) =~ s{::}{/}gxsm; | |||||||||||||||||||||||||||||||||||||||||
| 992 | |||||||||||||||||||||||||||||||||||||||||||
| 993 | push @files, | ||||||||||||||||||||||||||||||||||||||||||
| 994 | { | ||||||||||||||||||||||||||||||||||||||||||
| 995 | class => 'module', | ||||||||||||||||||||||||||||||||||||||||||
| 996 | source => $source, | ||||||||||||||||||||||||||||||||||||||||||
| 997 | import_root => $module->{import_root}, | ||||||||||||||||||||||||||||||||||||||||||
| 998 | 0 | destination => sprintf( 'lib/%s.pm.in', $module_path ), | |||||||||||||||||||||||||||||||||||||||||
| 999 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 1000 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1001 | |||||||||||||||||||||||||||||||||||||||||||
| 1002 | 0 | foreach my $script (@scripts) { | |||||||||||||||||||||||||||||||||||||||||
| 1003 | push @files, | ||||||||||||||||||||||||||||||||||||||||||
| 1004 | { | ||||||||||||||||||||||||||||||||||||||||||
| 1005 | class => 'script', | ||||||||||||||||||||||||||||||||||||||||||
| 1006 | source => $script->{source}, | ||||||||||||||||||||||||||||||||||||||||||
| 1007 | import_root => $script->{import_root}, | ||||||||||||||||||||||||||||||||||||||||||
| 1008 | relative => $script->{relative}, | ||||||||||||||||||||||||||||||||||||||||||
| 1009 | destination => sprintf 'bin/%s.in', | ||||||||||||||||||||||||||||||||||||||||||
| 1010 | 0 | basename( $script->{source} ), | |||||||||||||||||||||||||||||||||||||||||
| 1011 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 1012 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1013 | |||||||||||||||||||||||||||||||||||||||||||
| 1014 | 0 | my %test_roots = ( | |||||||||||||||||||||||||||||||||||||||||
| 1015 | author => 'xt/author', | ||||||||||||||||||||||||||||||||||||||||||
| 1016 | release => 'xt/release', | ||||||||||||||||||||||||||||||||||||||||||
| 1017 | smoke => 'xt/smoke', | ||||||||||||||||||||||||||||||||||||||||||
| 1018 | t => 't', | ||||||||||||||||||||||||||||||||||||||||||
| 1019 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 1020 | |||||||||||||||||||||||||||||||||||||||||||
| 1021 | 0 | foreach my $class ( sort keys %tests ) { | |||||||||||||||||||||||||||||||||||||||||
| 1022 | 0 | foreach my $test ( @{ $tests{$class} } ) { | |||||||||||||||||||||||||||||||||||||||||
| 1023 | push @files, | ||||||||||||||||||||||||||||||||||||||||||
| 1024 | { | ||||||||||||||||||||||||||||||||||||||||||
| 1025 | class => 'test', | ||||||||||||||||||||||||||||||||||||||||||
| 1026 | source => $test->{source}, | ||||||||||||||||||||||||||||||||||||||||||
| 1027 | import_root => $test->{import_root}, | ||||||||||||||||||||||||||||||||||||||||||
| 1028 | relative => $test->{relative}, | ||||||||||||||||||||||||||||||||||||||||||
| 1029 | destination => sprintf '%s/%s', | ||||||||||||||||||||||||||||||||||||||||||
| 1030 | $test_roots{$class}, | ||||||||||||||||||||||||||||||||||||||||||
| 1031 | $test->{relative}, | ||||||||||||||||||||||||||||||||||||||||||
| 1032 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||
| 1033 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1034 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1035 | |||||||||||||||||||||||||||||||||||||||||||
| 1036 | 0 | my %destinations; | |||||||||||||||||||||||||||||||||||||||||
| 1037 | |||||||||||||||||||||||||||||||||||||||||||
| 1038 | 0 | foreach my $file (@files) { | |||||||||||||||||||||||||||||||||||||||||
| 1039 | 0 | push @{ $destinations{ $file->{destination} } }, $file; | |||||||||||||||||||||||||||||||||||||||||
| 1040 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1041 | |||||||||||||||||||||||||||||||||||||||||||
| 1042 | 0 | foreach my $destination ( keys %destinations ) { | |||||||||||||||||||||||||||||||||||||||||
| 1043 | 0 | my $files = $destinations{$destination}; | |||||||||||||||||||||||||||||||||||||||||
| 1044 | |||||||||||||||||||||||||||||||||||||||||||
| 1045 | next | ||||||||||||||||||||||||||||||||||||||||||
| 1046 | 0 | ▶ | if @{$files} == 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1047 | |||||||||||||||||||||||||||||||||||||||||||
| 1048 | 0 | foreach my $file ( @{$files} ) { | |||||||||||||||||||||||||||||||||||||||||
| 1049 | 0 | $file->{class} = 'import-error'; | |||||||||||||||||||||||||||||||||||||||||
| 1050 | 0 | $file->{destination} = $self->_import_error_destination($file); | |||||||||||||||||||||||||||||||||||||||||
| 1051 | 0 | $file->{reason} = sprintf q{multiple imported files map to '%s'}, $destination; | |||||||||||||||||||||||||||||||||||||||||
| 1052 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1053 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1054 | |||||||||||||||||||||||||||||||||||||||||||
| 1055 | 0 | my $import_files = { | |||||||||||||||||||||||||||||||||||||||||
| 1056 | files => \@files, | ||||||||||||||||||||||||||||||||||||||||||
| 1057 | packages => \%file_packages, | ||||||||||||||||||||||||||||||||||||||||||
| 1058 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 1059 | |||||||||||||||||||||||||||||||||||||||||||
| 1060 | 0 | $self->set_import_file_listing($import_files); | |||||||||||||||||||||||||||||||||||||||||
| 1061 | |||||||||||||||||||||||||||||||||||||||||||
| 1062 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 1063 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1064 | |||||||||||||||||||||||||||||||||||||||||||
| 1065 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 1066 | 0 | ▶ | sub _import_error_destination { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_import_error_destination: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1067 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 1068 | 0 | my ( $self, $file ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1069 | |||||||||||||||||||||||||||||||||||||||||||
| 1070 | 0 | my $root = $file->{import_root}; | |||||||||||||||||||||||||||||||||||||||||
| 1071 | 0 | $root =~ s{\\}{/}gxsm; | |||||||||||||||||||||||||||||||||||||||||
| 1072 | 0 | $root =~ s{\A[.]/}{}xsm; | |||||||||||||||||||||||||||||||||||||||||
| 1073 | 0 | $root =~ s{/+\z}{}xsm; | |||||||||||||||||||||||||||||||||||||||||
| 1074 | |||||||||||||||||||||||||||||||||||||||||||
| 1075 | 0 | return sprintf 'import-errors/%s/%s', $root, $file->{relative}; | |||||||||||||||||||||||||||||||||||||||||
| 1076 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1077 | |||||||||||||||||||||||||||||||||||||||||||
| 1078 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 1079 | 0 | ▶ | sub _classify_test_file { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_classify_test_file: not called CC=10 SCAR=47.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1080 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 1081 | 0 | my ( $self, $name, $relative, $root, $tests ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1082 | |||||||||||||||||||||||||||||||||||||||||||
| 1083 | return | ||||||||||||||||||||||||||||||||||||||||||
| 1084 | 0 | ▶ | if $name !~ /[.](?:pm|pl|t)\z/xsm; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1085 | |||||||||||||||||||||||||||||||||||||||||||
| 1086 | 0 | ▶ | if ( $relative =~ m{\At/(.+)\z}xsm ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1087 | 0 | push @{ $tests->{t} }, { source => $name, relative => $1, import_root => $root }; | |||||||||||||||||||||||||||||||||||||||||
| 1088 | 0 | return $TRUE; | |||||||||||||||||||||||||||||||||||||||||
| 1089 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1090 | |||||||||||||||||||||||||||||||||||||||||||
| 1091 | 0 | ▶ | if ( $relative =~ m{\Axt/author/(.+)\z}xsm ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1092 | 0 | push @{ $tests->{author} }, { source => $name, relative => $1, import_root => $root }; | |||||||||||||||||||||||||||||||||||||||||
| 1093 | 0 | return $TRUE; | |||||||||||||||||||||||||||||||||||||||||
| 1094 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1095 | |||||||||||||||||||||||||||||||||||||||||||
| 1096 | 0 | ▶ | if ( $relative =~ m{\Axt/release/(.+)\z}xsm ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1097 | 0 | push @{ $tests->{release} }, { source => $name, relative => $1, import_root => $root }; | |||||||||||||||||||||||||||||||||||||||||
| 1098 | 0 | return $TRUE; | |||||||||||||||||||||||||||||||||||||||||
| 1099 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1100 | |||||||||||||||||||||||||||||||||||||||||||
| 1101 | 0 | ▶ | if ( $relative =~ m{\Axt/smoke/(.+)\z}xsm ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1102 | 0 | push @{ $tests->{smoke} }, { source => $name, relative => $1, import_root => $root }; | |||||||||||||||||||||||||||||||||||||||||
| 1103 | 0 | return $TRUE; | |||||||||||||||||||||||||||||||||||||||||
| 1104 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1105 | |||||||||||||||||||||||||||||||||||||||||||
| 1106 | 0 | my $test_root = $root; | |||||||||||||||||||||||||||||||||||||||||
| 1107 | 0 | $test_root =~ s{\\}{/}gxsm; | |||||||||||||||||||||||||||||||||||||||||
| 1108 | 0 | $test_root =~ s{/+\z}{}xsm; | |||||||||||||||||||||||||||||||||||||||||
| 1109 | |||||||||||||||||||||||||||||||||||||||||||
| 1110 | 0 | ▶ | if ( $test_root =~ m{(?:\A|/)t\z}xsm ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1111 | 0 | push @{ $tests->{t} }, { source => $name, relative => $relative, import_root => $root }; | |||||||||||||||||||||||||||||||||||||||||
| 1112 | 0 | return $TRUE; | |||||||||||||||||||||||||||||||||||||||||
| 1113 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1114 | |||||||||||||||||||||||||||||||||||||||||||
| 1115 | 0 | ▶ | if ( $test_root =~ m{(?:\A|/)xt/author\z}xsm ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1116 | 0 | push @{ $tests->{author} }, { source => $name, relative => $relative, import_root => $root }; | |||||||||||||||||||||||||||||||||||||||||
| 1117 | 0 | return $TRUE; | |||||||||||||||||||||||||||||||||||||||||
| 1118 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1119 | |||||||||||||||||||||||||||||||||||||||||||
| 1120 | 0 | ▶ | if ( $test_root =~ m{(?:\A|/)xt/release\z}xsm ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1121 | 0 | push @{ $tests->{release} }, { source => $name, relative => $relative, import_root => $root }; | |||||||||||||||||||||||||||||||||||||||||
| 1122 | 0 | return $TRUE; | |||||||||||||||||||||||||||||||||||||||||
| 1123 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1124 | |||||||||||||||||||||||||||||||||||||||||||
| 1125 | 0 | ▶ | if ( $test_root =~ m{(?:\A|/)xt/smoke\z}xsm ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1126 | 0 | push @{ $tests->{smoke} }, { source => $name, relative => $relative, import_root => $root }; | |||||||||||||||||||||||||||||||||||||||||
| 1127 | 0 | return $TRUE; | |||||||||||||||||||||||||||||||||||||||||
| 1128 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1129 | |||||||||||||||||||||||||||||||||||||||||||
| 1130 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 1131 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1132 | |||||||||||||||||||||||||||||||||||||||||||
| 1133 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 1134 | 8 | ▶ | sub _find_primary_package { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_find_primary_package: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1135 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 1136 | 8 | my ( $self, $path, $packages ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1137 | |||||||||||||||||||||||||||||||||||||||||||
| 1138 | 8 | ( my $pkg_key = $path ) =~ s/\.pm(?:\.in)?$//xsm; | |||||||||||||||||||||||||||||||||||||||||
| 1139 | 8 | $pkg_key =~ s{/}{::}xsmg; | |||||||||||||||||||||||||||||||||||||||||
| 1140 | 8 | $pkg_key =~ s/\A:://xsm; | |||||||||||||||||||||||||||||||||||||||||
| 1141 | |||||||||||||||||||||||||||||||||||||||||||
| 1142 | 8 | my @reversed_key = reverse split /::/xsm, $pkg_key; | |||||||||||||||||||||||||||||||||||||||||
| 1143 | |||||||||||||||||||||||||||||||||||||||||||
| 1144 | 8 | my %reversed_packages = map { join( '::', reverse split /::/xsm, $_ ) => $_ } @{$packages}; | |||||||||||||||||||||||||||||||||||||||||
| 1145 | |||||||||||||||||||||||||||||||||||||||||||
| 1146 | 8 | ▶ | if ( $self->get_logger ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1147 | 8 | $self->get_logger->debug( | |||||||||||||||||||||||||||||||||||||||||
| 1148 | Dumper( | ||||||||||||||||||||||||||||||||||||||||||
| 1149 | [ path => $path, | ||||||||||||||||||||||||||||||||||||||||||
| 1150 | packages => $packages, | ||||||||||||||||||||||||||||||||||||||||||
| 1151 | pkg_key => $pkg_key, | ||||||||||||||||||||||||||||||||||||||||||
| 1152 | reversed_key => \@reversed_key, | ||||||||||||||||||||||||||||||||||||||||||
| 1153 | reversed_packages => \%reversed_packages | ||||||||||||||||||||||||||||||||||||||||||
| 1154 | ] | ||||||||||||||||||||||||||||||||||||||||||
| 1155 | ) | ||||||||||||||||||||||||||||||||||||||||||
| 1156 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 1157 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1158 | |||||||||||||||||||||||||||||||||||||||||||
| 1159 | 8 | for my $len ( reverse 1 .. scalar @reversed_key ) { | |||||||||||||||||||||||||||||||||||||||||
| 1160 | 16 | my $candidate = join '::', @reversed_key[ 0 .. $len - 1 ]; | |||||||||||||||||||||||||||||||||||||||||
| 1161 | |||||||||||||||||||||||||||||||||||||||||||
| 1162 | return $reversed_packages{$candidate} | ||||||||||||||||||||||||||||||||||||||||||
| 1163 | 16 | ▶ | if exists $reversed_packages{$candidate}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1164 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1165 | |||||||||||||||||||||||||||||||||||||||||||
| 1166 | 1 | return; | |||||||||||||||||||||||||||||||||||||||||
| 1167 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1168 | |||||||||||||||||||||||||||||||||||||||||||
| 1169 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 1170 | 0 | ▶ | sub _tail_file { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_tail_file: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1171 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 1172 | 0 | my ( $self, $file, $nlines ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1173 | |||||||||||||||||||||||||||||||||||||||||||
| 1174 | 0 | my @lines = split /\n/, slurp($file); | |||||||||||||||||||||||||||||||||||||||||
| 1175 | |||||||||||||||||||||||||||||||||||||||||||
| 1176 | 0 | my $start = max( 0, scalar(@lines) - $nlines ); | |||||||||||||||||||||||||||||||||||||||||
| 1177 | |||||||||||||||||||||||||||||||||||||||||||
| 1178 | 0 | foreach my $line ( splice @lines, $start, $nlines ) { | |||||||||||||||||||||||||||||||||||||||||
| 1179 | 0 | $self->get_logger->error($line); | |||||||||||||||||||||||||||||||||||||||||
| 1180 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1181 | |||||||||||||||||||||||||||||||||||||||||||
| 1182 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 1183 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1184 | |||||||||||||||||||||||||||||||||||||||||||
| 1185 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 1186 | 0 | ▶ | sub _find_package_name { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_find_package_name: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1187 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 1188 | 0 | my ( $self, $file ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1189 | |||||||||||||||||||||||||||||||||||||||||||
| 1190 | 0 | require Module::Metadata; | |||||||||||||||||||||||||||||||||||||||||
| 1191 | |||||||||||||||||||||||||||||||||||||||||||
| 1192 | 0 | ▶ | my $meta = Module::Metadata->new_from_file($file) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1193 | or return; | ||||||||||||||||||||||||||||||||||||||||||
| 1194 | |||||||||||||||||||||||||||||||||||||||||||
| 1195 | 0 | my ($package) = $meta->packages_inside; | |||||||||||||||||||||||||||||||||||||||||
| 1196 | |||||||||||||||||||||||||||||||||||||||||||
| 1197 | 0 | return $package; | |||||||||||||||||||||||||||||||||||||||||
| 1198 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1199 | |||||||||||||||||||||||||||||||||||||||||||
| 1200 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 1201 | 0 | ▶ | sub _create_project_tarball { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_create_project_tarball: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1202 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 1203 | 0 | my ( $self, $tmpdir, $module_name, $output_dir ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1204 | |||||||||||||||||||||||||||||||||||||||||||
| 1205 | 0 | require Archive::Tar; | |||||||||||||||||||||||||||||||||||||||||
| 1206 | |||||||||||||||||||||||||||||||||||||||||||
| 1207 | 0 | my $project_name = $module_name; | |||||||||||||||||||||||||||||||||||||||||
| 1208 | 0 | $project_name =~ s/::/-/gxsm; | |||||||||||||||||||||||||||||||||||||||||
| 1209 | |||||||||||||||||||||||||||||||||||||||||||
| 1210 | 0 | my $archive_name = sprintf '%s-cmb.tar.gz', $project_name; | |||||||||||||||||||||||||||||||||||||||||
| 1211 | 0 | my $archive_path = File::Spec->catfile( $output_dir, $archive_name ); | |||||||||||||||||||||||||||||||||||||||||
| 1212 | |||||||||||||||||||||||||||||||||||||||||||
| 1213 | 0 | my $stage_dir = File::Temp::tempdir( CLEANUP => $TRUE ); | |||||||||||||||||||||||||||||||||||||||||
| 1214 | 0 | my $project_dir = File::Spec->catdir( $stage_dir, $project_name ); | |||||||||||||||||||||||||||||||||||||||||
| 1215 | |||||||||||||||||||||||||||||||||||||||||||
| 1216 | 0 | require File::Copy::Recursive; | |||||||||||||||||||||||||||||||||||||||||
| 1217 | |||||||||||||||||||||||||||||||||||||||||||
| 1218 | 0 | ▶ | File::Copy::Recursive::dircopy( $tmpdir, $project_dir ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1219 | or croak sprintf "ERROR: could not stage project for archive: %s\n", $OS_ERROR; | ||||||||||||||||||||||||||||||||||||||||||
| 1220 | |||||||||||||||||||||||||||||||||||||||||||
| 1221 | 0 | my $pwd = getcwd; | |||||||||||||||||||||||||||||||||||||||||
| 1222 | |||||||||||||||||||||||||||||||||||||||||||
| 1223 | 0 | ▶ | chdir $stage_dir | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1224 | or croak sprintf "ERROR: could not change to %s: %s\n", $stage_dir, $OS_ERROR; | ||||||||||||||||||||||||||||||||||||||||||
| 1225 | |||||||||||||||||||||||||||||||||||||||||||
| 1226 | 0 | my @files; | |||||||||||||||||||||||||||||||||||||||||
| 1227 | |||||||||||||||||||||||||||||||||||||||||||
| 1228 | File::Find::find( | ||||||||||||||||||||||||||||||||||||||||||
| 1229 | { no_chdir => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 1230 | |||||||||||||||||||||||||||||||||||||||||||
| 1231 | 0 | ▶ | wanted => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1232 | 0 | my $name = $File::Find::name; | |||||||||||||||||||||||||||||||||||||||||
| 1233 | |||||||||||||||||||||||||||||||||||||||||||
| 1234 | 0 | $name = File::Spec->abs2rel( $name, $stage_dir ); | |||||||||||||||||||||||||||||||||||||||||
| 1235 | 0 | $name =~ s{\\}{/}gxsm; | |||||||||||||||||||||||||||||||||||||||||
| 1236 | |||||||||||||||||||||||||||||||||||||||||||
| 1237 | 0 | push @files, $name; | |||||||||||||||||||||||||||||||||||||||||
| 1238 | |||||||||||||||||||||||||||||||||||||||||||
| 1239 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 1240 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 1241 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 1242 | 0 | $project_dir, | |||||||||||||||||||||||||||||||||||||||||
| 1243 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 1244 | |||||||||||||||||||||||||||||||||||||||||||
| 1245 | 0 | my $tar = Archive::Tar->new; | |||||||||||||||||||||||||||||||||||||||||
| 1246 | |||||||||||||||||||||||||||||||||||||||||||
| 1247 | 0 | $tar->add_files(@files); | |||||||||||||||||||||||||||||||||||||||||
| 1248 | |||||||||||||||||||||||||||||||||||||||||||
| 1249 | 0 | ▶ | croak sprintf "ERROR: could not create project tarball %s\n", $archive_path | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1250 | if !$tar->write( $archive_path, Archive::Tar::COMPRESS_GZIP() ); | ||||||||||||||||||||||||||||||||||||||||||
| 1251 | |||||||||||||||||||||||||||||||||||||||||||
| 1252 | 0 | ▶ | chdir $pwd | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1253 | or croak sprintf "ERROR: could not change to %s: %s\n", $pwd, $OS_ERROR; | ||||||||||||||||||||||||||||||||||||||||||
| 1254 | |||||||||||||||||||||||||||||||||||||||||||
| 1255 | 0 | $self->get_logger->info( sprintf 'successfully created project tarball: %s', $archive_path ); | |||||||||||||||||||||||||||||||||||||||||
| 1256 | |||||||||||||||||||||||||||||||||||||||||||
| 1257 | 0 | return $archive_path; | |||||||||||||||||||||||||||||||||||||||||
| 1258 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1259 | |||||||||||||||||||||||||||||||||||||||||||
| 1260 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||