| 1 | package Test::DependentModules; | ||||||||||||||||||||||||||||||||
| 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 | 1 | ▶ | use autodie; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||
| 7 | 1 | our $VERSION = '0.26'; | |||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||
| 9 | # CPAN::Reporter spits out random output we don't want, and we don't want to | ||||||||||||||||||||||||||||||||
| 10 | # report these tests anyway. | ||||||||||||||||||||||||||||||||
| 11 | BEGIN { | ||||||||||||||||||||||||||||||||
| 12 | ## no critic (Variables::RequireLocalizedPunctuationVars) | ||||||||||||||||||||||||||||||||
| 13 | 1 | ▶ | $INC{'CPAN/Reporter.pm'} = 0; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 14 | } | ||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||
| 16 | 1 | ▶ | use Capture::Tiny qw( capture ); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 17 | 1 | ▶ | use Cwd qw( abs_path ); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 18 | 1 | ▶ | use Exporter qw( import ); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 19 | 1 | ▶ | use File::Path qw( rmtree ); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 20 | 1 | ▶ | use File::Spec; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 21 | 1 | ▶ | use File::Temp qw( tempdir ); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 22 | 1 | ▶ | use File::chdir; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 23 | 1 | ▶ | use IO::Handle::Util qw( io_from_write_cb ); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 24 | 1 | ▶ | use IPC::Run3 qw( run3 ); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 25 | 1 | ▶ | use Log::Dispatch; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 26 | 1 | ▶ | use MetaCPAN::Client; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 27 | 1 | ▶ | use Test::Builder; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 28 | 1 | ▶ | use Try::Tiny; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||
| 30 | 1 | our @EXPORT_OK = qw( test_all_dependents test_module test_modules ); | |||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||
| 32 | ## no critic (Variables::RequireLocalizedPunctuationVars) | ||||||||||||||||||||||||||||||||
| 33 | 1 | ▶ | $ENV{PERL5LIB} = join q{:}, ( $ENV{PERL5LIB} || q{} ), | ||||||||||||||||||||||||||||||
|
Condition50%1/2
$ENV{'PERL5LIB'} || ''
MC/DC0%0/1
$ENV{'PERL5LIB'} || ''
$ENV{'PERL5LIB'}
Truth table50%1/2
A
A= $ENV{'PERL5LIB'}
| |||||||||||||||||||||||||||||||||
| 34 | File::Spec->catdir( _temp_lib_dir(), 'lib', 'perl5' ); | ||||||||||||||||||||||||||||||||
| 35 | 1 | $ENV{PERL_AUTOINSTALL} = '--defaultdeps'; | |||||||||||||||||||||||||||||||
| 36 | 1 | $ENV{PERL_MM_USE_DEFAULT} = 1; | |||||||||||||||||||||||||||||||
| 37 | ## use critic | ||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||
| 39 | 1 | my $Test = Test::Builder->new; | |||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||
| 41 | sub test_all_dependents { | ||||||||||||||||||||||||||||||||
| 42 | 0 | ▶ | my $module = shift; | ||||||||||||||||||||||||||||||
|
Subroutine
test_all_dependents: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 43 | 0 | my $params = shift; | |||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||
| 45 | 0 | _load_cpan(); | |||||||||||||||||||||||||||||||
| 46 | 0 | _make_logs(); | |||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||
| 48 | 0 | my @deps = _get_deps( $module, $params ); | |||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||
| 50 | 0 | $Test->plan( tests => scalar @deps ); | |||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||
| 52 | 0 | local $Test::Builder::Level = $Test::Builder::Level + 1; | |||||||||||||||||||||||||||||||
| 53 | 0 | test_modules(@deps); | |||||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||
| 56 | sub _get_deps { | ||||||||||||||||||||||||||||||||
| 57 | 0 | ▶ | my $module = shift; | ||||||||||||||||||||||||||||||
|
Subroutine
_get_deps: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||||||
| 58 | 0 | my $params = shift; | |||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||
| 60 | 0 | $module =~ s/::/-/g; | |||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||
| 62 | 0 | my $rev_deps = MetaCPAN::Client->new->rev_deps($module); | |||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||
| 64 | my $allow | ||||||||||||||||||||||||||||||||
| 65 | = $params->{filter} ? $params->{filter} | ||||||||||||||||||||||||||||||||
| 66 | 0 | ▶ | : $params->{exclude} ? sub { $_[0] !~ /$params->{exclude}/ } | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||
| 67 | 0 | ▶ | : sub {1}; | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
Branch: 2 branches
| |||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||
| 69 | 0 | my @deps; | |||||||||||||||||||||||||||||||
| 70 | 0 | ▶ | while ( my $dep = $rev_deps->next ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 71 | 0 | my $dist = $dep->distribution; | |||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||
| 73 | 0 | ▶ | next unless $allow->($dist); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 74 | 0 | ▶ | next if $dist =~ /^(?:Task|Bundle)/; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||
| 76 | 0 | push @deps => $dist; | |||||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||
| 79 | ## no critic (Subroutines::ProhibitReturnSort) | ||||||||||||||||||||||||||||||||
| 80 | 0 | return sort { lc $a cmp lc $b } @deps; | |||||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||
| 83 | sub test_modules { | ||||||||||||||||||||||||||||||||
| 84 | 0 | ▶ | _load_cpan(); | ||||||||||||||||||||||||||||||
|
Subroutine
test_modules: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||||||
| 85 | 0 | _make_logs(); | |||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||
| 87 | 0 | my $parallel = 0; | |||||||||||||||||||||||||||||||
| 88 | 0 | ▶ | if ( $ENV{PERL_TEST_DM_PROCESSES} | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$ENV{"PERL_TEST_DM_PROCESSES"} and $ENV{"PERL_TEST_DM_PROCESSES"} > 1
MC/DC0%0/2
$ENV{"PERL_TEST_DM_PROCESSES"} and $ENV{"PERL_TEST_DM_PROCESSES"} > 1
$ENV{"PERL_TEST_DM_PROCESSES"}
$ENV{"PERL_TEST_DM_PROCESSES"} > 1
Truth table0%0/3
A and B
A= $ENV{"PERL_TEST_DM_PROCESSES"}B= $ENV{"PERL_TEST_DM_PROCESSES"} > 1
| |||||||||||||||||||||||||||||||||
| 89 | && $ENV{PERL_TEST_DM_PROCESSES} > 1 ) { | ||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||
| 91 | 0 | ▶ | if ( eval { require Parallel::ForkManager; 1; } ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 92 | 0 | $parallel = 1; | |||||||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||||||
| 94 | else { | ||||||||||||||||||||||||||||||||
| 95 | 0 | warn | |||||||||||||||||||||||||||||||
| 96 | 'Cannot run multiple processes without the Parallel::ForkManager module.'; | ||||||||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||
| 100 | 0 | ▶ | if ($parallel) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 101 | 0 | _test_in_parallel(@_); | |||||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||||||
| 103 | else { | ||||||||||||||||||||||||||||||||
| 104 | 0 | local $Test::Builder::Level = $Test::Builder::Level + 1; | |||||||||||||||||||||||||||||||
| 105 | 0 | for my $module (@_) { | |||||||||||||||||||||||||||||||
| 106 | 0 | test_module($module); | |||||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||
| 111 | sub _test_in_parallel { | ||||||||||||||||||||||||||||||||
| 112 | 0 | ▶ | my @modules = @_; | ||||||||||||||||||||||||||||||
|
Subroutine
_test_in_parallel: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||
| 114 | 0 | my $pm = Parallel::ForkManager->new( $ENV{PERL_TEST_DM_PROCESSES} ); | |||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||
| 116 | $pm->run_on_finish( | ||||||||||||||||||||||||||||||||
| 117 | sub { | ||||||||||||||||||||||||||||||||
| 118 | 0 | ▶ | shift; # pid | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||
| 119 | 0 | shift; # program exit code | |||||||||||||||||||||||||||||||
| 120 | 0 | shift; # ident | |||||||||||||||||||||||||||||||
| 121 | 0 | shift; # exit signal | |||||||||||||||||||||||||||||||
| 122 | 0 | shift; # core dump | |||||||||||||||||||||||||||||||
| 123 | 0 | my $results = shift; | |||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||
| 125 | 0 | local $Test::Builder::Level = $Test::Builder::Level + 1; | |||||||||||||||||||||||||||||||
| 126 | 0 | _test_report($results); | |||||||||||||||||||||||||||||||
| 127 | } | ||||||||||||||||||||||||||||||||
| 128 | 0 | ); | |||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||
| 130 | 0 | for my $module (@_) { | |||||||||||||||||||||||||||||||
| 131 | 0 | ▶ | $pm->start and next; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||
| 133 | 0 | local $Test::Builder::Level = $Test::Builder::Level + 1; | |||||||||||||||||||||||||||||||
| 134 | 0 | test_module( $module, $pm ); | |||||||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||
| 137 | 0 | $pm->wait_all_children; | |||||||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||
| 140 | sub test_module { | ||||||||||||||||||||||||||||||||
| 141 | 0 | ▶ | my $name = shift; | ||||||||||||||||||||||||||||||
|
Subroutine
test_module: not called CC=11 SCAR=48.8
Pod
documented
| |||||||||||||||||||||||||||||||||
| 142 | 0 | my $pm = shift; | |||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||
| 144 | 0 | _load_cpan(); | |||||||||||||||||||||||||||||||
| 145 | 0 | _make_logs(); | |||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||
| 147 | 0 | $name =~ s/-/::/g; | |||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||
| 149 | 0 | my $dist = _get_distro($name); | |||||||||||||||||||||||||||||||
| 150 | 0 | ▶ | unless ($dist) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 151 | 0 | _finish_test( | |||||||||||||||||||||||||||||||
| 152 | $pm, | ||||||||||||||||||||||||||||||||
| 153 | { | ||||||||||||||||||||||||||||||||
| 154 | name => $name, | ||||||||||||||||||||||||||||||||
| 155 | skipped => qq{Could't find a distro for $name}, | ||||||||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||||||
| 157 | ); | ||||||||||||||||||||||||||||||||
| 158 | 0 | return; | |||||||||||||||||||||||||||||||
| 159 | } | ||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||
| 161 | 0 | $Test->diag( 'Testing ' . $dist->base_id ); | |||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||
| 163 | 0 | ▶ | unless ($dist) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 164 | 0 | $name =~ s/::/-/g; | |||||||||||||||||||||||||||||||
| 165 | 0 | ▶ | my $todo | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 166 | = defined( $Test->todo ) | ||||||||||||||||||||||||||||||||
| 167 | ? ' (TODO: ' . $Test->todo . ')' | ||||||||||||||||||||||||||||||||
| 168 | : q{}; | ||||||||||||||||||||||||||||||||
| 169 | 0 | my $summary = "FAIL${todo}: $name - ??? - ???"; | |||||||||||||||||||||||||||||||
| 170 | 0 | my $output = "Could not find $name on CPAN\n"; | |||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||
| 172 | 0 | _finish_test( | |||||||||||||||||||||||||||||||
| 173 | $pm, { | ||||||||||||||||||||||||||||||||
| 174 | name => $name, | ||||||||||||||||||||||||||||||||
| 175 | passed => 0, | ||||||||||||||||||||||||||||||||
| 176 | summary => $summary, | ||||||||||||||||||||||||||||||||
| 177 | output => $output, | ||||||||||||||||||||||||||||||||
| 178 | stderr => $output, | ||||||||||||||||||||||||||||||||
| 179 | } | ||||||||||||||||||||||||||||||||
| 180 | ); | ||||||||||||||||||||||||||||||||
| 181 | 0 | return; | |||||||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||
| 184 | 0 | $name = $dist->base_id; | |||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||
| 186 | my $success = try { | ||||||||||||||||||||||||||||||||
| 187 | 0 | ▶ | capture { _install_prereqs($dist) }; | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||
| 188 | 0 | 1; | |||||||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||||||
| 190 | catch { | ||||||||||||||||||||||||||||||||
| 191 | 0 | ▶ | local $Test::Builder::Level = $Test::Builder::Level + 1; | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||
| 192 | 0 | my $msg = "Installing prereqs for $name failed: $_"; | |||||||||||||||||||||||||||||||
| 193 | 0 | $msg =~ s/\s*$//; | |||||||||||||||||||||||||||||||
| 194 | 0 | $msg =~ s/\n/\t/g; | |||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||
| 196 | 0 | _finish_test( | |||||||||||||||||||||||||||||||
| 197 | $pm, | ||||||||||||||||||||||||||||||||
| 198 | , { | ||||||||||||||||||||||||||||||||
| 199 | name => $name, | ||||||||||||||||||||||||||||||||
| 200 | skipped => $msg, | ||||||||||||||||||||||||||||||||
| 201 | } | ||||||||||||||||||||||||||||||||
| 202 | ); | ||||||||||||||||||||||||||||||||
| 203 | 0 | return; | |||||||||||||||||||||||||||||||
| 204 | 0 | }; | |||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||
| 206 | 0 | ▶ | return unless $success; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||
| 208 | 0 | my ( $passed, $output, $stderr ) = _run_tests_for_dir( $dist->dir ); | |||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||
| 210 | # A lot of modules seem to have cargo-culted a diag() that looks like this | ||||||||||||||||||||||||||||||||
| 211 | # ... | ||||||||||||||||||||||||||||||||
| 212 | # | ||||||||||||||||||||||||||||||||
| 213 | # Testing Foo::Bar 0.01, Perl 5.00801, /usr/bin/perl | ||||||||||||||||||||||||||||||||
| 214 | 0 | ▶ | $stderr = q{} | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $stderr and $stderr =~ /\A\# Testing [\w:]+ [^\n]+\Z/
MC/DC0%0/2
defined $stderr and $stderr =~ /\A\# Testing [\w:]+ [^\n]+\Z/
defined $stderr
$stderr =~ /\A\# Testing [\w:]+ [^\n]+\Z/
Truth table0%0/3
A and B
A= defined $stderrB= $stderr =~ /\A\# Testing [\w:]+ [^\n]+\Z/
| |||||||||||||||||||||||||||||||||
| 215 | if defined $stderr && $stderr =~ /\A\# Testing [\w:]+ [^\n]+\Z/; | ||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||
| 217 | 0 | ▶ | my $status = $passed && $stderr ? 'WARN' : $passed ? 'PASS' : 'FAIL'; | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
$passed and $stderr
MC/DC0%0/2
$passed and $stderr
$passed
$stderr
Truth table0%0/3
A and B
A= $passedB= $stderr
| |||||||||||||||||||||||||||||||||
| 218 | 0 | ▶ | if ( my $reason = $Test->todo ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 219 | 0 | $status .= " (TODO: $reason)"; | |||||||||||||||||||||||||||||||
| 220 | } | ||||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||
| 222 | 0 | my $summary | |||||||||||||||||||||||||||||||
| 223 | = "$status: $name - " . $dist->base_id . ' - ' . $dist->author->id; | ||||||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||||
| 225 | 0 | _finish_test( | |||||||||||||||||||||||||||||||
| 226 | $pm, | ||||||||||||||||||||||||||||||||
| 227 | { | ||||||||||||||||||||||||||||||||
| 228 | name => $name, | ||||||||||||||||||||||||||||||||
| 229 | passed => $passed, | ||||||||||||||||||||||||||||||||
| 230 | summary => $summary, | ||||||||||||||||||||||||||||||||
| 231 | output => $output, | ||||||||||||||||||||||||||||||||
| 232 | stderr => $stderr, | ||||||||||||||||||||||||||||||||
| 233 | } | ||||||||||||||||||||||||||||||||
| 234 | ); | ||||||||||||||||||||||||||||||||
| 235 | } | ||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||
| 237 | sub _finish_test { | ||||||||||||||||||||||||||||||||
| 238 | 0 | ▶ | my $pm = shift; | ||||||||||||||||||||||||||||||
|
Subroutine
_finish_test: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||
| 239 | 0 | my $results = shift; | |||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||
| 241 | 0 | ▶ | if ($pm) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 242 | 0 | $pm->finish( 0, $results ); | |||||||||||||||||||||||||||||||
| 243 | } | ||||||||||||||||||||||||||||||||
| 244 | else { | ||||||||||||||||||||||||||||||||
| 245 | 0 | local $Test::Builder::Level = $Test::Builder::Level + 2; | |||||||||||||||||||||||||||||||
| 246 | 0 | _test_report($results); | |||||||||||||||||||||||||||||||
| 247 | } | ||||||||||||||||||||||||||||||||
| 248 | } | ||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||
| 250 | ## no critic (Subroutines::ProhibitManyArgs) | ||||||||||||||||||||||||||||||||
| 251 | sub _test_report { | ||||||||||||||||||||||||||||||||
| 252 | 0 | ▶ | my $results = shift; | ||||||||||||||||||||||||||||||
|
Subroutine
_test_report: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||||||
| 254 | 0 | ▶ | if ( $results->{skipped} ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 255 | 0 | _status_log("UNKNOWN: $results->{name} ($results->{skipped})\n"); | |||||||||||||||||||||||||||||||
| 256 | 0 | _error_log("UNKNOWN: $results->{name} ($results->{skipped})\n"); | |||||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||||||
| 258 | 0 | $Test->diag("Skipping $results->{name}: $results->{skipped}"); | |||||||||||||||||||||||||||||||
| 259 | 0 | $Test->skip( $results->{skipped} ); | |||||||||||||||||||||||||||||||
| 260 | } | ||||||||||||||||||||||||||||||||
| 261 | else { | ||||||||||||||||||||||||||||||||
| 262 | 0 | _status_log("$results->{summary}\n"); | |||||||||||||||||||||||||||||||
| 263 | 0 | _error_log("$results->{summary}\n"); | |||||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||||||
| 265 | 0 | $Test->ok( $results->{passed}, "$results->{name} passed all tests" ); | |||||||||||||||||||||||||||||||
| 266 | } | ||||||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||||||
| 268 | 0 | ▶ | if ( $results->{passed} || $results->{skipped} ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$results->{"passed"} or $results->{"skipped"}
MC/DC0%0/2
$results->{"passed"} or $results->{"skipped"}
$results->{"passed"}
$results->{"skipped"}
Truth table0%0/3
A or B
A= $results->{"passed"}B= $results->{"skipped"}
| |||||||||||||||||||||||||||||||||
| 269 | 0 | _error_log("\n"); | |||||||||||||||||||||||||||||||
| 270 | } | ||||||||||||||||||||||||||||||||
| 271 | else { | ||||||||||||||||||||||||||||||||
| 272 | 0 | _error_log( q{-} x 50 ); | |||||||||||||||||||||||||||||||
| 273 | 0 | _error_log("\n"); | |||||||||||||||||||||||||||||||
| 274 | 0 | ▶ | _error_log("$results->{output}\n") if defined $results->{output}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 275 | 0 | ▶ | _error_log("$results->{stderr}\n") if defined $results->{stderr}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 276 | } | ||||||||||||||||||||||||||||||||
| 277 | } | ||||||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||||||
| 279 | { | ||||||||||||||||||||||||||||||||
| 280 | 1 | my %logs; | |||||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||||||
| 282 | sub _make_logs { | ||||||||||||||||||||||||||||||||
| 283 | 0 | ▶ | return if %logs; | ||||||||||||||||||||||||||||||
|
Subroutine
_make_logs: not called CC=5 SCAR=34.0
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||||||
| 285 | my $file_class = $ENV{PERL_TEST_DM_PROCESSES} | ||||||||||||||||||||||||||||||||
| 286 | 0 | ▶ | && $ENV{PERL_TEST_DM_PROCESSES} > 1 ? 'File::Locked' : 'File'; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$ENV{"PERL_TEST_DM_PROCESSES"} and $ENV{"PERL_TEST_DM_PROCESSES"} > 1
MC/DC0%0/2
$ENV{"PERL_TEST_DM_PROCESSES"} and $ENV{"PERL_TEST_DM_PROCESSES"} > 1
$ENV{"PERL_TEST_DM_PROCESSES"}
$ENV{"PERL_TEST_DM_PROCESSES"} > 1
Truth table0%0/3
A and B
A= $ENV{"PERL_TEST_DM_PROCESSES"}B= $ENV{"PERL_TEST_DM_PROCESSES"} > 1
| |||||||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||||||
| 288 | 0 | for my $type (qw( status error prereq )) { | |||||||||||||||||||||||||||||||
| 289 | 0 | $logs{$type} = Log::Dispatch->new( | |||||||||||||||||||||||||||||||
| 290 | outputs => [ | ||||||||||||||||||||||||||||||||
| 291 | [ | ||||||||||||||||||||||||||||||||
| 292 | $file_class, | ||||||||||||||||||||||||||||||||
| 293 | min_level => 'debug', | ||||||||||||||||||||||||||||||||
| 294 | filename => _log_filename($type), | ||||||||||||||||||||||||||||||||
| 295 | mode => 'append', | ||||||||||||||||||||||||||||||||
| 296 | ], | ||||||||||||||||||||||||||||||||
| 297 | ], | ||||||||||||||||||||||||||||||||
| 298 | ); | ||||||||||||||||||||||||||||||||
| 299 | } | ||||||||||||||||||||||||||||||||
| 300 | } | ||||||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||||||
| 302 | sub _status_log { | ||||||||||||||||||||||||||||||||
| 303 | 0 | ▶ | $logs{status}->info(@_); | ||||||||||||||||||||||||||||||
|
Subroutine
_status_log: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||
| 304 | } | ||||||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||||||
| 306 | sub _error_log { | ||||||||||||||||||||||||||||||||
| 307 | 0 | ▶ | $logs{error}->info(@_); | ||||||||||||||||||||||||||||||
|
Subroutine
_error_log: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||
| 308 | } | ||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||
| 310 | sub _prereq_log { | ||||||||||||||||||||||||||||||||
| 311 | 0 | ▶ | $logs{prereq}->info(@_); | ||||||||||||||||||||||||||||||
|
Subroutine
_prereq_log: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||
| 312 | } | ||||||||||||||||||||||||||||||||
| 313 | } | ||||||||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||||||
| 315 | 1 | sub _log_filename { | |||||||||||||||||||||||||||||||
| 316 | 0 | ▶ | my $type = shift; | ||||||||||||||||||||||||||||||
|
Subroutine
_log_filename: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||||||
| 318 | return File::Spec->devnull | ||||||||||||||||||||||||||||||||
| 319 | 0 | ▶ | unless $ENV{PERL_TEST_DM_LOG_DIR}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||||||
| 321 | return File::Spec->catfile( | ||||||||||||||||||||||||||||||||
| 322 | $ENV{PERL_TEST_DM_LOG_DIR}, | ||||||||||||||||||||||||||||||||
| 323 | 0 | 'test-mydeps-' . $$ . q{-} . $type . '.log' | |||||||||||||||||||||||||||||||
| 324 | ); | ||||||||||||||||||||||||||||||||
| 325 | } | ||||||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||||||
| 327 | sub _get_distro { | ||||||||||||||||||||||||||||||||
| 328 | 0 | ▶ | my $name = shift; | ||||||||||||||||||||||||||||||
|
Subroutine
_get_distro: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||||||
| 330 | 0 | my @mods = CPAN::Shell->expand( 'Module', $name ); | |||||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||||||
| 332 | 0 | ▶ | return unless @mods == 1; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||||||
| 334 | 0 | my $dist = $mods[0]->distribution; | |||||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||||||
| 336 | 0 | ▶ | return unless $dist; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||||||
| 338 | 0 | $dist->get; | |||||||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||||||
| 340 | 0 | return $dist; | |||||||||||||||||||||||||||||||
| 341 | } | ||||||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||||||
| 343 | sub _install_prereqs { | ||||||||||||||||||||||||||||||||
| 344 | 0 | ▶ | my $dist = shift; | ||||||||||||||||||||||||||||||
|
Subroutine
_install_prereqs: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||
| 345 | 0 | ▶ | my $root_dist = shift || $dist->base_id; | ||||||||||||||||||||||||||||||
|
Condition0%0/3
shift() || $dist->base_id
MC/DC0%0/2
shift() || $dist->base_id
shift()
$dist->base_id
Truth table0%0/3
A || B
A= shift()B= $dist->base_id
| |||||||||||||||||||||||||||||||||
| 346 | |||||||||||||||||||||||||||||||||
| 347 | 0 | my $install_dir = _temp_lib_dir(); | |||||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||||||
| 349 | ## no critic (Variables::RequireInitializationForLocalVars, Variables::ProhibitPackageVars) | ||||||||||||||||||||||||||||||||
| 350 | 0 | local $CPAN::Config->{makepl_arg} .= " INSTALL_BASE=$install_dir"; | |||||||||||||||||||||||||||||||
| 351 | local $CPAN::Config->{mbuild_install_arg} | ||||||||||||||||||||||||||||||||
| 352 | 0 | .= " --install_base $install_dir"; | |||||||||||||||||||||||||||||||
| 353 | ## use critic | ||||||||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||||||
| 355 | 0 | my $for_dist = $dist->base_id; | |||||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||||||
| 357 | 0 | for my $prereq ( $dist->unsat_prereq('configure_requires_later') ) { | |||||||||||||||||||||||||||||||
| 358 | 0 | _install_prereq( $prereq->[0], $for_dist, $root_dist ); | |||||||||||||||||||||||||||||||
| 359 | } | ||||||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||||||
| 361 | 0 | $dist->undelay; | |||||||||||||||||||||||||||||||
| 362 | 0 | $dist->make; | |||||||||||||||||||||||||||||||
| 363 | |||||||||||||||||||||||||||||||||
| 364 | 0 | for my $prereq ( $dist->unsat_prereq('later') ) { | |||||||||||||||||||||||||||||||
| 365 | 0 | _install_prereq( $prereq->[0], $for_dist, $root_dist ); | |||||||||||||||||||||||||||||||
| 366 | } | ||||||||||||||||||||||||||||||||
| 367 | |||||||||||||||||||||||||||||||||
| 368 | 0 | $dist->undelay; | |||||||||||||||||||||||||||||||
| 369 | } | ||||||||||||||||||||||||||||||||
| 370 | |||||||||||||||||||||||||||||||||
| 371 | sub _install_prereq { | ||||||||||||||||||||||||||||||||
| 372 | 0 | ▶ | my $prereq = shift; | ||||||||||||||||||||||||||||||
|
Subroutine
_install_prereq: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||
| 373 | 0 | my $for_dist = shift; | |||||||||||||||||||||||||||||||
| 374 | 0 | my $root_dist = shift; | |||||||||||||||||||||||||||||||
| 375 | |||||||||||||||||||||||||||||||||
| 376 | 0 | ▶ | return if $prereq eq 'perl'; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 377 | |||||||||||||||||||||||||||||||||
| 378 | 0 | my $for = "for $for_dist"; | |||||||||||||||||||||||||||||||
| 379 | 0 | ▶ | if ( $for_dist ne $root_dist ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 380 | 0 | $for .= " (started with $root_dist)"; | |||||||||||||||||||||||||||||||
| 381 | } | ||||||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||||||
| 383 | 0 | my $dist = _get_distro($prereq); | |||||||||||||||||||||||||||||||
| 384 | 0 | ▶ | if ( !$dist ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 385 | 0 | _prereq_log("Couldn't find $prereq $for\n"); | |||||||||||||||||||||||||||||||
| 386 | 0 | next; | |||||||||||||||||||||||||||||||
| 387 | } | ||||||||||||||||||||||||||||||||
| 388 | |||||||||||||||||||||||||||||||||
| 389 | 0 | _install_prereqs( $dist, $root_dist ); | |||||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||||||
| 391 | 0 | my $installing = $dist->base_id; | |||||||||||||||||||||||||||||||
| 392 | |||||||||||||||||||||||||||||||||
| 393 | 0 | _prereq_log("Installing $installing $for\n"); | |||||||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||||||
| 395 | try { | ||||||||||||||||||||||||||||||||
| 396 | 0 | ▶ | $dist->notest; | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||
| 397 | 0 | $dist->install; | |||||||||||||||||||||||||||||||
| 398 | } | ||||||||||||||||||||||||||||||||
| 399 | catch { | ||||||||||||||||||||||||||||||||
| 400 | 0 | ▶ | die "Installing $installing for $for_dist failed: $_"; | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||
| 401 | 0 | }; | |||||||||||||||||||||||||||||||
| 402 | } | ||||||||||||||||||||||||||||||||
| 403 | |||||||||||||||||||||||||||||||||
| 404 | { | ||||||||||||||||||||||||||||||||
| 405 | 1 | my $Dir; | |||||||||||||||||||||||||||||||
| 406 | 1 | ▶ | BEGIN { $Dir = tempdir( CLEANUP => 1 ); } | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 407 | |||||||||||||||||||||||||||||||||
| 408 | sub _temp_lib_dir { | ||||||||||||||||||||||||||||||||
| 409 | 1 | ▶ | return $Dir; | ||||||||||||||||||||||||||||||
|
Subroutine
_temp_lib_dir: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 410 | } | ||||||||||||||||||||||||||||||||
| 411 | } | ||||||||||||||||||||||||||||||||
| 412 | |||||||||||||||||||||||||||||||||
| 413 | 1 | sub _run_tests_for_dir { | |||||||||||||||||||||||||||||||
| 414 | 7 | ▶ | my $dir = shift; | ||||||||||||||||||||||||||||||
|
Subroutine
_run_tests_for_dir: called CC=4 SCAR=14.0
| |||||||||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||||||
| 416 | 7 | local $CWD = $dir; | |||||||||||||||||||||||||||||||
| 417 | |||||||||||||||||||||||||||||||||
| 418 | 7 | ▶ | if ( -e 'Build.PL' ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 419 | return | ||||||||||||||||||||||||||||||||
| 420 | 4 | ▶ | unless _run_commands( | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 421 | ['./Build'], | ||||||||||||||||||||||||||||||||
| 422 | ); | ||||||||||||||||||||||||||||||||
| 423 | } | ||||||||||||||||||||||||||||||||
| 424 | else { | ||||||||||||||||||||||||||||||||
| 425 | return | ||||||||||||||||||||||||||||||||
| 426 | 3 | ▶ | unless _run_commands( | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 427 | ['make'], | ||||||||||||||||||||||||||||||||
| 428 | ); | ||||||||||||||||||||||||||||||||
| 429 | } | ||||||||||||||||||||||||||||||||
| 430 | |||||||||||||||||||||||||||||||||
| 431 | 7 | return _run_tests(); | |||||||||||||||||||||||||||||||
| 432 | } | ||||||||||||||||||||||||||||||||
| 433 | |||||||||||||||||||||||||||||||||
| 434 | sub _run_commands { | ||||||||||||||||||||||||||||||||
| 435 | 7 | ▶ | for my $cmd (@_) { | ||||||||||||||||||||||||||||||
|
Subroutine
_run_commands: called CC=3 SCAR=11.8
| |||||||||||||||||||||||||||||||||
| 436 | 7 | my $output; | |||||||||||||||||||||||||||||||
| 437 | |||||||||||||||||||||||||||||||||
| 438 | my $success = try { | ||||||||||||||||||||||||||||||||
| 439 | 7 | ▶ | run3( $cmd, \undef, \$output, \$output ); | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 440 | } | ||||||||||||||||||||||||||||||||
| 441 | catch { | ||||||||||||||||||||||||||||||||
| 442 | 0 | ▶ | $output .= "Couldn't run @$cmd: $_"; | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||
| 443 | 0 | return; | |||||||||||||||||||||||||||||||
| 444 | 7 | }; | |||||||||||||||||||||||||||||||
| 445 | |||||||||||||||||||||||||||||||||
| 446 | 7 | ▶ | return ( 0, $output ) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 447 | unless $success; | ||||||||||||||||||||||||||||||||
| 448 | } | ||||||||||||||||||||||||||||||||
| 449 | |||||||||||||||||||||||||||||||||
| 450 | 7 | return 1; | |||||||||||||||||||||||||||||||
| 451 | } | ||||||||||||||||||||||||||||||||
| 452 | |||||||||||||||||||||||||||||||||
| 453 | sub _run_tests { | ||||||||||||||||||||||||||||||||
| 454 | 7 | ▶ | my $output = q{}; | ||||||||||||||||||||||||||||||
|
Subroutine
_run_tests: called CC=3 SCAR=11.3
| |||||||||||||||||||||||||||||||||
| 455 | 7 | my $error = q{}; | |||||||||||||||||||||||||||||||
| 456 | |||||||||||||||||||||||||||||||||
| 457 | my $stderr = sub { | ||||||||||||||||||||||||||||||||
| 458 | 6 | ▶ | my $line = shift; | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 459 | |||||||||||||||||||||||||||||||||
| 460 | 6 | $output .= $line; | |||||||||||||||||||||||||||||||
| 461 | 6 | $error .= $line; | |||||||||||||||||||||||||||||||
| 462 | 7 | }; | |||||||||||||||||||||||||||||||
| 463 | |||||||||||||||||||||||||||||||||
| 464 | 7 | my $cmd; | |||||||||||||||||||||||||||||||
| 465 | 7 | ▶ | if ( -e 'Build' ) { | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||
| 466 | 4 | $cmd = [qw( ./Build test )]; | |||||||||||||||||||||||||||||||
| 467 | } | ||||||||||||||||||||||||||||||||
| 468 | elsif ( -e 'Makefile' ) { | ||||||||||||||||||||||||||||||||
| 469 | 3 | $cmd = [qw( make test )]; | |||||||||||||||||||||||||||||||
| 470 | } | ||||||||||||||||||||||||||||||||
| 471 | else { | ||||||||||||||||||||||||||||||||
| 472 | 0 | return ( 0, "Cannot find a Build or Makefile file in $CWD" ); | |||||||||||||||||||||||||||||||
| 473 | } | ||||||||||||||||||||||||||||||||
| 474 | |||||||||||||||||||||||||||||||||
| 475 | 7 | my $passed; | |||||||||||||||||||||||||||||||
| 476 | try { | ||||||||||||||||||||||||||||||||
| 477 | 7 | ▶ | run3( $cmd, undef, \$output, $stderr ); | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.4
| |||||||||||||||||||||||||||||||||
| 478 | 7 | ▶ | if ( $? == 0 ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 479 | 6 | ▶ | $passed = $output eq q{} | ||||||||||||||||||||||||||||||
|
Condition33%1/3
$output eq '' || $output =~ /Result: (?:PASS|NOTESTS)|No tests defined/
MC/DC0%0/2
$output eq '' || $output =~ /Result: (?:PASS|NOTESTS)|No tests defined/
$output eq ''
$output =~ /Result: (?:PASS|NOTESTS)|No tests defined/
Truth table33%1/3
A || B
A= $output eq ''B= $output =~ /Result: (?:PASS|NOTESTS)|No tests defined/
| |||||||||||||||||||||||||||||||||
| 480 | || $output =~ /Result: (?:PASS|NOTESTS)|No tests defined/; | ||||||||||||||||||||||||||||||||
| 481 | } | ||||||||||||||||||||||||||||||||
| 482 | } | ||||||||||||||||||||||||||||||||
| 483 | catch { | ||||||||||||||||||||||||||||||||
| 484 | 0 | ▶ | $output .= "Couldn't run @$cmd: $_"; | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||
| 485 | 0 | $error .= "Couldn't run @$cmd: $_"; | |||||||||||||||||||||||||||||||
| 486 | 7 | }; | |||||||||||||||||||||||||||||||
| 487 | |||||||||||||||||||||||||||||||||
| 488 | 7 | return ( $passed, $output, $error ); | |||||||||||||||||||||||||||||||
| 489 | } | ||||||||||||||||||||||||||||||||
| 490 | |||||||||||||||||||||||||||||||||
| 491 | { | ||||||||||||||||||||||||||||||||
| 492 | 1 | my $LOADED_CPAN = 0; | |||||||||||||||||||||||||||||||
| 493 | |||||||||||||||||||||||||||||||||
| 494 | sub _load_cpan { | ||||||||||||||||||||||||||||||||
| 495 | ## no critic (TestingAndDebugging::ProhibitNoWarnings) | ||||||||||||||||||||||||||||||||
| 496 | 1 | ▶ | no warnings 'once'; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 497 | 0 | ▶ | return if $LOADED_CPAN; | ||||||||||||||||||||||||||||||
|
Subroutine
_load_cpan: not called CC=3 SCAR=22.6
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 498 | |||||||||||||||||||||||||||||||||
| 499 | 0 | require CPAN; | |||||||||||||||||||||||||||||||
| 500 | 0 | require CPAN::Shell; | |||||||||||||||||||||||||||||||
| 501 | |||||||||||||||||||||||||||||||||
| 502 | ## no critic (InputOutput::RequireBriefOpen) | ||||||||||||||||||||||||||||||||
| 503 | 0 | open my $fh, '>', File::Spec->devnull; | |||||||||||||||||||||||||||||||
| 504 | |||||||||||||||||||||||||||||||||
| 505 | { | ||||||||||||||||||||||||||||||||
| 506 | 1 | ▶ | no warnings 'redefine'; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.2
| |||||||||||||||||||||||||||||||||
| 507 | 0 | ▶ | *CPAN::Shell::report_fh = sub {$fh}; | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||
| 508 | } | ||||||||||||||||||||||||||||||||
| 509 | |||||||||||||||||||||||||||||||||
| 510 | ## no critic (Variables::ProhibitPackageVars) | ||||||||||||||||||||||||||||||||
| 511 | 0 | $CPAN::Be_Silent = 1; | |||||||||||||||||||||||||||||||
| 512 | |||||||||||||||||||||||||||||||||
| 513 | 0 | CPAN::HandleConfig->load; | |||||||||||||||||||||||||||||||
| 514 | 0 | CPAN::Shell::setup_output(); | |||||||||||||||||||||||||||||||
| 515 | 0 | CPAN::Index->reload('force'); | |||||||||||||||||||||||||||||||
| 516 | |||||||||||||||||||||||||||||||||
| 517 | 0 | $CPAN::Config->{test_report} = 0; | |||||||||||||||||||||||||||||||
| 518 | 0 | $CPAN::Config->{mbuildpl_arg} .= ' --quiet'; | |||||||||||||||||||||||||||||||
| 519 | 0 | $CPAN::Config->{prerequisites_policy} = 'follow'; | |||||||||||||||||||||||||||||||
| 520 | 0 | $CPAN::Config->{make_install_make_command} =~ s/^sudo //; | |||||||||||||||||||||||||||||||
| 521 | 0 | $CPAN::Config->{mbuild_install_build_command} =~ s/^sudo //; | |||||||||||||||||||||||||||||||
| 522 | 0 | $CPAN::Config->{make_install_arg} =~ s/UNINST=1//; | |||||||||||||||||||||||||||||||
| 523 | 0 | $CPAN::Config->{mbuild_install_arg} =~ s/--uninst\s+1//; | |||||||||||||||||||||||||||||||
| 524 | |||||||||||||||||||||||||||||||||
| 525 | 0 | ▶ | if ( $ENV{PERL_TEST_DM_CPAN_VERBOSE} ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 526 | 0 | ▶ | $fh = io_from_write_cb( sub { $Test->diag( $_[0] ) } ); | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||
| 527 | } | ||||||||||||||||||||||||||||||||
| 528 | |||||||||||||||||||||||||||||||||
| 529 | 0 | $LOADED_CPAN = 1; | |||||||||||||||||||||||||||||||
| 530 | |||||||||||||||||||||||||||||||||
| 531 | 0 | return; | |||||||||||||||||||||||||||||||
| 532 | } | ||||||||||||||||||||||||||||||||
| 533 | } | ||||||||||||||||||||||||||||||||
| 534 | |||||||||||||||||||||||||||||||||
| 535 | 1 | 1; | |||||||||||||||||||||||||||||||
| 536 | |||||||||||||||||||||||||||||||||
| 537 | # ABSTRACT: Test all modules which depend on your module | ||||||||||||||||||||||||||||||||
| 538 | |||||||||||||||||||||||||||||||||
| 539 | __END__ | ||||||||||||||||||||||||||||||||
| 540 | |||||||||||||||||||||||||||||||||
| 541 | =pod | ||||||||||||||||||||||||||||||||
| 542 | |||||||||||||||||||||||||||||||||
| 543 | =head1 NAME | ||||||||||||||||||||||||||||||||
| 544 | |||||||||||||||||||||||||||||||||
| 545 | Test::DependentModules - Test all modules which depend on your module | ||||||||||||||||||||||||||||||||
| 546 | |||||||||||||||||||||||||||||||||
| 547 | =head1 VERSION | ||||||||||||||||||||||||||||||||
| 548 | |||||||||||||||||||||||||||||||||
| 549 | version 0.26 | ||||||||||||||||||||||||||||||||
| 550 | |||||||||||||||||||||||||||||||||
| 551 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||
| 552 | |||||||||||||||||||||||||||||||||
| 553 | use Test::DependentModules qw( test_all_dependents ); | ||||||||||||||||||||||||||||||||
| 554 | |||||||||||||||||||||||||||||||||
| 555 | test_all_dependents('My::Module'); | ||||||||||||||||||||||||||||||||
| 556 | |||||||||||||||||||||||||||||||||
| 557 | # or ... | ||||||||||||||||||||||||||||||||
| 558 | |||||||||||||||||||||||||||||||||
| 559 | use Test::DependentModules qw( test_module ); | ||||||||||||||||||||||||||||||||
| 560 | use Test::More tests => 3; | ||||||||||||||||||||||||||||||||
| 561 | |||||||||||||||||||||||||||||||||
| 562 | test_module('Exception::Class'); | ||||||||||||||||||||||||||||||||
| 563 | test_module('DateTime'); | ||||||||||||||||||||||||||||||||
| 564 | test_module('Log::Dispatch'); | ||||||||||||||||||||||||||||||||
| 565 | |||||||||||||||||||||||||||||||||
| 566 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||
| 567 | |||||||||||||||||||||||||||||||||
| 568 | B<WARNING>: The tests this module does should B<never> be included as part of | ||||||||||||||||||||||||||||||||
| 569 | a normal CPAN install! | ||||||||||||||||||||||||||||||||
| 570 | |||||||||||||||||||||||||||||||||
| 571 | This module is intended as a tool for module authors who would like to easily | ||||||||||||||||||||||||||||||||
| 572 | test that a module release will not break dependencies. This is particularly | ||||||||||||||||||||||||||||||||
| 573 | useful for module authors (like myself) who have modules which are a | ||||||||||||||||||||||||||||||||
| 574 | dependency of many other modules. | ||||||||||||||||||||||||||||||||
| 575 | |||||||||||||||||||||||||||||||||
| 576 | =head2 How It Works | ||||||||||||||||||||||||||||||||
| 577 | |||||||||||||||||||||||||||||||||
| 578 | Internally, this module will download dependencies from CPAN and run their | ||||||||||||||||||||||||||||||||
| 579 | tests. If those dependencies in turn have unsatisfied dependencies, they are | ||||||||||||||||||||||||||||||||
| 580 | installed into a temporary directory. These second-level (and third-, etc) | ||||||||||||||||||||||||||||||||
| 581 | dependencies are I<not> tested. | ||||||||||||||||||||||||||||||||
| 582 | |||||||||||||||||||||||||||||||||
| 583 | In order to avoid prompting, this module sets C<$ENV{PERL_AUTOINSTALL}> to | ||||||||||||||||||||||||||||||||
| 584 | C<--defaultdeps> and sets C<$ENV{PERL_MM_USE_DEFAULT}> to a true value. | ||||||||||||||||||||||||||||||||
| 585 | |||||||||||||||||||||||||||||||||
| 586 | Nonetheless, some ill-behaved modules will I<still> wait for a | ||||||||||||||||||||||||||||||||
| 587 | prompt. Unfortunately, because of the way this module attempts to keep output | ||||||||||||||||||||||||||||||||
| 588 | to a minimum, you won't see these prompts. Patches are welcome. | ||||||||||||||||||||||||||||||||
| 589 | |||||||||||||||||||||||||||||||||
| 590 | =head2 Running Tests in Parallel | ||||||||||||||||||||||||||||||||
| 591 | |||||||||||||||||||||||||||||||||
| 592 | If you're testing a lot of modules, you might benefit from running tests in | ||||||||||||||||||||||||||||||||
| 593 | parallel. You'll need to have L<Parallel::ForkManager> installed for this to | ||||||||||||||||||||||||||||||||
| 594 | work. | ||||||||||||||||||||||||||||||||
| 595 | |||||||||||||||||||||||||||||||||
| 596 | Set the C<$ENV{PERL_TEST_DM_PROCESSES}> env var to a value greater than 1 to | ||||||||||||||||||||||||||||||||
| 597 | enable parallel testing. | ||||||||||||||||||||||||||||||||
| 598 | |||||||||||||||||||||||||||||||||
| 599 | =head1 FUNCTIONS | ||||||||||||||||||||||||||||||||
| 600 | |||||||||||||||||||||||||||||||||
| 601 | This module optionally exports three functions: | ||||||||||||||||||||||||||||||||
| 602 | |||||||||||||||||||||||||||||||||
| 603 | =head2 test_all_dependents( $module, { filter => sub { ... } } ) | ||||||||||||||||||||||||||||||||
| 604 | |||||||||||||||||||||||||||||||||
| 605 | Given a module name, this function uses L<MetaCPAN::Client> to find all its | ||||||||||||||||||||||||||||||||
| 606 | dependencies and test them. It will set a test plan for you. | ||||||||||||||||||||||||||||||||
| 607 | |||||||||||||||||||||||||||||||||
| 608 | If you provide a C<filter> sub, it will be called with a single argument, the | ||||||||||||||||||||||||||||||||
| 609 | I<distribution name>, which will be something like "Test-DependentModules" | ||||||||||||||||||||||||||||||||
| 610 | (note the lack of colons). The filter should return a true or false value to | ||||||||||||||||||||||||||||||||
| 611 | indicate whether or not to test that distribution. | ||||||||||||||||||||||||||||||||
| 612 | |||||||||||||||||||||||||||||||||
| 613 | If you don't provide a filter, you can provide a regex to use by passing an | ||||||||||||||||||||||||||||||||
| 614 | C<exclude> key in the hashref. Anything that matches the regex is excluded. | ||||||||||||||||||||||||||||||||
| 615 | |||||||||||||||||||||||||||||||||
| 616 | Additionally, any distribution name starting with "Task" or "Bundle" is always | ||||||||||||||||||||||||||||||||
| 617 | excluded. | ||||||||||||||||||||||||||||||||
| 618 | |||||||||||||||||||||||||||||||||
| 619 | =head2 test_modules(@names) | ||||||||||||||||||||||||||||||||
| 620 | |||||||||||||||||||||||||||||||||
| 621 | Given a list of module names, this function will test them all. You can use | ||||||||||||||||||||||||||||||||
| 622 | this if you'd prefer to hard code a list of modules to test. | ||||||||||||||||||||||||||||||||
| 623 | |||||||||||||||||||||||||||||||||
| 624 | In this case, you will have to handle your own test planning. | ||||||||||||||||||||||||||||||||
| 625 | |||||||||||||||||||||||||||||||||
| 626 | =head2 test_module($name) | ||||||||||||||||||||||||||||||||
| 627 | |||||||||||||||||||||||||||||||||
| 628 | B<DEPRECATED>. Use the C<test_modules()> sub instead, so you can run | ||||||||||||||||||||||||||||||||
| 629 | optionally run tests in parallel. | ||||||||||||||||||||||||||||||||
| 630 | |||||||||||||||||||||||||||||||||
| 631 | Given a module name, this function will test it. You can use this if you'd | ||||||||||||||||||||||||||||||||
| 632 | prefer to hard code a list of modules to test. | ||||||||||||||||||||||||||||||||
| 633 | |||||||||||||||||||||||||||||||||
| 634 | In this case, you will have to handle your own test planning. | ||||||||||||||||||||||||||||||||
| 635 | |||||||||||||||||||||||||||||||||
| 636 | =head1 PERL5LIB FOR DEPENDENCIES | ||||||||||||||||||||||||||||||||
| 637 | |||||||||||||||||||||||||||||||||
| 638 | If you want to include a module-to-be-released in the path seen by | ||||||||||||||||||||||||||||||||
| 639 | dependencies, you must make sure that the correct path ends up in | ||||||||||||||||||||||||||||||||
| 640 | C<$ENV{PERL5LIB}>. If you use C<prove -l> or C<prove -b> to run tests, then | ||||||||||||||||||||||||||||||||
| 641 | that will happen automatically. | ||||||||||||||||||||||||||||||||
| 642 | |||||||||||||||||||||||||||||||||
| 643 | =head1 WARNINGS, LOGGING AND VERBOSITY | ||||||||||||||||||||||||||||||||
| 644 | |||||||||||||||||||||||||||||||||
| 645 | By default, this module attempts to quiet down CPAN and the module building | ||||||||||||||||||||||||||||||||
| 646 | toolchain as much as possible. However, when there are test failures in a | ||||||||||||||||||||||||||||||||
| 647 | dependency it's nice to see the output. | ||||||||||||||||||||||||||||||||
| 648 | |||||||||||||||||||||||||||||||||
| 649 | In addition, if the tests spit out warnings but still pass, this will just be | ||||||||||||||||||||||||||||||||
| 650 | treated as a pass. | ||||||||||||||||||||||||||||||||
| 651 | |||||||||||||||||||||||||||||||||
| 652 | If you enable logging, this module log all successes, warnings, and failures, | ||||||||||||||||||||||||||||||||
| 653 | along with the full output of the test suite for each dependency. In addition, | ||||||||||||||||||||||||||||||||
| 654 | it logs what prereqs it installs, since you may want to install some of them | ||||||||||||||||||||||||||||||||
| 655 | permanently to speed up future tests. | ||||||||||||||||||||||||||||||||
| 656 | |||||||||||||||||||||||||||||||||
| 657 | To enable logging, you must provide a directory to which log files will be | ||||||||||||||||||||||||||||||||
| 658 | written. The log file names are of the form C<test-my-deps-$$-$type.log>, | ||||||||||||||||||||||||||||||||
| 659 | where C<$type> is one of "status", "error", or "prereq". | ||||||||||||||||||||||||||||||||
| 660 | |||||||||||||||||||||||||||||||||
| 661 | The directory should be provided in C<$ENV{PERL_TEST_DM_LOG_DIR}>. The | ||||||||||||||||||||||||||||||||
| 662 | directory must already exist. | ||||||||||||||||||||||||||||||||
| 663 | |||||||||||||||||||||||||||||||||
| 664 | You also can enable CPAN's output by setting the | ||||||||||||||||||||||||||||||||
| 665 | C<$ENV{PERL_TEST_DM_CPAN_VERBOSE}> variable to a true value. | ||||||||||||||||||||||||||||||||
| 666 | |||||||||||||||||||||||||||||||||
| 667 | =head1 BUGS | ||||||||||||||||||||||||||||||||
| 668 | |||||||||||||||||||||||||||||||||
| 669 | Please report any bugs or feature requests to C<bug-test-mydeps@rt.cpan.org>, | ||||||||||||||||||||||||||||||||
| 670 | or through the web interface at L<http://rt.cpan.org>. I will be notified, | ||||||||||||||||||||||||||||||||
| 671 | and then you'll automatically be notified of progress on your bug as I make | ||||||||||||||||||||||||||||||||
| 672 | changes. | ||||||||||||||||||||||||||||||||
| 673 | |||||||||||||||||||||||||||||||||
| 674 | =head1 DONATIONS | ||||||||||||||||||||||||||||||||
| 675 | |||||||||||||||||||||||||||||||||
| 676 | If you'd like to thank me for the work I've done on this module, please | ||||||||||||||||||||||||||||||||
| 677 | consider making a "donation" to me via PayPal. I spend a lot of free time | ||||||||||||||||||||||||||||||||
| 678 | creating free software, and would appreciate any support you'd care to offer. | ||||||||||||||||||||||||||||||||
| 679 | |||||||||||||||||||||||||||||||||
| 680 | Please note that B<I am not suggesting that you must do this> in order for me | ||||||||||||||||||||||||||||||||
| 681 | to continue working on this particular software. I will continue to do so, | ||||||||||||||||||||||||||||||||
| 682 | inasmuch as I have in the past, for as long as it interests me. | ||||||||||||||||||||||||||||||||
| 683 | |||||||||||||||||||||||||||||||||
| 684 | Similarly, a donation made in this way will probably not make me work on this | ||||||||||||||||||||||||||||||||
| 685 | software much more, unless I get so many donations that I can consider working | ||||||||||||||||||||||||||||||||
| 686 | on free software full time, which seems unlikely at best. | ||||||||||||||||||||||||||||||||
| 687 | |||||||||||||||||||||||||||||||||
| 688 | To donate, log into PayPal and send money to autarch@urth.org or use the | ||||||||||||||||||||||||||||||||
| 689 | button on this page: L<http://www.urth.org/~autarch/fs-donation.html> | ||||||||||||||||||||||||||||||||
| 690 | |||||||||||||||||||||||||||||||||
| 691 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||
| 692 | |||||||||||||||||||||||||||||||||
| 693 | Dave Rolsky <autarch@urth.org> | ||||||||||||||||||||||||||||||||
| 694 | |||||||||||||||||||||||||||||||||
| 695 | =head1 CONTRIBUTORS | ||||||||||||||||||||||||||||||||
| 696 | |||||||||||||||||||||||||||||||||
| 697 | =for stopwords Graham Knop Jesse Luehrs mickey Sawyer X | ||||||||||||||||||||||||||||||||
| 698 | |||||||||||||||||||||||||||||||||
| 699 | =over 4 | ||||||||||||||||||||||||||||||||
| 700 | |||||||||||||||||||||||||||||||||
| 701 | =item * | ||||||||||||||||||||||||||||||||
| 702 | |||||||||||||||||||||||||||||||||
| 703 | Graham Knop <haarg@haarg.org> | ||||||||||||||||||||||||||||||||
| 704 | |||||||||||||||||||||||||||||||||
| 705 | =item * | ||||||||||||||||||||||||||||||||
| 706 | |||||||||||||||||||||||||||||||||
| 707 | Jesse Luehrs <doy@tozt.net> | ||||||||||||||||||||||||||||||||
| 708 | |||||||||||||||||||||||||||||||||
| 709 | =item * | ||||||||||||||||||||||||||||||||
| 710 | |||||||||||||||||||||||||||||||||
| 711 | mickey <mickey75@gmail.com> | ||||||||||||||||||||||||||||||||
| 712 | |||||||||||||||||||||||||||||||||
| 713 | =item * | ||||||||||||||||||||||||||||||||
| 714 | |||||||||||||||||||||||||||||||||
| 715 | Sawyer X <xsawyerx@cpan.org> | ||||||||||||||||||||||||||||||||
| 716 | |||||||||||||||||||||||||||||||||
| 717 | =back | ||||||||||||||||||||||||||||||||
| 718 | |||||||||||||||||||||||||||||||||
| 719 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||||||||||||||
| 720 | |||||||||||||||||||||||||||||||||
| 721 | This software is Copyright (c) 2015 by Dave Rolsky. | ||||||||||||||||||||||||||||||||
| 722 | |||||||||||||||||||||||||||||||||
| 723 | This is free software, licensed under: | ||||||||||||||||||||||||||||||||
| 724 | |||||||||||||||||||||||||||||||||
| 725 | The Artistic License 2.0 (GPL Compatible) | ||||||||||||||||||||||||||||||||
| 726 | |||||||||||||||||||||||||||||||||
| 727 | =cut | ||||||||||||||||||||||||||||||||