Re: Apache::Test question
[prev]
[thread]
[next]
[Date index for 2004/12/16]
Torsten Foertsch wrote:
> On Wednesday 15 December 2004 20:46, Stas Bekman wrote:
>
>>Torsten Foertsch wrote:
>>
>>>But how do I know it in the tests? Is there another way except of
>>>scanning conf/httpd.conf?
>>
>>You do:
>>
>>use Apache::Test;
>>plan tests => 5, need_module 'ssl';
>>
>>It's documented in the Apache::Test manpage and also here:
>>http://perl.apache.org/docs/general/testing/testing.html
>>feel free to suggest an improvement if you couldn't find that information
>>when you read those docs. (you did read those, right? :)
>
>
> yes, I did. I am aware of need_module() and have_module() being almost
> the same thing. Now please have a look at Apache::ModSSL/t/1is_https.t
> and TEST.PL:
>
> TEST.PL:
> -----------------------------------------------------------------------------------------------
> ...
> my $I=Apache::TestRunPerl->new;
>
> my @argv=@ARGV; # save it
>
> $I->run(@ARGV);
> system "cp t/conf/apache_test_config.pm t/conf/apache_test_config.pm1";
>
> Apache::TestConfig::autoconfig_skip_module_add('mod_ssl.c');
>
> $I->refresh;
>
> $I->run(@argv);
> system "cp t/conf/apache_test_config.pm t/conf/apache_test_config.pm2";
> -----------------------------------------------------------------------------------------------
>
> For debugging I am duplicating the generated apache_test_config.pm files.
> They do differ. The 2nd one lacks the "LoadModule ssl_module" as expected.
>
> ...
> @@ -308,10 +308,6 @@
> LoadModule rewrite_module "/usr/lib/apache2-prefork/mod_rewrite.so"
> </IfModule>
> ',
> - '<IfModule !mod_ssl.c>
> - LoadModule ssl_module "/usr/lib/apache2-prefork/mod_ssl.so"
> -</IfModule>
> -',
> '<IfModule !mod_unique_id.c>
> LoadModule unique_id_module "/usr/lib/apache2-prefork/mod_unique_id.so"
> </IfModule>
> ...
>
> 1is_https.t:
> -----------------------------------------------------------------------------------------------
> ...
> sub ssl_loaded {
> open my $f, "t/conf/httpd.conf" or die "ERROR: Cannot read t/conf/httpd.conf: $!";
> return grep(/^\s*LoadModule\s+ssl_module\b/, <$f>) ? 1 : 0;
> }
> ...
> #if( have_module('ssl') ) {
> if( ssl_loaded ) {
> plan tests => 2;
>
> ok t_cmp( test( 'default', 'is_https' ), "HAVE_SSL=1 is_https: 0\n", "no ssl" );
> ok t_cmp( test( 'SSL', 'is_https' ), "HAVE_SSL=1 is_https: 1\n", "ssl" );
> } else {
> plan tests => 1;
>
> ok t_cmp( test( 'default', 'is_https' ), "HAVE_SSL= is_https: UNDEF\n", "no ssl" );
> }
> -----------------------------------------------------------------------------------------------
>
> My ssl_loaded() function distinguishes between the 2 cases, have_module('ssl')
> does not. With have_module() always the 1st case is entered.
>
> Here is an excerpt of Apache::Test:
>
> sub need_module {
> ...
> for (@modules) {
> ...
> next if $cfg->{modules}->{$mod};
> if (exists $cfg->{cmodules_disabled}->{$mod}) {
> push @reasons, $cfg->{cmodules_disabled}->{$mod};
> next;
> }
> ...
> }
> ...
> }
>
> Since my Apache::TestConfig in both cases contains "mod_ssl.c" in
> $cfg->{modules} the test will succeed. The
> "Apache::TestConfig::autoconfig_skip_module_add('mod_ssl.c');"
> is disregarded while generating this hash.
Right, because as you've figured out t/conf/apache_test_config.pm is a
cached version of the the test setup data. So you need to do a cleanup
before reconfiguring things so that file gets updated. Note that you
perform things A-T has no top-level support for at the moment. Since your
hack uses internal APIs it can break any moment if things change. So it's
important to provide a public API for this kind of purposes.
grep the source for reconfigure() which I think will enforce the re-cache.
--
__________________________________________________________________
Stas Bekman JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide ---> http://perl.apache.org
mailto:stas@xxxxxx.xxx http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org http://ticketmaster.com
--
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html
 |
(message missing)
|