From: Dave Rolsky Date: Fri, 3 Jul 2009 15:22:13 +0000 (-0500) Subject: Run tests with prove under run3 so we can capture the output. Then X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=f3b33ea9db4645f24a53fe03095611eb1a9e49e3;p=gitmo%2Fmoose-dev-utils.git Run tests with prove under run3 so we can capture the output. Then analyze the output for warnings, pass, and fail. --- 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 ); +} +