You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@perl.apache.org by "Philippe M. Chiasson" <go...@cpan.org> on 2004/02/10 02:40:33 UTC

Re: cvs commit: modperl-2.0/t/conf extra.last.conf.in perlsection.conf

On Mon, 2004-02-09 at 16:38 -0800, Stas Bekman wrote:
> Philippe M. Chiasson wrote:
> > On Mon, 2004-02-09 at 15:15 -0800, Stas Bekman wrote:
> > 
> >>gozer@apache.org wrote:
> >>
> >>>gozer       2004/02/09 14:20:53
> >>>
> >>>  Modified:    t/conf   extra.last.conf.in
> >>>  Removed:     t/conf   perlsection.conf
> >>>  Log:
> >>>  To test recursive/re-entrant <Perl> sections, autogenerate the included file
> >>>  instead of having to keep t/conf/perlsection.conf in CVS
> >>
> >>[...]
> >>This causes:
> >>
> >>[Mon Feb 09 15:15:10 2004] [info] 5 APR:: modules loaded
> >>[Mon Feb 09 15:15:10 2004] [info] base server + 15 vhosts ready to run tests
> >>waiting 120 seconds for server to start: 00:03#
> >># writing file: /home/stas/apache.org/mp2-mutex/t/conf/perlsection.conf
> >>waiting 120 seconds for server to start: 00:06# removing file: 
> >>/home/stas/apache.org/mp2-mutex/t/conf/perlsection.conf
> >>
> >>Use Apache::TestConfig::writefile instead?
> > 
> > 
> > I did notice that, but I ended up liking it, as perlsection.conf is
> > created, included & then deleted right away, just sufficient for the
> > test. No leftover perlsection.conf file left lying around.
> 
> yeah, but it totally messes up the startup messages.

Oh, it's an aesthetic thing. Consider it fixed. 

> > What's the advantage of using A::TC::writefile instead ?
> 
> It doesn't cleanup the files and doesn't log what it does. I see no reason why 
> would you want to delete it. t_write_file is for the test run-time.

I can't really call Apache::TestConfig->new from within the <Perl>
section, so how about I do it all myself on my own like so :

Index: t/conf/extra.last.conf.in
===================================================================
RCS file: /home/cvs/modperl-2.0/t/conf/extra.last.conf.in,v
retrieving revision 1.12
diff -u -I$Id -r1.12 extra.last.conf.in
--- t/conf/extra.last.conf.in   10 Feb 2004 00:14:11 -0000      1.12
+++ t/conf/extra.last.conf.in   10 Feb 2004 01:39:28 -0000
@@ -32,11 +32,12 @@
 #Handle re-entrant <Perl> sections
 <Perl >
     use File::Spec;
-    use Apache::TestUtil;
     my $file = File::Spec->catfile('@ServerRoot@', 'conf', 'perlsection.conf');
-    my $conf = join "\n", qw(<Perl> $TestDirective::perl::Included++; </Perl>);
-    Apache::TestUtil::t_write_file($file, $conf);
+    open(my $fh, ">$file");
+    print $fh join "\n", qw(<Perl> $TestDirective::perl::Included++; </Perl>);
+    close($fh);
     $Include = $file;
+    END { unlink($file); };
 </Perl>


> __________________________________________________________________
> 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
-- 
--------------------------------------------------------------------------------
Philippe M. Chiasson /gozer\@(cpan|ectoplasm)\.org/ 88C3A5A5 (122FF51B/C634E37B)
http://gozer.ectoplasm.org/    F9BF E0C2 480E 7680 1AE5 3631 CB32 A107 88C3 A5A5
Q: It is impossible to make anything foolproof because fools are so ingenious.
perl -e'$$=\${gozer};{$_=unpack(P7,pack(L,$$));/^JAm_pH\n$/&&print||$$++&&redo}'

Re: cvs commit: modperl-2.0/t/conf extra.last.conf.in perlsection.conf

Posted by "Philippe M. Chiasson" <go...@cpan.org>.
On Mon, 2004-02-09 at 17:58 -0800, Stas Bekman wrote:
> Philippe M. Chiasson wrote:
> 
> >>>What's the advantage of using A::TC::writefile instead ?
> >>
> >>It doesn't cleanup the files and doesn't log what it does. I see no reason why 
> >>would you want to delete it. t_write_file is for the test run-time.
> > 
> > 
> > I can't really call Apache::TestConfig->new from within the <Perl>
> > section, so how about I do it all myself on my own like so :
> 
> right, that would be an overkill too.

Checked in with a cleaned up version of my previous patch.

> [..]
> >      $Include = $file;
> > +    END { unlink($file); };
> 
> On the opposite, I think it should not be deleted. If something goes wrong and 
> the file is deleted, after using its name in the error report how user is 
> supposed to know where to look?

Hrm, yes, I guess so, and it does no harm to leave it there and
regenerate it on each test run.

> It's really like conf.in, but you can't use that feature, because you want to 
> include it elsewhere.

yup

> Another solution is just move it somewhere under t/htdocs/ and keep the 
> perlsection.conf cvs committed as you did in first place. No need to 
> autogenerate things then.

Bah, I like the autogenerated stuff, since it keeps the 2 parts of the
test closely together.

> >  </Perl>
> 
> 
> __________________________________________________________________
> 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
-- 
--------------------------------------------------------------------------------
Philippe M. Chiasson /gozer\@(cpan|ectoplasm)\.org/ 88C3A5A5 (122FF51B/C634E37B)
http://gozer.ectoplasm.org/    F9BF E0C2 480E 7680 1AE5 3631 CB32 A107 88C3 A5A5
Q: It is impossible to make anything foolproof because fools are so ingenious.
perl -e'$$=\${gozer};{$_=unpack(P7,pack(L,$$));/^JAm_pH\n$/&&print||$$++&&redo}'

Re: cvs commit: modperl-2.0/t/conf extra.last.conf.in perlsection.conf

Posted by Stas Bekman <st...@stason.org>.
Philippe M. Chiasson wrote:

>>>What's the advantage of using A::TC::writefile instead ?
>>
>>It doesn't cleanup the files and doesn't log what it does. I see no reason why 
>>would you want to delete it. t_write_file is for the test run-time.
> 
> 
> I can't really call Apache::TestConfig->new from within the <Perl>
> section, so how about I do it all myself on my own like so :

right, that would be an overkill too.

> Index: t/conf/extra.last.conf.in
> ===================================================================
> RCS file: /home/cvs/modperl-2.0/t/conf/extra.last.conf.in,v
> retrieving revision 1.12
> diff -u -I$Id -r1.12 extra.last.conf.in
> --- t/conf/extra.last.conf.in   10 Feb 2004 00:14:11 -0000      1.12
> +++ t/conf/extra.last.conf.in   10 Feb 2004 01:39:28 -0000
> @@ -32,11 +32,12 @@
>  #Handle re-entrant <Perl> sections
>  <Perl >
>      use File::Spec;
> -    use Apache::TestUtil;
>      my $file = File::Spec->catfile('@ServerRoot@', 'conf', 'perlsection.conf');
> -    my $conf = join "\n", qw(<Perl> $TestDirective::perl::Included++; </Perl>);
> -    Apache::TestUtil::t_write_file($file, $conf);
> +    open(my $fh, ">$file");

or die ...

> +    print $fh join "\n", qw(<Perl> $TestDirective::perl::Included++; </Perl>);
> +    close($fh);

please use braces consistenly (i.e. don't use them ;)

>      $Include = $file;
> +    END { unlink($file); };

On the opposite, I think it should not be deleted. If something goes wrong and 
the file is deleted, after using its name in the error report how user is 
supposed to know where to look?

It's really like conf.in, but you can't use that feature, because you want to 
include it elsewhere.

Another solution is just move it somewhere under t/htdocs/ and keep the 
perlsection.conf cvs committed as you did in first place. No need to 
autogenerate things then.

>  </Perl>


__________________________________________________________________
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

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org