my( $totals, $failed ) = eval {
local @INC = @INC;
local *STDOUT; # Shut up Test::Harness!
local *STDERR; # Yeah, you too!
my $MM = ExtUtils::MM->new(); # and you!
unshift @INC, map { File::Spec->rel2abs($_) }
@{ $MM }{ qw( INST_LIB INST_ARCHLIB ) };
Test::Harness::_run_all_tests( @test_files )
};
####
find ~/Dev -name Makefile.PL | perl -pe 's|/Makefile.PL$||' | xargs daily_build > daily.txt
####
#!/usr/bin/perl -sw
use strict;
use ExtUtils::MM;
use File::Spec;
use File::Spec::Functions qw(catfile);
use Test::Harness;
use Test::Manifest;
our( %Missing, $v );
foreach my $arg ( @ARGV )
{
print "$arg ... ";
print "\n" if $v;
# # # # # # # # # # # # # # # # # # # # #
do{ message( "Could not change to [$arg]: $!" ); next }
unless chdir $arg;
do{ message( "There is no Makefile.PL! Skipping." ); next }
unless -e "Makefile.PL";
# # # # # # # # # # # # # # # # # # # # #
my @output = run_makefile_pl();
# # # # # # # # # # # # # # # # # # # # #
if( my @missing = find_missing_prereqs( @output ) )
{
message( "Prerequisites not found! Skipping." );
if( $v )
{
message( "\t\t" . join "\n\t\t", @missing );
@Missing{ @missing } = (1) x @missing;
}
next;
}
# # # # # # # # # # # # # # # # # # # # #
@output = run_make();
# # # # # # # # # # # # # # # # # # # # #
my @test_files = get_test_files();
# # # # # # # # # # # # # # # # # # # # #
unless( @test_files )
{
message( "Found no test files! Skipping." );
next;
}
# # # # # # # # # # # # # # # # # # # # #
message( "Found tests ==> " . join " ", @test_files, "\n" ) if $v;
open STDERR, ">> /dev/null";
message( "Testing ==> " ) if $v;
my( $totals, $failed ) = test_files( @test_files );
unless( defined $totals and defined $failed )
{
message( "Could not even run tests." );
next;
}
# # # # # # # # # # # # # # # # # # # # #
if( keys %$failed )
{
my( $max, $fail, $string ) = ( 0, 0, '' );
foreach my $key ( keys %$failed )
{
my $hash = $failed->{$key};
if( $hash->{failed} > $hash->{max} )
{
$hash->{failed} = $hash->{max}
}
$string .= sprintf "\t\t%-20s failed %d/%d ( %3d%% )\n",
$key, @{ $hash }{ qw( failed max percent ) };
$max += $hash->{max};
$fail += $hash->{failed};
}
message( sprintf "%d/%d ( %3.1f%% ) failed",
$fail, $max, $fail / $max * 100 );
message( $string ) if $v;
}
else
{
message( "No tests failed" );
}
}
# # # # # # # # # # # # # # # # # # # # #
if( $v and keys %Missing )
{
print "-" x 73, "\n", "Missing modules\n";
print join "\n\t", sort keys %Missing;
print "\n\n";
}
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
sub message
{
chomp( my $message = shift );
print "\t" if $v;
print "$message\n";
}
sub get_test_files
{
my @files = do {
if( -e Test::Manifest::manifest_name() )
{
Test::Manifest::get_t_files()
}
else
{
find_all_t_files();
}
};
}
sub find_all_t_files { glob "t/*.t" }
sub run_makefile_pl { `perl Makefile.PL 2>&1`; }
sub run_make { `make 2>&1`; }
sub find_missing_prereqs
{
my @output = shift;
my %missing = ();
if( grep { m/not found/ } @output )
{
chomp @output;
%missing = map { s/^W.*ite\s+|\s+[\d._]* not found.$//g; $_, 1 }
grep { m/not found/ } @output;
}
return ( keys %missing );
}
sub test_files
{
my @test_files = @_;
eval {
local @INC = @INC;
local *STDOUT; # Shut up Test::Harness!
local *STDERR; # Yeah, you too!
my $MM = ExtUtils::MM->new(); # and you!
unshift @INC, map { File::Spec->rel2abs($_) }
@{ $MM }{ qw( INST_LIB INST_ARCHLIB ) };
Test::Harness::_run_all_tests( @test_files )
}
}