httpd-test-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stas Bekman <s...@stason.org>
Subject Re: Test::More server support redux
Date Thu, 05 Aug 2004 17:47:47 GMT
Geoffrey Young wrote:
> hi all...
> 
> michael schwern is very close to releasing Test::More 0.49, which is the
> first version of Test::More that we can use as the server-backend for
> Apache::Test.
> 
> I would like to integrate the Test::More foo into A-T as soon as 0.49 comes
> out.  so, if you are interested in Test::More support and have some free
> tuits, I would appreciate some feedback on the work I have thus far.
> 
> the first thing to do is download the latest Test::More
> 
> http://search.cpan.org/CPAN/authors/id/M/MS/MSCHWERN/Test-Simple-0.48_02.tar.gz
> 
> which schwern said is really the release candidate for 0.49.
> 
> then, apply the attached patch and let me know how the tests turn out.
> really, I know that the Apache/Test.pm patch works, so if you have test
> failures it is more likely due to the test setup itself - I didn't want to
> move from Apache::TestRun to Apache::TestRunPerl so I needed to set up some
> of the mod_perl specific things myself.  hopefully I got most of them right :)
> 
> the tests pass successfully for me for apache 1.3 and 2.0, both with and
> without mod_perl installed (well, they don't run with without mod_perl but
> they don't implode either ;)
> 
> anyway, as I've mentioned before, I've been using Test::More as the backend
> for a while now on a corporate project and it rocks, so I'm excited to port
> it over when 0.49 is official.  feedback welcome.

No time for this now, but if it works for you go ahead with it.

> +Note that I<Test::Builder> 0.18_01, available in I<Test::Simple>
> +version 0.48_01 on CPAN, is required to use this feature.

drop that, as 2 copies of the same thing in different places will go out 
of sync at some point. check on the code level should be sufficient. 
instead the error message could say where to find the required version.

one day we will move to Module::Build/Module::Install and have required 
vs recommended lists, so this issue will become moot for CPANPLUS users.

> +Because I<Apache:Test> was initially developed using I<Test> as
> +the framework driver, complete I<Test::More> integration is
> +considered experimental at this time - it is supported as best as
> +possible but is not guaranteed to be as stable as the default I<Test>
> +interface at this time.
>  
>  =head1 Apache::TestToString Class
>  
> Index: lib/Apache/TestHarness.pm
> ===================================================================
> RCS file: /home/cvs/httpd-test/perl-framework/Apache-Test/lib/Apache/TestHarness.pm,v
> retrieving revision 1.18
> diff -u -r1.18 TestHarness.pm
> --- lib/Apache/TestHarness.pm	4 Mar 2004 05:51:31 -0000	1.18
> +++ lib/Apache/TestHarness.pm	5 Aug 2004 14:20:06 -0000
> @@ -63,8 +63,13 @@
>  sub run_t {
>      my($self, $file) = @_;
>      my $ran = 0;
> -    my $lib = catfile Apache::Test::vars('top_dir'), qw(Apache-Test lib);
> -    my $cmd = qq[$^X -Mlib="$lib" $file];
> +    # so we can find Apache/Test.pm from both the perl-framework
> +    # and Apache-Test.  note that IS_APACHE_TEST_BUILD returns
> +    # true for the perl-framework as well
> +    my $lib = join ':',
> +        catfile(Apache::Test::vars('top_dir'), qw(Apache-Test lib)),
> +        catfile(Apache::Test::vars('top_dir'), 'lib');
> +    my $cmd = qq[PERL5LIB="$lib" $^X $file];

why this change? is there anything wrong with -Mlib? PERL5LIB will be 
ignored under -T -- code will be broken.

>      my $h = Symbol::gensym();
>      open $h, "$cmd|" or die "open $cmd: $!";
> Index: t/conf/extra.conf.in
> ===================================================================
> RCS file: /home/cvs/httpd-test/perl-framework/Apache-Test/t/conf/extra.conf.in,v
> retrieving revision 1.3
> diff -u -r1.3 extra.conf.in
> --- t/conf/extra.conf.in	27 Jun 2004 18:38:57 -0000	1.3
> +++ t/conf/extra.conf.in	5 Aug 2004 14:20:06 -0000
> @@ -4,3 +4,31 @@
>  <IfModule mod_alias.c>
>    Redirect /redirect http://@ServerName@/redirected/
>  </IfModule>
> +
> +<IfModule mod_perl.c>
> +  <IfDefine APACHE2>
> +    PerlModule Apache2
> +  </IfDefine>

why not put the stuff below into extra.last.conf.in. Apache2 will be 
loaded by then. It's better not to mess with Apache2 before times.

> +  <Location /TestMore__testpm>
> +    SetHandler perl-script
> +    <IfDefine APACHE2>
> +      PerlResponseHandler TestMore::testpm
> +    </IfDefine>
> +    <IfDefine APACHE1>
> +      PerlHandler TestMore::testpm
> +    </IfDefine>
> +  </Location>
> +
> +  <Location /TestMore__testmorepm>
> +    SetHandler perl-script
> +    <IfDefine APACHE2>
> +      PerlResponseHandler TestMore::testmorepm
> +    </IfDefine>
> +    <IfDefine APACHE1>
> +      PerlHandler TestMore::testmorepm
> +    </IfDefine>
> +  </Location>
> +</IfModule>
> +
> +

> --- /dev/null	2003-09-15 06:40:47.000000000 -0700
> +++ t/more/01testpm.t	2004-08-05 07:17:22.000000000 -0700

> @@ -0,0 +1,8 @@
> +# see the description in t/more/all.t
> +
> +use strict;
> +use warnings FATAL => qw(all);
> +
> +use Apache::TestRequest 'GET_BODY_ASSERT';
> +print GET_BODY_ASSERT "/TestMore__testpm";
> +
> 
> --- /dev/null	2003-09-15 06:40:47.000000000 -0700
> +++ t/more/02testmore.t	2004-08-05 07:17:27.000000000 -0700
> @@ -0,0 +1,8 @@
> +# see the description in t/more/all.t
> +
> +use strict;
> +use warnings FATAL => qw(all);
> +
> +use Apache::TestRequest 'GET_BODY_ASSERT';
> +print GET_BODY_ASSERT "/TestMore__testmorepm";
> +
> 
> --- /dev/null	2003-09-15 06:40:47.000000000 -0700
> +++ t/more/03testpm.t	2004-08-05 07:17:31.000000000 -0700
> @@ -0,0 +1,8 @@
> +# see the description in t/more/all.t
> +
> +use strict;
> +use warnings FATAL => qw(all);
> +
> +use Apache::TestRequest 'GET_BODY_ASSERT';
> +print GET_BODY_ASSERT "/TestMore__testpm";
> +
> 
> --- /dev/null	2003-09-15 06:40:47.000000000 -0700
> +++ t/more/04testmore.t	2004-08-05 07:17:35.000000000 -0700
> @@ -0,0 +1,8 @@
> +# see the description in t/more/all.t
> +
> +use strict;
> +use warnings FATAL => qw(all);
> +
> +use Apache::TestRequest 'GET_BODY_ASSERT';
> +print GET_BODY_ASSERT "/TestMore__testmorepm";

hmm, what are you trying to achieve with repeating two tests twice? what 
if you don't hit the same interpreter if that's what you are after? It's 
probably better to use 1 test and run the same_interprter framework?

> --- /dev/null	2003-09-15 06:40:47.000000000 -0700
> +++ t/response/TestMore/testmorepm.pm	2004-08-05 06:43:16.000000000 -0700
> @@ -0,0 +1,21 @@
> +package TestMore::testmorepm;
> +
> +use strict;
> +use warnings FATAL => qw(all);
> +
> +use Test::More;
> +use Apache::Test qw(-withtestmore);
> +
> +sub handler {
> +
> +  plan shift, tests => 2;
> +
> +  is (1, 1, 'called Test::More::is()');
> +
> +  like ('wow', qr/wow/, 'called Test::More::like()');
> +
> +  0;

What's 0? Should it be Apache::OK?

> +}
> +
> +1;
> 
> --- /dev/null	2003-09-15 06:40:47.000000000 -0700
> +++ t/response/TestMore/testpm.pm	2004-08-05 06:40:14.000000000 -0700
> @@ -0,0 +1,18 @@
> +package TestMore::testpm;
> +
> +use strict;
> +use warnings FATAL => qw(all);
> +
> +use Apache::Test;
> +use Apache::TestUtil;
> +
> +sub handler {
> +
> +  plan shift, tests => 1;
> +
> +  ok t_cmp(1, 1, 'called Apache::Test::ok()');
> +
> +  0;

ditto


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

Mime
View raw message