2 ################################################################################
4 # soak -- Test Perl modules with multiple Perl releases.
6 # Original Author: Paul Marquess
8 ################################################################################
12 # $Date: 2006/05/22 20:26:02 +0200 $
14 ################################################################################
16 # Version 3.x, Copyright (C) 2004-2006, Marcus Holland-Moritz.
17 # Version 2.x, Copyright (C) 2001, Paul Marquess.
18 # Version 1.x, Copyright (C) 1999, Kenneth Albanowski.
20 # This program is free software; you can redistribute it and/or
21 # modify it under the same terms as Perl itself.
23 ################################################################################
29 use ExtUtils::MakeMaker;
33 use List::Util qw(max);
36 my $VERSION = do { my @r = '$Snapshot: /Devel-PPPort/3.08_05 $' =~ /(\d+\.\d+(?:_\d+)?)/; @r ? $r[0] : '9.99' };
40 my $MAKE = $Config{make} || 'make';
43 make => $Config{make} || 'make',
47 GetOptions(\%OPT, qw(verbose make=s min=s mmargs=s@)) or pod2usage(2);
49 $OPT{mmargs} = [''] unless exists $OPT{mmargs};
50 $OPT{min} = parse_version($OPT{min}) - 1e-10;
52 my @GoodPerls = map { $_->[0] }
53 sort { $a->[1] <=> $b->[1] or $a->[0] cmp $b->[0] }
54 grep { $_->[1] >= $OPT{min} }
55 map { [$_ => perl_version($_)] }
56 @ARGV ? SearchPerls(@ARGV) : FindPerls();
59 print "Sorry, got no Perl binaries for testing.\n\n";
63 my $maxlen = max(map length, @GoodPerls) + 3;
64 my $mmalen = max(map length, @{$OPT{mmargs}});
65 $maxlen += $mmalen+3 if $mmalen > 0;
67 # run each through the test harness
68 my(@good, @bad, $total);
70 # prime the pump, so the first "make realclean" will work.
71 runit("$^X Makefile.PL") && runit("$MAKE realclean")
72 or die "Cannot run $^X Makefile.PL && $MAKE realclean\n";
74 print "Testing ", scalar @GoodPerls, " versions/configurations...\n\n";
76 for my $perl (@GoodPerls) {
77 for my $mm (@{$OPT{mmargs}}) {
78 my $config = $mm =~ /\S+/ ? " ($mm)" : '';
79 my $prefix = $verbose ? "$perl$config -- " : '';
80 print "Testing $perl$config " . ('.' x ($maxlen - length($perl.$config)));
82 my $ok = runit("$perl Makefile.PL $mm") &&
83 # runit("$perl Makefile.PL --with-apicheck") &&
88 push @good, [$perl, $mm];
89 print "${prefix}ok\n";
92 push @bad, [$perl, $mm];
93 print "${prefix}not ok\n";
96 runit("$MAKE realclean");
101 print "\nFailed with:\n";
102 for my $fail (@bad) {
103 my($perl, $mm) = @$fail;
104 my $config = $mm =~ /\S+/ ? " ($mm)" : '';
105 print " $perl$config\n";
109 print "\nPassed with ", scalar @good, " of $total versions/configurations.\n\n";
114 # TODO -- portability alert!!
117 print "\n Running [$cmd]\n" if $verbose;
118 my $output = `$cmd 2>&1`;
119 $output = "\n" unless defined $output;
121 print "\n Output\n$output\n" if $verbose || $?;
123 warn " Running '$cmd' failed: $?\n";
131 # TODO -- need to decide how far back we go.
132 # TODO -- get list of user releases prior to 5.004
133 # TODO -- does not work on Windows (at least)
135 # find versions of Perl that are available
136 my @PerlBinaries = qw(
141 5.004 5.00401 5.00402 5.00403 5.00404 5.00405
142 5.005 5.00501 5.00502 5.00503 5.00504
144 5.7.0 5.7.1 5.7.2 5.7.3
145 5.8.0 5.8.1 5.8.2 5.8.3 5.8.4 5.8.5 5.8.6
149 print "Searching for Perl binaries...\n";
150 my $mm = MM->new( { NAME => 'dummy' });
151 my @path = $mm->path;
154 # find_perl will send a warning to STDOUT if it can't find
155 # the requested perl, so need to temporarily silence STDOUT.
156 tie *STDOUT, 'NoSTDOUT';
158 for my $perl (@PerlBinaries) {
159 if (my $abs = $mm->find_perl($perl, ["perl$perl"], \@path, 0)) {
160 push @GoodPerls, $abs;
166 print "\nFound:\n", (map " $_\n", @GoodPerls), "\n";
176 for my $arg (@args) {
179 print "Searching for Perl binaries in '$arg'...\n";
181 $File::Find::name =~ m!perl5[\w._]+$!
182 and -f $File::Find::name
183 and -x $File::Find::name
184 and perl_version($File::Find::name)
185 and push @found, $File::Find::name;
187 printf "Found %d Perl binar%s in '%s'.\n\n", scalar @found, @found == 1 ? 'y' : 'ies', $arg;
201 my $ver = `$perl -e 'print \$]' 2>&1`;
202 return $? == 0 && $ver >= 5 ? $ver : 0;
209 if ($ver =~ /^(\d+)\.(\d+)\.(\d+)$/) {
210 return $1 + 1e-3*$2 + 1e-6*$3;
212 elsif ($ver =~ /^\d+\.[\d_]+$/) {
217 die "cannot parse version '$ver'\n";
223 our @ISA = qw(Tie::Handle);
225 sub TIEHANDLE { bless \(my $s = ''), shift }
233 soak - Test Perl modules with multiple Perl releases
237 soak [options] [perl ...]
239 --make=program override name of make program ($Config{make})
240 --min=version use at least this version of perl
241 --mmargs=options pass options to Makefile.PL (multiple --mmargs possible)
246 Version 3.x, Copyright (c) 2004-2006, Marcus Holland-Moritz.
248 Version 2.x, Copyright (C) 2001, Paul Marquess.
250 Version 1.x, Copyright (C) 1999, Kenneth Albanowski.
252 This program is free software; you can redistribute it and/or
253 modify it under the same terms as Perl itself.
257 See L<Devel::PPPort>.