X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=gitmo%2Fmoose-dev-utils.git;a=blobdiff_plain;f=cpan-stable-smolder;h=7c647ac3aa579a650f582c0d27ffc5398ebcda76;hp=18daa3296ed89887dd5c7fbbdda593782bf9d163;hb=f3b33ea9db4645f24a53fe03095611eb1a9e49e3;hpb=ec985a7b4fa6d27117020e427d0f462152791186 diff --git a/cpan-stable-smolder b/cpan-stable-smolder index 18daa32..7c647ac 100755 --- a/cpan-stable-smolder +++ b/cpan-stable-smolder @@ -6,6 +6,7 @@ use CPAN; use Cwd; use File::chdir; use File::Path qw( rmtree ); +use IPC::Run3 qw( run3 ); CPAN::HandleConfig->load(); @@ -116,20 +117,40 @@ close $log; exit; sub test_all_modules { + my @statuses; + my @details; + foreach my $project (@_) { my $dist = get_distro_from_cpan($project); unless ($dist) { - print $log "UNKNOWN : $project (not on CPAN?)\n"; + print {$log} "UNKNOWN : $project (not on CPAN?)\n"; next; } - my $passed = test_module( $dist->dir() ); + my ( $passed, $warned, $output ) = test_module( $dist->dir() ); + + my $status = $passed && $warned ? 'WARN' : $passed ? 'PASS' : 'FAIL'; + + push @statuses, "$status: $project - " . $dist->base_id(); + + push @details, [ $project, $output ] + if $warned || ! $passed; + } + + for my $status (@statuses) { + print {$log} "$status\n"; + } - my $msg = $passed ? 'SUCCESS' : 'FAIL'; + if (@details) { + print {$log} "\n\n"; - print $log sprintf( '%7s : %s - %s', $msg, $project, $dist->base_id() ); - print $log "\n"; + for my $detail (@details) { + print {$log} q{-} x 50; + print {$log} "\n"; + print {$log} "$detail->[0]\n\n"; + print {$log} "$detail->[1]\n\n"; + } } } @@ -159,30 +180,44 @@ sub test_module { local $ENV{PERL_AUTOINSTALL} = '--defaultdeps'; if ( -f "Build.PL" ) { - _run_commands( + return + unless _run_commands( [ $^X, 'Build.PL' ], ['./Build'], - [qw( ./Build test )], - ); + ); } else { - _run_commands( + return + unless _run_commands( [ $^X, 'Makefile.PL' ], ['make'], - [qw( make test )], - ); + ); } + + return _run_tests(); } sub _run_commands { for my $cmd (@_) { - if ( system( @{$cmd} ) ) { + my $output; + + unless ( run3 $cmd, \undef, \$output, \$output ) { warn "Failed to run @{$cmd}\n"; - return; + return ( 0, $output ); } } return 1; } -1; +sub _run_tests { + my $output; + + run3 [ qw( prove -b ) ], undef, \$output, \$output; + + my $passed = $output =~ /Result: PASS/; + my $warned = $output =~ /at .+ line \d+/; + + return ( $passed, $warned, $output ); +} +