use Cwd;
use File::chdir;
use File::Path qw( rmtree );
+use IPC::Run3 qw( run3 );
CPAN::HandleConfig->load();
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";
+ }
}
}
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 );
+}
+