# soak: Test Devel::PPPort with multiple versions of Perl. # # Author: Paul Marquess # require 5.006001; use strict ; use warnings ; use ExtUtils::MakeMaker; use Getopt::Long; my $VERSION = "1.000"; $| = 1 ; my $verbose = 0 ; # TODO -- determine what "make" program to run. my $MAKE = 'make'; my $result = GetOptions( "verbose" => \$verbose, "make=s" => \$MAKE, ) or Usage(); my @GoodPerls = (); if (@ARGV) { @GoodPerls = @ARGV } else { @GoodPerls = FindPerls() } my $maxlen = 0; foreach (@GoodPerls) { $maxlen = length $_ if length $_ > $maxlen ; } $maxlen += 3 ; # run each through the test harness my $bad = 0 ; my $good = 0 ; my $total = 0 ; # prime the pump, so the first "make clean" will work. runit("perl Makefile.PL") || die "Cannot run perl Makefile.PL\n" ; foreach my $perl (@GoodPerls) { my $prefix = "$perl -- " if $verbose ; print "Testing $perl " . ('.' x ($maxlen - length $perl)) ; my $ok = runit("$MAKE clean") && runit("$perl Makefile.PL") && runit("$MAKE test") ; ++ $total; if ($ok) { ++ $good ; print "${prefix}ok\n"; } else { ++ $bad ; print "${prefix}not ok\n" ; } } print "\n\nPassed with $good of $total versions of Perl.\n\n"; exit $bad ; sub runit { # TODO -- portability alert!! my $cmd = shift ; print "\n Running [$cmd]\n" if $verbose ; my $output = `$cmd 2>&1` ; $output = "\n" unless defined $output; $output =~ s/^/ /gm; print "\n Output\n$output\n" if $verbose || $? ; if ($?) { warn " Running '$cmd' failed: $?\n" ; return 0 ; } return 1 ; } sub Usage { die <new( { NAME => 'dummy' }); my @path = $mm->path(); # find_perl will send a warning to STDOUT if it can't find # the requested perl, so need to temporarily silence STDOUT. tie(*STDOUT, 'NoSTDOUT'); foreach my $perl (@PerlBinaries) { if (my $abs = $mm->find_perl($perl, ["perl$perl"], [@path], 0)) { push @GoodPerls, $abs ; } } untie *STDOUT; print "\n\nFound\n"; foreach (@GoodPerls) { print " $_\n" } print "\n\n"; return @GoodPerls; } package NoSTDOUT; use Tie::Handle; our @ISA = qw(Tie::Handle); sub TIEHANDLE { my ($class) = @_; my $buf = ""; bless \$buf, $class; } sub PRINT { my $self = shift; } sub WRITE { my $self = shift; }