Run tests with prove under run3 so we can capture the output. Then
[gitmo/moose-dev-utils.git] / cpan-stable-smolder
index 9ef4fd5..7c647ac 100755 (executable)
@@ -6,6 +6,7 @@ use CPAN;
 use Cwd;
 use File::chdir;
 use File::Path qw( rmtree );
+use IPC::Run3 qw( run3 );
 
 
 CPAN::HandleConfig->load();
@@ -105,7 +106,9 @@ test_all_modules(
         MooseX::WithCache
         MooseX::Workers
         MooseX::YAML
-        Fey-ORM
+        Fey::ORM
+        KiokuDB
+        Catalyst
         ]
 );
 
@@ -113,6 +116,44 @@ 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";
+            next;
+        }
+
+        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";
+    }
+
+    if (@details) {
+        print {$log} "\n\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";
+        }
+    }
+}
+
 sub get_distro_from_cpan {
     my $project = shift;
 
@@ -138,30 +179,45 @@ sub test_module {
     local $CWD = $dir;
 
     local $ENV{PERL_AUTOINSTALL} = '--defaultdeps';
-    if ( -f "Makefile.PL" ) {
-        return ! system $^X . ' Makefile.PL && make && make test';
+    if ( -f "Build.PL" ) {
+        return
+            unless _run_commands(
+            [ $^X, 'Build.PL' ],
+            ['./Build'],
+            );
     }
     else {
-        return ! system $^X . ' Build.PL && ./Build && ./Build test';
+        return
+            unless _run_commands(
+            [ $^X, 'Makefile.PL' ],
+            ['make'],
+            );
     }
+
+    return _run_tests();
 }
 
-sub test_all_modules {
-    foreach my $project (@_) {
-        my $dist = get_distro_from_cpan($project);
+sub _run_commands {
+    for my $cmd (@_) {
+        my $output;
 
-        unless ($dist) {
-            print $log "UNKNOWN : $project (not on CPAN?)\n";
-            next;
+        unless ( run3 $cmd, \undef, \$output, \$output ) {
+            warn "Failed to run @{$cmd}\n";
+            return ( 0, $output );
         }
+    }
 
-        my $passed = test_module( $dist->dir() );
+    return 1;
+}
 
-        my $msg = $passed ? 'SUCCESS' : 'FAIL';
+sub _run_tests {
+    my $output;
 
-        print $log sprintf( '%7s : %s - %s', $msg, $project, $dist->base_id() );
-        print $log "\n";
-    }
+    run3 [ qw( prove -b ) ], undef, \$output, \$output;
+
+    my $passed = $output =~ /Result: PASS/;
+    my $warned = $output =~ /at .+ line \d+/;
+
+    return ( $passed, $warned, $output );
 }
 
-1;