| 1 | #!/usr/local/bin/perl | ||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||
| 3 | # Copyright 2002-2026, Paul Johnson (paul@pjcj.net) | ||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||
| 5 | # This software is free. It is licensed under the same terms as Perl itself. | ||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||
| 7 | # The latest version of this software should be available from my homepage: | ||||||||||||||||||||||||||||||
| 8 | # https://pjcj.net | ||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||
| 10 | 3 | ▶ | use 5.42.0; | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||
| 12 | # VERSION | ||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||
| 14 | 3 | ▶ | use Devel::Cover::Collection (); | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||
| 16 | 3 | ▶ | use Cwd qw( abs_path cwd ); | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 17 | 3 | ▶ | use Getopt::Long qw( GetOptions ); | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 18 | 3 | ▶ | use Pod::Usage qw( pod2usage ); | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||
| 20 | # use Carp; $SIG{__DIE__} = \&Carp::confess; | ||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||
| 22 | 3 | $|++; | |||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||
| 24 | 3 | my $Options = { | |||||||||||||||||||||||||||||
| 25 | bin_dir => abs_path($0) =~ s|/cpancover$||r, | ||||||||||||||||||||||||||||||
| 26 | build => 1, | ||||||||||||||||||||||||||||||
| 27 | compress_old_versions => 0, | ||||||||||||||||||||||||||||||
| 28 | docker => "docker", | ||||||||||||||||||||||||||||||
| 29 | dryrun => 0, | ||||||||||||||||||||||||||||||
| 30 | force => 0, | ||||||||||||||||||||||||||||||
| 31 | generate_html => 0, | ||||||||||||||||||||||||||||||
| 32 | latest => 0, | ||||||||||||||||||||||||||||||
| 33 | local => 0, | ||||||||||||||||||||||||||||||
| 34 | local_build => 0, | ||||||||||||||||||||||||||||||
| 35 | mark_rebuilt => 0, | ||||||||||||||||||||||||||||||
| 36 | modules => [], | ||||||||||||||||||||||||||||||
| 37 | output_file => "index.html", | ||||||||||||||||||||||||||||||
| 38 | rebuild => 0, | ||||||||||||||||||||||||||||||
| 39 | rebuild_batch => 100, | ||||||||||||||||||||||||||||||
| 40 | report => "html", | ||||||||||||||||||||||||||||||
| 41 | results_dir => cwd(), | ||||||||||||||||||||||||||||||
| 42 | timeout => undef, | ||||||||||||||||||||||||||||||
| 43 | verbose => 0, | ||||||||||||||||||||||||||||||
| 44 | workers => 0, | ||||||||||||||||||||||||||||||
| 45 | }; | ||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||
| 47 | sub get_options { | ||||||||||||||||||||||||||||||
| 48 | #<<< | ||||||||||||||||||||||||||||||
| 49 | 3 | ▶ | die "Bad option" unless GetOptions( | ||||||||||||||||||||||||||||
|
Subroutine
get_options: called CC=6 SCAR=22.0
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 50 | $Options, qw( | ||||||||||||||||||||||||||||||
| 51 | bin_dir=s | ||||||||||||||||||||||||||||||
| 52 | build! | ||||||||||||||||||||||||||||||
| 53 | compress_old_versions=i | ||||||||||||||||||||||||||||||
| 54 | docker=s | ||||||||||||||||||||||||||||||
| 55 | dryrun! | ||||||||||||||||||||||||||||||
| 56 | env=s | ||||||||||||||||||||||||||||||
| 57 | force! | ||||||||||||||||||||||||||||||
| 58 | generate_html! | ||||||||||||||||||||||||||||||
| 59 | help|h! | ||||||||||||||||||||||||||||||
| 60 | info|i! | ||||||||||||||||||||||||||||||
| 61 | latest! | ||||||||||||||||||||||||||||||
| 62 | local! | ||||||||||||||||||||||||||||||
| 63 | local_build! | ||||||||||||||||||||||||||||||
| 64 | mark_rebuilt! | ||||||||||||||||||||||||||||||
| 65 | module_file=s | ||||||||||||||||||||||||||||||
| 66 | modules=s | ||||||||||||||||||||||||||||||
| 67 | output_file=s | ||||||||||||||||||||||||||||||
| 68 | rebuild! | ||||||||||||||||||||||||||||||
| 69 | rebuild_batch=i | ||||||||||||||||||||||||||||||
| 70 | report=s | ||||||||||||||||||||||||||||||
| 71 | results_dir=s | ||||||||||||||||||||||||||||||
| 72 | timeout=i | ||||||||||||||||||||||||||||||
| 73 | verbose! | ||||||||||||||||||||||||||||||
| 74 | version|v! | ||||||||||||||||||||||||||||||
| 75 | workers=i | ||||||||||||||||||||||||||||||
| 76 | ) | ||||||||||||||||||||||||||||||
| 77 | ); | ||||||||||||||||||||||||||||||
| 78 | #>>> | ||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||
| 80 | 3 | ▶ | say "$0 version " . __PACKAGE__->VERSION and exit 0 if $Options->{version}; | ||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition25%1/4
$Options->{'version'} && (say("$0 version " . __PACKAGE__->VERSION) && exit 0)
say "$0 version " . __PACKAGE__->VERSION and exit 0
MC/DC0%0/2
$Options->{'version'} && (say("$0 version " . __PACKAGE__->VERSION) && exit 0)
$Options->{'version'}
say "$0 version " . __PACKAGE__->VERSION
Truth table33%1/3
A && B
A= $Options->{'version'}B= say "$0 version " . __PACKAGE__->VERSION
| |||||||||||||||||||||||||||||||
| 81 | 3 | ▶ | pod2usage(-exitval => 0, -verbose => 0) if $Options->{help}; | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 82 | 3 | ▶ | pod2usage(-exitval => 0, -verbose => 2) if $Options->{info}; | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||
| 85 | sub newcp { | ||||||||||||||||||||||||||||||
| 86 | #<<< | ||||||||||||||||||||||||||||||
| 87 | Devel::Cover::Collection->new( | ||||||||||||||||||||||||||||||
| 88 | 3 | ▶ | map { $_ => $Options->{$_} } qw( | ||||||||||||||||||||||||||||
|
Subroutine
newcp: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 89 | bin_dir | ||||||||||||||||||||||||||||||
| 90 | docker | ||||||||||||||||||||||||||||||
| 91 | dryrun | ||||||||||||||||||||||||||||||
| 92 | env | ||||||||||||||||||||||||||||||
| 93 | force | ||||||||||||||||||||||||||||||
| 94 | local | ||||||||||||||||||||||||||||||
| 95 | mark_rebuilt | ||||||||||||||||||||||||||||||
| 96 | modules | ||||||||||||||||||||||||||||||
| 97 | output_file | ||||||||||||||||||||||||||||||
| 98 | rebuild | ||||||||||||||||||||||||||||||
| 99 | rebuild_batch | ||||||||||||||||||||||||||||||
| 100 | report | ||||||||||||||||||||||||||||||
| 101 | results_dir | ||||||||||||||||||||||||||||||
| 102 | timeout | ||||||||||||||||||||||||||||||
| 103 | verbose | ||||||||||||||||||||||||||||||
| 104 | workers | ||||||||||||||||||||||||||||||
| 105 | ) | ||||||||||||||||||||||||||||||
| 106 | ) | ||||||||||||||||||||||||||||||
| 107 | #>>> | ||||||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||
| 110 | sub main { | ||||||||||||||||||||||||||||||
| 111 | # TODO - only one instance should run at a time | ||||||||||||||||||||||||||||||
| 112 | 3 | ▶ | get_options; | ||||||||||||||||||||||||||||
|
Subroutine
main: called CC=14 SCAR=42.4
| |||||||||||||||||||||||||||||||
| 113 | # say Dumper($Options) if $Options->{verbose}; | ||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||
| 115 | 3 | ▶ | if ($Options->{latest}) { | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 116 | 0 | my $cp = newcp; | |||||||||||||||||||||||||||||
| 117 | 0 | $cp->get_latest; | |||||||||||||||||||||||||||||
| 118 | 0 | return; | |||||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||
| 121 | 3 | ▶ | if ($Options->{local_build}) { | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 122 | 0 | my $cp = newcp; | |||||||||||||||||||||||||||||
| 123 | 0 | $cp->set_modules(@ARGV); | |||||||||||||||||||||||||||||
| 124 | 0 | $cp->local_build; | |||||||||||||||||||||||||||||
| 125 | 0 | return; | |||||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||
| 128 | 3 | my %counts; | |||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||
| 130 | 3 | ▶ | if ($Options->{module_file}) { | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 131 | 0 | my $cp = newcp; | |||||||||||||||||||||||||||||
| 132 | 0 | $cp->set_module_file($Options->{module_file}); | |||||||||||||||||||||||||||||
| 133 | 0 | $counts{new_count} += $cp->cover_modules; | |||||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||
| 136 | 3 | ▶ | if ($Options->{build}) { | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 137 | 3 | my $cp; | |||||||||||||||||||||||||||||
| 138 | 3 | ▶ | if (@ARGV) { | ||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||
| 139 | 3 | $cp = newcp; | |||||||||||||||||||||||||||||
| 140 | 3 | $cp->set_modules(@ARGV); | |||||||||||||||||||||||||||||
| 141 | } elsif (!-t STDIN) { | ||||||||||||||||||||||||||||||
| 142 | 0 | my @modules; | |||||||||||||||||||||||||||||
| 143 | 0 | ▶ | while (my $l = <>) { | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 144 | 0 | chomp $l; | |||||||||||||||||||||||||||||
| 145 | 0 | push @modules, split " ", $l; | |||||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||||
| 147 | 0 | $cp = newcp; | |||||||||||||||||||||||||||||
| 148 | 0 | $cp->set_modules(@modules); | |||||||||||||||||||||||||||||
| 149 | } else { | ||||||||||||||||||||||||||||||
| 150 | 0 | $cp = newcp; | |||||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||||
| 152 | 3 | $counts{new_count} += $cp->cover_modules; | |||||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||
| 155 | 3 | ▶ | if ($Options->{rebuild}) { | ||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||
| 156 | 0 | my $cp = newcp; | |||||||||||||||||||||||||||||
| 157 | 0 | ▶ | $counts{rebuilt_count} = $cp->rebuild_pass if $Options->{rebuild_batch}; | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 158 | 0 | ▶ | $counts{all_rebuilt} = $cp->all_rebuilt ? 1 : 0; | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 159 | 0 | $cp->write_status(%counts); | |||||||||||||||||||||||||||||
| 160 | } elsif ($Options->{mark_rebuilt}) { | ||||||||||||||||||||||||||||||
| 161 | 0 | my $cp = newcp; | |||||||||||||||||||||||||||||
| 162 | 0 | $cp->write_status(%counts); | |||||||||||||||||||||||||||||
| 163 | } | ||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||
| 165 | 3 | ▶ | if ($Options->{generate_html}) { | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 166 | 0 | my $cp = newcp; | |||||||||||||||||||||||||||||
| 167 | 0 | $cp->generate_html; | |||||||||||||||||||||||||||||
| 168 | } | ||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||
| 170 | 3 | ▶ | if ($Options->{compress_old_versions}) { | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 171 | 0 | my $cp = newcp; | |||||||||||||||||||||||||||||
| 172 | 0 | $cp->compress_old_versions($Options->{compress_old_versions}); | |||||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||
| 176 | 3 | main | |||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||
| 178 | __END__ | ||||||||||||||||||||||||||||||