Just in case you didn't know, you can use Apache::Test for testing your code with both mod_perl generations. It certainly helps to automate the testing. For example I use the following simple smoker script to run the test suite on Apache::Peek with different versions of perl and mod_perl.

Kudos to Barrie Slaymaker for the wonderful IPC::Run.

BTW, Philippe has a more advanced smoker (with much better reporting) but he won't let it to see the light before he makes it perfect ;)

For more info on Apache-Test see Geoff's article:
http://www.perl.com/pub/a/2003/05/22/testing.html
and the online manual:
http://perl.apache.org/docs/general/testing/testing.html

--

#!/usr/bin/perl

use strict;
use warnings;

use IPC::Run qw(run timeout);

use constant TIMEOUT => 5*60;
use constant DEBUG   => 0;

$SIG{INT} = sub { report(); exit; };

my %report = (ok => 0, nok => 0, failed => {});
my $test = 0;
while (<DATA>) {
    next if /^\s*(#.*|$)/;
    chomp;
    run_test($_);
}

report();

sub run_test {
    my $command = shift;
    my @cmds = split /\s*&&\s*/, $command;
    $test++;
    my $cnt = 0;
    my $failed = 0;
    for my $cmd (@cmds) {
        next unless $cmd =~ /\S/;
        $cnt++;
        print "[$test.$cnt] $cmd\n";
        my @cmd = split /\s+/, $cmd;
        my($in, $out, $err);
        my $ok = 0;
        eval {
            $ok = run [EMAIL PROTECTED], \$in, \$out, \$err,
                debug => DEBUG, timeout(TIMEOUT);
        };
        warn "[EMAIL PROTECTED]" if $@;
        $ok = 1 if $cmd =~ /make clean/; # ignore 'make clean' errors
        unless ($ok) {
            print "\n\tFAILURE!\n\n";
            print "STDOUT:\n$out\n" if $out;
            print "STDERR:\n$err\n" if $err;
            push @{ $report{failed}{$command} }, "($cnt) $cmd";
            $failed++;
            last;
        }
        if (@cmd == 2 && $cmd[0] eq 'make' && $cmd[1] eq 'test') {
            my $result = $out =~ /All tests successful/ ? "OK" : "NOT OK";
            print "\n\t$result\n\n";
        }
    }

    $failed ? $report{nok}++ : $report{ok}++;
    print "\n", "-" x 40, "\n\n";
}

sub report {
    my $format = "%-7s: %3d\n";
    printf $format, "Success", $report{ok};
    printf $format, "Failure", $report{nok};
    print "-" x 16, "\n";
    printf $format, "Total", $report{ok}+$report{nok};

    my @failed = keys %{ $report{failed} };
    if (@failed) {
        print join "\n", '',
            "Failed commands:", "-" x 16,
            map { join("\n\t", $_, @{ $report{failed}{$_}||[] }),"\n"} @failed;
    }
}

__DATA__
# need to test all these combinations

### mp2 DSO ###

make clean && /usr/bin/env CCFLAGS="-g" perl-5.6.1 Makefile.PL -httpd /home/stas/httpd/prefork/bin/httpd -libmodperl /home/stas/httpd/prefork/modules/mod_perl-5.6.1.so -port select MOD_PERL=2 && make && make test

make clean && /usr/bin/env CCFLAGS="-g" perl-5.8.0 Makefile.PL -httpd /home/stas/httpd/prefork/bin/httpd -libmodperl mod_perl-5.8.0.so -port select MOD_PERL=2 && make && make test

make clean && /usr/bin/env CCFLAGS="-g" perl-5.8.0-ithread Makefile.PL -httpd /home/stas/httpd/prefork/bin/httpd -libmodperl mod_perl-5.8.0-ithread.so -port select MOD_PERL=2 && make && make test

make clean && /usr/bin/env CCFLAGS="-g" perl-5.8.1 Makefile.PL -httpd /home/stas/httpd/prefork/bin/httpd -libmodperl mod_perl-5.8.1.so -port select MOD_PERL=2 && make && make test

make clean && /usr/bin/env CCFLAGS="-g" perl-5.8.1-ithread Makefile.PL -httpd /home/stas/httpd/prefork/bin/httpd -libmodperl mod_perl-5.8.1-ithread.so -port select MOD_PERL=2 && make && make test

make clean && /usr/bin/env CCFLAGS="-g" perl-blead Makefile.PL -httpd /home/stas/httpd/prefork/bin/httpd -libmodperl mod_perl-blead.so -port select MOD_PERL=2 && make && make test

make clean && /usr/bin/env CCFLAGS="-g" perl-blead-ithread Makefile.PL -httpd /home/stas/httpd/prefork/bin/httpd -libmodperl mod_perl-blead-ithread.so -port select MOD_PERL=2 && make && make test

### worker 2.0 ###

make clean && /usr/bin/env CCFLAGS="-g" perl-5.8.1-ithread Makefile.PL -httpd /home/stas/httpd/worker/bin/httpd -libmodperl mod_perl-5.8.1-ithread.so -port select MOD_PERL=2 && make && make test

### mp1 NON-DSO ###

#ok
make clean && /usr/bin/env CCFLAGS="-g" perl-5.00503 Makefile.PL -httpd /home/httpd/httpd_perl/bin/httpd-5.00503 -port select MOD_PERL=1 && make && make test


#ok
make clean && /usr/bin/env CCFLAGS="-g" perl-5.6.1-ithread Makefile.PL -httpd /home/httpd/httpd_perl/bin/httpd-5.6.1-ithread -port select MOD_PERL=1 && make && make test


#ok
make clean && /usr/bin/env CCFLAGS="-g" perl-5.6.1 Makefile.PL -httpd /home/httpd/httpd_perl/bin/httpd-5.6.1 -port select MOD_PERL=1 && make && make test


#ok
make clean && /usr/bin/env CCFLAGS="-g" perl-5.8.0-ithread Makefile.PL -httpd /home/httpd/httpd_perl/bin/httpd-5.8.0-ithread -port select MOD_PERL=1 && make && make test


#ok
make clean && /usr/bin/env CCFLAGS="-g" perl-5.8.0 Makefile.PL -httpd /home/httpd/httpd_perl/bin/httpd-5.8.0 -port select MOD_PERL=1 && make && make test



#ok
make clean && /usr/bin/env CCFLAGS="-g" perl-5.8.1-ithread Makefile.PL -httpd /home/httpd/httpd_perl/bin/httpd-5.8.1-ithread -port select MOD_PERL=1 && make && make test


#ok
make clean && /usr/bin/env CCFLAGS="-g" perl-5.8.1 Makefile.PL -httpd /home/httpd/httpd_perl/bin/httpd-5.8.1 -port select MOD_PERL=1 && make && make test


#ok
make clean && /usr/bin/env CCFLAGS="-g" perl-blead-ithread Makefile.PL -httpd /home/httpd/httpd_perl/bin/httpd-blead-ithread -port select MOD_PERL=1 && make && make test


#ok
make clean && /usr/bin/env CCFLAGS="-g" perl-blead Makefile.PL -httpd /home/httpd/httpd_perl/bin/httpd-blead -port select MOD_PERL=1 && make && make test


__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com



Reply via email to