[Apache-dispatch-devel] SF.net SVN: apache-dispatch: [50] trunk
Brought to you by:
geoffrey_young,
phred_moyer
|
From: <phr...@us...> - 2006-08-02 04:47:53
|
Revision: 50 Author: phred_moyer Date: 2006-08-01 21:47:49 -0700 (Tue, 01 Aug 2006) ViewCVS: http://svn.sourceforge.net/apache-dispatch/?rev=50&view=rev Log Message: ----------- - Test style adaptation from WebService::CaptchasDotNet - Added a use lib 'lib' pragma to the Makefile.PL so it can find Apache::Dispatch::Util locally - Updated tests so that they successfully skip if Apache::Test is not installed - Added package Apache::Dispatch::TestConfig to hold common eval code for tests Modified Paths: -------------- trunk/MANIFEST trunk/Makefile.PL trunk/t/01plain.t trunk/t/02extras.t trunk/t/03filter.t trunk/t/04oo.t Added Paths: ----------- trunk/lib/Apache/Dispatch/TestConfig.pm Modified: trunk/MANIFEST =================================================================== --- trunk/MANIFEST 2006-08-02 03:33:26 UTC (rev 49) +++ trunk/MANIFEST 2006-08-02 04:47:49 UTC (rev 50) @@ -8,6 +8,7 @@ set_pureperl.PL lib/Apache/Dispatch.pm lib/Apache/Dispatch/Util.pm +lib/Apache/Dispatch/TestConfig.pm lib/Apache2/Dispatch.pm t/lib/Apache/Bar.pm t/lib/Apache/Foo.pm @@ -22,3 +23,4 @@ t/04oo.t t/conf/extra.last.conf.in t/TEST.PL +META.yml Module meta-data (added by MakeMaker) Modified: trunk/Makefile.PL =================================================================== --- trunk/Makefile.PL 2006-08-02 03:33:26 UTC (rev 49) +++ trunk/Makefile.PL 2006-08-02 04:47:49 UTC (rev 50) @@ -4,6 +4,11 @@ use strict; +use lib 'lib'; + +use Apache::Dispatch::Util; +use ExtUtils::MakeMaker; + use constant HAS_APACHE_TEST => eval { require Apache::Test; require Apache::TestMM; @@ -14,10 +19,10 @@ my %args = @Apache::TestMM::Argv; die 'suitable httpd required' - unless ( $args{apxs} - or $args{httpd} - or $ENV{APACHE_TEST_HTTPD} - or $ENV{APACHE_TEST_APXS}); + unless ( $args{apxs} + or $args{httpd} + or $ENV{APACHE_TEST_HTTPD} + or $ENV{APACHE_TEST_APXS} ); Apache::TestMM::generate_script('t/TEST'); @@ -37,7 +42,7 @@ return HAS_APACHE_TEST if HAS_APACHE_TEST; - if (eval { require Devel::Cover }) { + if ( eval { require Devel::Cover } ) { $test .= <<EOF; testcover :: cover -delete @@ -61,24 +66,23 @@ } ## which mp version ( 1.2x or 2.0.x) -my ($mp_wanted, $mp_ver) = &get_mp_ver(); +my ( $mp_wanted, $mp_ver ) = &get_mp_ver(); print STDERR "Using mod_perl/$mp_ver\n\n"; -my %prereq = ('Apache::Test' => "1.23"); +my %prereq = ( 'Apache::Test' => "1.23" ); -my %makefile_params = ('VERSION' => '0.10',); +my %makefile_params = ( 'VERSION' => '0.10', ); -if ($mp_wanted == 2) { # mod_perl2 specific makefile +if ( $mp_wanted == 2 ) { # mod_perl2 specific makefile $prereq{'mod_perl2'} = 1.99023; # this covers the naming change $makefile_params{'NAME'} = 'Apache2::Dispatch'; $makefile_params{'PREREQ_PM'} = \%prereq; - require ModPerl::MM; - ModPerl::MM::WriteMakefile(%makefile_params); + WriteMakefile(%makefile_params); } -elsif ($mp_wanted != 2) { # mod_perl1 specific makefile +elsif ( $mp_wanted != 2 ) { # mod_perl1 specific makefile eval { require Apache::ExtUtils; require Apache::src; @@ -87,11 +91,11 @@ # Build directives using xs or PerlSetVar my $pureperl; - if ($@ || $ENV{DISPATCH_PUREPERL}) { + if ( $@ || $ENV{DISPATCH_PUREPERL} ) { print "Building without Custom Apache Directives, use 'PerlSetVar' for configuration.\n\n"; - $makefile_params{'PL_FILES'} = {'set_pureperl.PL' => '1'}; + $makefile_params{'PL_FILES'} = { 'set_pureperl.PL' => '1' }; $makefile_params{'C'} = []; } @@ -99,25 +103,23 @@ print "Building with Custom Apache Directives ('DispatchPrefix'). You will need a C compiler and Apache/mod_perl sources.\n\n"; - $makefile_params{'PL_FILES'} = {'set_pureperl.PL' => '0'}; - $makefile_params{'clean'} = {FILES => '*.xs*'}; + $makefile_params{'PL_FILES'} = { 'set_pureperl.PL' => '0' }; + $makefile_params{'clean'} = { FILES => '*.xs*' }; import Apache::ExtUtils qw(command_table); - require Apache::Dispatch::Util; my @directives = Apache::Dispatch::Util->directives(); - command_table(\@directives); + command_table( \@directives ); my $inc = Apache::src->new->inc; die "Can't find mod_perl header files installed" unless $inc; $makefile_params{'INC'} = $inc; } - $makefile_params{'PREREQ_PM'} = {mod_perl => 1.2401}; - require ExtUtils::MakeMaker; - ExtUtils::MakeMaker::WriteMakefile( - NAME => __PACKAGE__, - PREREQ_PM => \%prereq, - %makefile_params, - ); + $makefile_params{'PREREQ_PM'} = { mod_perl => 1.2401 }; + WriteMakefile( + NAME => __PACKAGE__, + PREREQ_PM => \%prereq, + %makefile_params, + ); } # The next sub inspired by Apache::Peek 1.05 @@ -127,8 +129,8 @@ my $flag = 0; my @args = (); - while (my $arg = shift @ARGV) { - if ($arg =~ /^MOD_PERL=([12])$/) { + while ( my $arg = shift @ARGV ) { + if ( $arg =~ /^MOD_PERL=([12])$/ ) { $flag = $1; } else { @@ -141,7 +143,7 @@ my $env = exists $ENV{MOD_PERL} ? $ENV{MOD_PERL} : 0; # check for contradicting requirements - if ($env && $flag && $flag != $env) { + if ( $env && $flag && $flag != $env ) { die <<EOF; Can\'t decide which mod_perl version should be used, since you have supplied contradicting requirements: @@ -155,10 +157,10 @@ my $mp_ver; - if ($wanted == 2) { + if ( $wanted == 2 ) { eval { require mod_perl2 }; my $req_ver = 1.999022; - if ($mod_perl2::VERSION < $req_ver || $@) { + if ( $mod_perl2::VERSION < $req_ver || $@ ) { die "mod_perl2 required version is $req_ver, you have $mod_perl2::VERSION. Please upgrade to continue."; } @@ -169,7 +171,7 @@ else { eval { require mod_perl }; no warnings qw(uninitialized); - if ($mod_perl::VERSION > 1.99 || $@) { + if ( $mod_perl::VERSION > 1.99 || $@ ) { die "You don't seem to have mod_perl 1.0 installed"; } else { @@ -177,6 +179,6 @@ } } - return ($wanted, $mp_ver); + return ( $wanted, $mp_ver ); } Added: trunk/lib/Apache/Dispatch/TestConfig.pm =================================================================== --- trunk/lib/Apache/Dispatch/TestConfig.pm (rev 0) +++ trunk/lib/Apache/Dispatch/TestConfig.pm 2006-08-02 04:47:49 UTC (rev 50) @@ -0,0 +1,19 @@ +package Apache::Dispatch::TestConfig; + +use strict; +use warnings FATAL => 'all'; + +our $HAS_APACHE_TEST = eval { + require Apache::Test; + Apache::Test->import(qw(have_lwp)); + + Apache::TestRequest->import(qw(GET_BODY_ASSERT)); + + require Apache::TestUtil; + Apache::TestUtil->import(qw(t_write_perl_script)); + + require Apache::TestServer; + return Apache::TestServer->new->{config}->{vars}->{httpd}; +}; + +1; \ No newline at end of file Property changes on: trunk/lib/Apache/Dispatch/TestConfig.pm ___________________________________________________________________ Name: svn:eol-style + native Modified: trunk/t/01plain.t =================================================================== --- trunk/t/01plain.t 2006-08-02 03:33:26 UTC (rev 49) +++ trunk/t/01plain.t 2006-08-02 04:47:49 UTC (rev 50) @@ -1,11 +1,17 @@ use strict; use warnings FATAL => 'all'; -use Apache::Test; -use Apache::TestRequest; +use Apache::Dispatch::TestConfig; +use Test::More; -plan tests => 4, \&need_lwp; +plan skip_all => 'Apache::Test not configured' + unless $Apache::Dispatch::TestConfig::HAS_APACHE_TEST; +plan skip_all => 'test library dependencies not met' + unless eval { have_lwp() }; + +plan tests => 4; + # Test Apache2::Foo->dispatch_index my $uri = '/plain'; ok GET_OK $uri; @@ -14,7 +20,7 @@ $uri = '/plain/foo'; ok GET_OK $uri; -# Test non-usage of Apache2::Foo::Bar->dispatch_index since +# Test non-usage of Apache2::Foo::Bar->dispatch_index since # Apache2::Foo->dispatch_bar does not exist $uri = '/plain/bar'; my $res = GET $uri; Modified: trunk/t/02extras.t =================================================================== --- trunk/t/02extras.t 2006-08-02 03:33:26 UTC (rev 49) +++ trunk/t/02extras.t 2006-08-02 04:47:49 UTC (rev 50) @@ -1,11 +1,17 @@ use strict; use warnings FATAL => 'all'; -use Apache::Test; -use Apache::TestRequest; +use Apache::Dispatch::TestConfig; +use Test::More; -plan tests => 5;#, \&need_lwp; +plan skip_all => 'Apache::Test not configured' + unless $Apache::Dispatch::TestConfig::HAS_APACHE_TEST; +plan skip_all => 'test library dependencies not met' + unless eval { have_lwp() }; + +plan tests => 5; + my $uri = '/extras'; my $res = GET $uri; ok $res->code == 200; Modified: trunk/t/03filter.t =================================================================== --- trunk/t/03filter.t 2006-08-02 03:33:26 UTC (rev 49) +++ trunk/t/03filter.t 2006-08-02 04:47:49 UTC (rev 50) @@ -1,9 +1,15 @@ use strict; use warnings FATAL => 'all'; -use Apache::Test qw(-withtestmore); -use Apache::TestRequest; +use Apache::Dispatch::TestConfig; +use Test::More; +plan skip_all => 'Apache::Test not configured' + unless $Apache::Dispatch::TestConfig::HAS_APACHE_TEST; + +plan skip_all => 'test library dependencies not met' + unless eval { have_lwp() }; + # figure out what version we have - I don't like this method but it works my $httpd = Apache::Test::vars('httpd'); my $version = `$httpd -v`; @@ -12,7 +18,7 @@ plan skip_all => "Filtering not yet implemented in Apache2::Dispatch"; } else { - plan tests => 2, \&need_lwp; + plan tests => 2; } my $url = '/filtered/foo'; Modified: trunk/t/04oo.t =================================================================== --- trunk/t/04oo.t 2006-08-02 03:33:26 UTC (rev 49) +++ trunk/t/04oo.t 2006-08-02 04:47:49 UTC (rev 50) @@ -1,11 +1,17 @@ use strict; use warnings FATAL => 'all'; -use Apache::Test qw(-withtestmore); -use Apache::TestRequest; +use Apache::Dispatch::TestConfig; +use Test::More; -plan tests => 2, \&need_lwp; +plan skip_all => 'Apache::Test not configured' + unless $Apache::Dispatch::TestConfig::HAS_APACHE_TEST; +plan skip_all => 'test library dependencies not met' + unless eval { have_lwp() }; + +plan tests => 2; + my $url = '/oo/baz'; my $res = GET $url; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |