Skip to content

Commit

Permalink
Rework dc script
Browse files Browse the repository at this point in the history
  • Loading branch information
pjcj committed Jun 15, 2024
1 parent c7460eb commit cde69ee
Show file tree
Hide file tree
Showing 5 changed files with 407 additions and 317 deletions.
1 change: 1 addition & 0 deletions bin/cpancover
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ sub newcp {
sub main {
# TODO - only one instance should run at a time
get_options;
use Data::Dumper; say Dumper($Options) if $Options->{verbose};

if ($Options->{latest}) {
my $cp = newcp;
Expand Down
2 changes: 1 addition & 1 deletion docs/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ with at least the perl optree, Devel::Cover output can vary slightly between
perl releases. For this reason some Devel::Cover tests have difference golden
results depending on the perl version.

A set of perl versions can be created by running the `dc all_versions --build`
A set of perl versions can be created by running the `dc all-versions --build`
command. Once this is done golden results for all versions can be created by
running `make all_gold TEST=circular_ref`.

Expand Down
6 changes: 3 additions & 3 deletions docs/cpancover.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ cd /cover/dc
Install or upgrade a cpancover perl:

```sh
dc install_cpancover_perl 5.26.1
dc install-cpancover-perl 5.26.1
```

Run cpancover:
Expand Down Expand Up @@ -123,7 +123,7 @@ For each version there is a standard and a threaded plenv installation.

The development directory for these purposes is `/cover/Devel--Cover`. New
versions of perl can be installed by adding them to `utils/all_versions` and
running `dc all_versions --build`.
running `dc all-versions --build`.

To install a version of perl with development tools run `dc install_dc_dev_perl
To install a version of perl with development tools run `dc install-dc_dev-perl
5.38.2`.
23 changes: 6 additions & 17 deletions lib/Devel/Cover/Collection.pm
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,6 @@ sub process_module_file ($self) {
sub build_modules ($self) {
my @command = qw( cpan -Ti );
push @command, "-f" if $self->force;
# my @command = qw( cpan );
# $ENV{CPAN_OPTS} = "-i -T";
# $ENV{CPAN_OPTS} .= " -f" if $self->force;
# $self->_set_local_timeout(300);
my %m;
for my $module (sort grep !$m{$_}++, $self->modules->@*) {
Expand All @@ -147,19 +144,13 @@ sub build_modules ($self) {
}

sub add_build_dirs ($self) {
# say "add_build_dirs"; say for @{$self->build_dirs};
# say && system "ls -al $_" for "/remote_staging",
# map "$_/build", @{$self->cpan_dir};
my $exists = sub {
# say "exists [$_]";
my $dir = "/remote_staging/" . (s|.*/||r =~ s/-\d+$/*/r);
my @files = glob $dir;
# say "checking [$dir] -> [@files]";
@files
};
push $self->build_dirs->@*, grep { !$exists->() } grep -d,
map glob("$_/build/*"), $self->cpan_dir->@*;
# say "add_build_dirs:"; say for @{$self->build_dirs};
}

sub run ($self, $build_dir) {
Expand All @@ -185,14 +176,11 @@ sub run ($self, $build_dir) {
}

$output .= "Testing $module in $build_dir\n";
# say "\n$line\n$output$line\n"; return;

# $output .= $self->sys($^X, "-V");
# $output .= $self->sys("pwd");
my @cmd;
if ($self->local) {
$ENV{DEVEL_COVER_OPTIONS} = "-ignore,/usr/local/lib/perl5";
$ENV{DEVEL_COVER_TEST_OPTS} = "-Mblib=" . $self->bin_dir;
$ENV{DEVEL_COVER_TEST_OPTS} = "-Mblib=" . $self->bin_dir . "/..";
@cmd = ($^X, $ENV{DEVEL_COVER_TEST_OPTS}, $self->bin_dir . "/cover");
} else {
@cmd = ($^X, $self->bin_dir . "/cover");
Expand Down Expand Up @@ -224,7 +212,6 @@ sub run_all ($self) {
},
$self->build_dirs
);
# print Dumper \@res;
}

sub write_json ($self, $vars) {
Expand Down Expand Up @@ -339,7 +326,7 @@ sub generate_html ($self) {
$m->{module} = $mod;
$m->{link} = "/$module/index.html" if $json->{summary}{Total}{total}{total};

for my $criterion ($vars->{criteria}->%*) {
for my $criterion ($vars->{criteria}->@*) {
my $summary = $json->{summary}{Total}{$criterion};
# print "summary:", Dumper $summary;
my $pc = $summary->{percentage};
Expand Down Expand Up @@ -466,7 +453,9 @@ sub cover_modules ($self) {
# say "modules: ", Dumper $self->modules;

my @cmd = $self->dc_file;
push @cmd, "--local" if $self->local;
push @cmd, "--local" if $self->local;
push @cmd, "--verbose" if $self->verbose;
push @cmd, "-i", "pjcj/cpancover_dev:latest";
my @command = (@cmd, "cpancover-docker-module");
$self->_set_local_timeout(0);
my @res = iterate_as_array(
Expand Down Expand Up @@ -637,7 +626,7 @@ use base "Template::Provider";

my %Templates;

sub fetch ($self, $name) {
sub fetch ($self, $name, $) {
# print "Looking for <$name>\n";
$self->SUPER::fetch(exists $Templates{$name} ? \$Templates{$name} : $name)
}
Expand Down
Loading

0 comments on commit cde69ee

Please sign in to comment.