Devel-Cover
view release on metacpan or search on metacpan
utils/all_versions view on Meta::CPAN
5.40.0 5.40.1 5.40.2
5.42.0
5.43.1 5.43.2 5.43.3 5.43.4 5.43.5 5.43.6 5.43.7
)
]
unless $Options->{version}->@*;
$Options->{version} = [
grep {
my $cmd = "dc-$_ -v$Silent";
my $exists = eval { !system $cmd };
$Options->{force} || ($exists ^ $Options->{build})
} $Options->{version}->@*
];
say "Versions: @{$Options->{version}}";
if ($Options->{list}) {
exit;
}
}
sub sys ($command, $user = 0, $logfile = undef) {
say $command;
return 1 if $Options->{dry_run};
my $ret;
if ($logfile) {
open my $log_fh, ">>", $logfile or warn "Can't open $logfile: $!";
open my $cmd_fh, "-|", "$command 2>&1" or do {
warn "Can't run $command: $!";
return 0;
};
while (my $line = <$cmd_fh>) {
print $log_fh $line if $log_fh;
print $line if $user;
}
close $cmd_fh or 1; # Ignore - exit status captured via $?
$ret = $?;
close $log_fh or warn "Can't close $logfile: $!" if $log_fh;
} elsif ($Options->{silent} && !$user) {
$ret = system "$command$Silent";
} else {
$ret = system $command;
}
warn "command failed: $ret - $command" if $ret && !$Options->{ignore_failure};
!$ret
}
sub _mods ($v, $n) {
my ($s) = $n =~ /(\d+)$/;
my $version = version->parse($n);
my @mods = qw( Test::Harness Test::Warn HTML::Entities );
return @mods if $v =~ /-thr/ && $s != 1;
push @mods, qw(
Template
Pod::Coverage
Test::Differences
Readonly
Parallel::Iterator
Sereal
JSON::MaybeXS
);
push @mods, "Perl::Tidy" if !$s || $s % 2;
push @mods, "PPI::HTML" if !$s || !($s % 2);
@mods
}
sub _build_version ($v) {
say "building $v";
# sleep 1; return;
my ($n) = $v =~ /(\d+\.\d+\.\d+)/ or die "Can't parse [$v}";
my $dir = "$ENV{HOME}/.plenv/versions/dc-$v/bin";
unless (-d $dir) {
my $opts = "-D usedevel";
$opts .= " -D usethreads" if $v =~ /thr/;
my $j = njobs;
sys "plenv install $n --as dc-$v -j $j $opts --noman" or do {
warn "plenv $v failed";
return;
};
unless (-d $dir) {
warn "perl for $v does not exist";
return;
}
}
$ENV{PATH} = "$dir:$ENV{PATH}";
sys "curl -L https://cpanmin.us | perl - App::cpanminus" or do {
warn "cpanm installation for $v failed";
return;
};
my @mods = _mods($v, $n);
sys "cpanm --notest @mods" or do {
warn "module installation for $v failed";
return;
};
my $ln = "/usr/local/bin/dc-$v";
sys "sudo rm -f $ln$Silent";
my $perl = "$dir/perl";
say "$perl => $ln";
sys "sudo ln -s $perl $ln" or warn "Can't ln $perl => $ln: $!";
}
sub _build_versions ($v) {
_build_version $v;
_build_version "$v-thr";
}
sub build_default {
delete $ENV{PLENV_VERSION};
( run in 0.719 second using v1.01-cache-2.11-cpan-6aa56a78535 )