| 1 | package App::lcpan::Cmd::core_or_pp; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 1 | our $DATE = '2021-02-13'; # DATE | |||||||||||||||||||||||||||
| 4 | 1 | our $VERSION = '0.051'; # VERSION | |||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use 5.010001; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use Log::ger; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 1 | require App::lcpan; | |||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 1 | our %SPEC; | |||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | $SPEC{handle_cmd} = { | ||||||||||||||||||||||||||||
| 16 | 1 | v => 1.1, | |||||||||||||||||||||||||||
| 17 | summary => 'Check that a module (with its prereqs) are all core/PP', | ||||||||||||||||||||||||||||
| 18 | args => { | ||||||||||||||||||||||||||||
| 19 | %App::lcpan::common_args, | ||||||||||||||||||||||||||||
| 20 | %App::lcpan::mods_args, | ||||||||||||||||||||||||||||
| 21 | with_prereqs => { | ||||||||||||||||||||||||||||
| 22 | schema => ['bool*', is=>1], | ||||||||||||||||||||||||||||
| 23 | }, | ||||||||||||||||||||||||||||
| 24 | with_recursive_prereqs => { | ||||||||||||||||||||||||||||
| 25 | schema => ['bool*', is=>1], | ||||||||||||||||||||||||||||
| 26 | }, | ||||||||||||||||||||||||||||
| 27 | core => { | ||||||||||||||||||||||||||||
| 28 | schema => ['bool*', is=>1], | ||||||||||||||||||||||||||||
| 29 | }, | ||||||||||||||||||||||||||||
| 30 | pp => { | ||||||||||||||||||||||||||||
| 31 | schema => ['bool*', is=>1], | ||||||||||||||||||||||||||||
| 32 | }, | ||||||||||||||||||||||||||||
| 33 | core_or_pp => { | ||||||||||||||||||||||||||||
| 34 | schema => ['bool*', is=>1], | ||||||||||||||||||||||||||||
| 35 | }, | ||||||||||||||||||||||||||||
| 36 | }, | ||||||||||||||||||||||||||||
| 37 | args_rels => { | ||||||||||||||||||||||||||||
| 38 | 'choose_one&' => [ | ||||||||||||||||||||||||||||
| 39 | [qw/with_prereqs with_recursive_prereqs/], | ||||||||||||||||||||||||||||
| 40 | [qw/core pp core_or_pp/], | ||||||||||||||||||||||||||||
| 41 | ], | ||||||||||||||||||||||||||||
| 42 | }, | ||||||||||||||||||||||||||||
| 43 | }; | ||||||||||||||||||||||||||||
| 44 | 0 | ▶ | sub handle_cmd { | ||||||||||||||||||||||||||
|
Subroutine
handle_cmd: not called CC=28 SCAR=67.0
Pod
documented
| |||||||||||||||||||||||||||||
| 45 | 0 | require Module::CoreList::More; | |||||||||||||||||||||||||||
| 46 | 0 | require Module::Path::More; | |||||||||||||||||||||||||||
| 47 | 0 | require Module::XSOrPP; | |||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | 0 | my %args = @_; | |||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | 0 | my $with_prereqs = delete $args{with_prereqs}; | |||||||||||||||||||||||||||
| 52 | 0 | my $with_recursive_prereqs = delete $args{with_recursive_prereqs}; | |||||||||||||||||||||||||||
| 53 | 0 | my $core = delete $args{core}; | |||||||||||||||||||||||||||
| 54 | 0 | my $pp = delete $args{pp}; | |||||||||||||||||||||||||||
| 55 | 0 | ▶ | my $core_or_pp = delete($args{core_or_pp}) // 1; | ||||||||||||||||||||||||||
|
Condition0%0/2
delete $args{"core_or_pp"} // 1
MC/DC0%0/1
delete $args{"core_or_pp"} // 1
delete $args{"core_or_pp"}
Truth table0%0/2
A
A= delete $args{"core_or_pp"}
| |||||||||||||||||||||||||||||
| 56 | 0 | my $mods0 = delete $args{modules}; | |||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | 0 | my $mods = {}; | |||||||||||||||||||||||||||
| 59 | 0 | ▶ | if ($with_prereqs || $with_recursive_prereqs) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$with_prereqs or $with_recursive_prereqs
MC/DC0%0/2
$with_prereqs or $with_recursive_prereqs
$with_prereqs
$with_recursive_prereqs
Truth table0%0/3
A or B
A= $with_prereqsB= $with_recursive_prereqs
| |||||||||||||||||||||||||||||
| 60 | 0 | require App::lcpan::Cmd::mod2dist; | |||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | 0 | my $res; | |||||||||||||||||||||||||||
| 63 | 0 | $res = App::lcpan::Cmd::mod2dist::handle_cmd(%args, modules=>$mods0); | |||||||||||||||||||||||||||
| 64 | #log_trace "mod2dist result: %s", $res; | ||||||||||||||||||||||||||||
| 65 | 0 | ▶ | return [500, "Can't mod2dist: $res->[0] - $res->[1]"] | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 66 | unless $res->[0] == 200; | ||||||||||||||||||||||||||||
| 67 | 0 | ▶ | my $dists = ref($res->[2]) eq 'HASH' ? [sort keys %{$res->[2]}] : [$res->[2]]; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 68 | #log_trace "dists=%s", $dists; | ||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | 0 | $res = App::lcpan::deps( | |||||||||||||||||||||||||||
| 71 | %args, | ||||||||||||||||||||||||||||
| 72 | dists => $dists, | ||||||||||||||||||||||||||||
| 73 | (level => -1) x !!$with_recursive_prereqs, | ||||||||||||||||||||||||||||
| 74 | ); | ||||||||||||||||||||||||||||
| 75 | 0 | ▶ | return [500, "Can't deps: $res->[0] - $res->[1]"] | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 76 | unless $res->[0] == 200; | ||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | 0 | for my $e (@{ $res->[2] }) { | |||||||||||||||||||||||||||
| 79 | 0 | $e->{module} =~ s/^\s+//; | |||||||||||||||||||||||||||
| 80 | 0 | $mods->{$e->{module}} = $e->{version}; | |||||||||||||||||||||||||||
| 81 | #log_trace "Added %s (%s) to list of modules to check", | ||||||||||||||||||||||||||||
| 82 | # $e->{module}, $e->{version}; | ||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||
| 84 | 0 | ▶ | $mods->{$_} //= 0 for @$mods0; | ||||||||||||||||||||||||||
|
Condition0%0/2
$mods->{$_} //= 0
MC/DC0%0/1
$mods->{$_} //= 0
$mods->{$_}
Truth table0%0/2
A
A= $mods->{$_}
| |||||||||||||||||||||||||||||
| 85 | } else { | ||||||||||||||||||||||||||||
| 86 | 0 | $mods->{$_} = 0 for @$mods0; | |||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | 0 | my $what; | |||||||||||||||||||||||||||
| 90 | my @errs; | ||||||||||||||||||||||||||||
| 91 | MOD: | ||||||||||||||||||||||||||||
| 92 | 0 | for my $mod (sort keys %$mods) { | |||||||||||||||||||||||||||
| 93 | 0 | ▶ | next if $mod eq 'perl'; # XXX check perl version | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 94 | 0 | my $v = $mods->{version}; | |||||||||||||||||||||||||||
| 95 | 0 | ▶ | my $subject = "$mod".($v ? " (version $v)" : ""); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 96 | 0 | log_trace("Checking %s ...", $subject); | |||||||||||||||||||||||||||
| 97 | 0 | ▶ | if ($core) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 98 | 0 | ▶ | $what //= "core"; | ||||||||||||||||||||||||||
|
Condition0%0/2
$what //= "core"
MC/DC0%0/1
$what //= "core"
$what
Truth table0%0/2
A
A= $what
| |||||||||||||||||||||||||||||
| 99 | 0 | ▶ | if (!Module::CoreList::More->is_still_core($mod, $v)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 100 | 0 | push @errs, "$subject is not core"; | |||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||
| 102 | } elsif ($pp) { | ||||||||||||||||||||||||||||
| 103 | 0 | ▶ | $what //= "PP"; | ||||||||||||||||||||||||||
|
Condition0%0/2
$what //= "PP"
MC/DC0%0/1
$what //= "PP"
$what
Truth table0%0/2
A
A= $what
| |||||||||||||||||||||||||||||
| 104 | 0 | ▶ | if (!Module::Path::More::module_path(module => $mod)) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 105 | 0 | push @errs, "$subject is not installed, so can't check XS/PP"; | |||||||||||||||||||||||||||
| 106 | # XXX check installed module version | ||||||||||||||||||||||||||||
| 107 | } elsif (!Module::XSOrPP::is_pp($mod)) { | ||||||||||||||||||||||||||||
| 108 | 0 | push @errs, "$subject is not $what"; | |||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||
| 110 | } else { | ||||||||||||||||||||||||||||
| 111 | 0 | ▶ | $what //= "core/PP"; | ||||||||||||||||||||||||||
|
Condition0%0/2
$what //= "core/PP"
MC/DC0%0/1
$what //= "core/PP"
$what
Truth table0%0/2
A
A= $what
| |||||||||||||||||||||||||||||
| 112 | 0 | ▶ | if (Module::CoreList::More->is_still_core($mod, $v)) { | ||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||
| 113 | 0 | next MOD; | |||||||||||||||||||||||||||
| 114 | } elsif (!Module::Path::More::module_path(module => $mod)) { | ||||||||||||||||||||||||||||
| 115 | 0 | push @errs, "$subject is not installed, so can't check XS/PP"; | |||||||||||||||||||||||||||
| 116 | # XXX check installed module version | ||||||||||||||||||||||||||||
| 117 | } elsif (!Module::XSOrPP::is_pp($mod)) { | ||||||||||||||||||||||||||||
| 118 | 0 | push @errs, "$subject is not $what"; | |||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||
| 123 | 0 | ▶ | if (@errs) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 124 | 0 | return [200, "OK", 0, { | |||||||||||||||||||||||||||
| 125 | 'func.errors' => \@errs, | ||||||||||||||||||||||||||||
| 126 | "cmdline.result" => join("\n", @errs), | ||||||||||||||||||||||||||||
| 127 | "cmdline.exit_code" => 1, | ||||||||||||||||||||||||||||
| 128 | }]; | ||||||||||||||||||||||||||||
| 129 | } else { | ||||||||||||||||||||||||||||
| 130 | 0 | ▶ | return [200, "OK", 1, { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 131 | "cmdline.result" => "All modules". | ||||||||||||||||||||||||||||
| 132 | ($with_recursive_prereqs ? " with their recursive prereqs" : | ||||||||||||||||||||||||||||
| 133 | $with_prereqs ? " with their prereqs" : "")." are $what", | ||||||||||||||||||||||||||||
| 134 | }]; | ||||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||
| 138 | 1 | 1; | |||||||||||||||||||||||||||
| 139 | # ABSTRACT: Check that a module (with its prereqs) are all core/PP | ||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||
| 141 | __END__ | ||||||||||||||||||||||||||||